Skip to content

Commit 7e725f7

Browse files
committed
Update options object
1 parent d1c0c94 commit 7e725f7

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apiv",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "A Hapi.js plugin that automatically adds version prefixes to all your API routes, making it easy to version your API endpoints.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ const plugin: Plugin<ApiVersionPluginOptions> = {
5656
realm.modifiers.route.prefix = globalPrefix
5757

5858
const extractRouteOptions = (settings: any) => {
59-
const options: any = {
60-
handler: settings.handler
61-
}
59+
const options: any = {}
6260

6361
const propsToCopy = [
6462
'auth', 'bind', 'description', 'id', 'isInternal', 'notes', 'tags'
@@ -156,7 +154,7 @@ const plugin: Plugin<ApiVersionPluginOptions> = {
156154

157155
if (apivConfig === false || apivConfig?.enabled === false) {
158156
const routeOptions = extractRouteOptions(route.settings)
159-
server.route({ ...routeOptions, method: route.method, path: originalPath })
157+
server.route({ method: route.method, path: originalPath, handler: route.settings.handler, options: routeOptions })
160158
continue
161159
}
162160

@@ -170,7 +168,7 @@ const plugin: Plugin<ApiVersionPluginOptions> = {
170168

171169
if (aliasPath !== route.path) {
172170
const routeOptions = extractRouteOptions(route.settings)
173-
server.route({ ...routeOptions, method: route.method, path: aliasPath })
171+
server.route({ method: route.method, path: aliasPath, handler: route.settings.handler, options: routeOptions })
174172
}
175173
}
176174
})

0 commit comments

Comments
 (0)