Skip to content

Commit

Permalink
example for middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPlayz0 committed Dec 22, 2023
1 parent 8795148 commit 1cba160
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ const api = new Server<typeof context>({
enabled: true,
folder: './routes',
context: context,
middleware: [
{
name: 'test',
when: 'precors',
handle: async (req, res, next) => {
console.log('this is before anything ever happens!');
next();
},
}
],
documentation: {
enabled: true,
open_api: {
Expand Down Expand Up @@ -48,4 +58,15 @@ const api = new Server<typeof context>({

export type RouteHandler = typeof api.routeHandler<HTTPContext>;

// Prior to starting the server, you can middleware
// api.addMiddleware({
// name: 'test',
// when: 'precors',
// middleware: async (req, res, next) => {
// console.log('this is before anything ever happens!');
// next();
// },
// });

// Start the server
api.listen();

0 comments on commit 1cba160

Please sign in to comment.