Skip to content

Commit

Permalink
async arrow function instead of explicit promise
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamero committed Feb 27, 2025
1 parent 1d6f770 commit 7ad4824
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ import { PromiseMiddleware } from './gen/middleware.js';
export function withHeaderMiddleware(key: string, value: string): Middleware[] {
return [
{
pre: (c: RequestContext) => {
return new Promise<RequestContext>((resolve) => {
c.setHeaderParam(key, value);
resolve(c);
});
pre: async (c: RequestContext) => {
c.setHeaderParam(key, value);
return c;
},
post: (c: ResponseContext) => {
return new Promise<ResponseContext>((resolve) => {
resolve(c);
});
post: async (c: ResponseContext) => {
return c;
},
},
];
Expand Down

0 comments on commit 7ad4824

Please sign in to comment.