Skip to content

Commit

Permalink
refactor: move AuthenticateState to the middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKolarik committed Jan 29, 2024
1 parent c406d27 commit 912d044
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lib/http/middleware/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ export const authenticate: ExtendedMiddleware = async (ctx, next) => {

return next();
};

export type AuthenticateState = { userId?: string };
3 changes: 2 additions & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type Koa from 'koa';
import type Router from '@koa/router';
import type { DocsLinkContext } from './lib/http/middleware/docs-link.js';
import type { AuthenticateState } from './lib/http/middleware/authenticate.js';

export type CustomState = Koa.DefaultState & { userId?: string };
export type CustomState = Koa.DefaultState & AuthenticateState;
export type CustomContext = Koa.DefaultContext & DocsLinkContext;

export type ExtendedContext = Router.RouterContext<CustomState, CustomContext>;
Expand Down

0 comments on commit 912d044

Please sign in to comment.