Skip to content

Commit

Permalink
feat: add params to h3 event object for api router
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrojcm committed Mar 10, 2024
1 parent 618149b commit 963b343
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/vinxi-router/api-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const routes = [
...route,
handler: async (event, params) => {
const mod = await route.$handler.import();
return await mod.default(event, params);
event.context['params'] = params
return await mod.default(event);
},
})),
];
Expand Down Expand Up @@ -35,7 +36,9 @@ function createRouter(routes) {
for (let i = 0; i < route.keys.length; i++) {
params[route.keys[i].name] = match[i + 1];
}
return await route.handler(event, params);
// add params to context object
event.context['params'] = params
return await route.handler(event);
}
}

Expand Down

0 comments on commit 963b343

Please sign in to comment.