Files
Gallus_Pub/backend/src/middleware/auth.middleware.ts

13 lines
262 B
TypeScript

import { FastifyRequest, FastifyReply } from 'fastify';
export async function authenticate(
request: FastifyRequest,
reply: FastifyReply
) {
try {
await request.jwtVerify();
} catch (err) {
reply.code(401).send({ error: 'Unauthorized' });
}
}