44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { Type } from '@sinclair/typebox'
|
|
|
|
export const fastifyErrorsSchema = {
|
|
400: {
|
|
statusCode: Type.Literal(400),
|
|
error: Type.Literal('Bad Request'),
|
|
message: Type.String()
|
|
},
|
|
401: {
|
|
statusCode: Type.Literal(401),
|
|
error: Type.Literal('Unauthorized'),
|
|
message: Type.Literal('Unauthorized')
|
|
},
|
|
403: {
|
|
statusCode: Type.Literal(403),
|
|
error: Type.Literal('Forbidden'),
|
|
message: Type.Literal('Forbidden')
|
|
},
|
|
404: {
|
|
statusCode: Type.Literal(404),
|
|
error: Type.Literal('Not Found'),
|
|
message: Type.Literal('Not Found')
|
|
},
|
|
431: {
|
|
statusCode: Type.Literal(431),
|
|
error: Type.Literal('Request Header Fields Too Large'),
|
|
message: Type.String()
|
|
},
|
|
500: {
|
|
statusCode: Type.Literal(500),
|
|
error: Type.Literal('Internal Server Error'),
|
|
message: Type.Literal('Something went wrong')
|
|
}
|
|
}
|
|
|
|
export const fastifyErrors = {
|
|
400: Type.Object(fastifyErrorsSchema[400]),
|
|
401: Type.Object(fastifyErrorsSchema[401]),
|
|
403: Type.Object(fastifyErrorsSchema[403]),
|
|
404: Type.Object(fastifyErrorsSchema[404]),
|
|
431: Type.Object(fastifyErrorsSchema[431]),
|
|
500: Type.Object(fastifyErrorsSchema[500])
|
|
}
|