13 lines
262 B
TypeScript
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' });
|
|
}
|
|
}
|