Initial commit - version 1.0.0

This commit is contained in:
2023-05-30 17:38:55 -04:00
commit 1f3eb0b9c9
23 changed files with 9396 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { Middleware } from 'koa';
import { GatekeeperUser } from './types/GatekeeperUser';
declare module 'koa' {
interface ExtendableContext {
user: GatekeeperUser | null;
isAuthenticated(): boolean;
isUnauthenticated(): boolean;
logout(): void;
}
}
export const initialize: Middleware = (ctx) => {
ctx.user = null;
ctx.isAuthenticated = () => !!ctx.user;
ctx.isUnauthenticated = () => !ctx.user;
ctx.logout = () => (ctx.user = null);
};