mirror of
https://github.com/movie-web/backend.git
synced 2025-09-13 18:13:26 +00:00
fix bugs + add a lot of endpoints
Co-authored-by: William Oldham <github@binaryoverload.co.uk>
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
validatorCompiler,
|
||||
} from 'fastify-type-provider-zod';
|
||||
import { ZodError } from 'zod';
|
||||
import { StatusError } from '@/services/error';
|
||||
|
||||
const log = scopedLogger('fastify');
|
||||
|
||||
@@ -31,8 +32,8 @@ export async function setupFastify(): Promise<FastifyInstance> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (err.statusCode) {
|
||||
reply.status(err.statusCode).send({
|
||||
if (err instanceof StatusError) {
|
||||
reply.status(err.errorStatusCode).send({
|
||||
errorType: 'message',
|
||||
message: err.message,
|
||||
});
|
||||
|
@@ -1,6 +1,18 @@
|
||||
import { loginAuthRouter } from '@/routes/auth/login';
|
||||
import { manageAuthRouter } from '@/routes/auth/manage';
|
||||
import { metaRouter } from '@/routes/meta';
|
||||
import { sessionsRouter } from '@/routes/sessions';
|
||||
import { userDeleteRouter } from '@/routes/users/delete';
|
||||
import { userEditRouter } from '@/routes/users/edit';
|
||||
import { userSessionsRouter } from '@/routes/users/sessions';
|
||||
import { FastifyInstance } from 'fastify';
|
||||
|
||||
export async function setupRoutes(app: FastifyInstance) {
|
||||
app.register(manageAuthRouter.register);
|
||||
app.register(loginAuthRouter.register);
|
||||
app.register(userSessionsRouter.register);
|
||||
app.register(sessionsRouter.register);
|
||||
app.register(userEditRouter.register);
|
||||
app.register(userDeleteRouter.register);
|
||||
app.register(metaRouter.register);
|
||||
}
|
||||
|
Reference in New Issue
Block a user