GitNexus/gitnexus/test/fixtures/lang-resolution/api-e2e-test/middleware/auth.ts

7 lines
214 B
TypeScript

export function withAuth(handler: Function) {
return async (req: Request) => {
const token = req.headers.get('Authorization');
if (!token) throw new Error('Unauthorized');
return handler(req);
};
}