29 lines
789 B
TypeScript
29 lines
789 B
TypeScript
import { FastifyError } from 'fastify';
|
|
|
|
export const InvalidPayload = () =>
|
|
({
|
|
code: '400',
|
|
statusCode: 400,
|
|
name: 'InvalidPayload',
|
|
message:
|
|
"Payload type is invalid. Did you forget to set a proper 'Content-Type'?",
|
|
}) as FastifyError;
|
|
|
|
export const ValidationError = (err?: string) =>
|
|
({
|
|
code: '400',
|
|
statusCode: 400,
|
|
name: 'ValidationError',
|
|
message: err
|
|
? 'The schema does not match'
|
|
: 'The schema does not match: ' + err,
|
|
}) as FastifyError;
|
|
|
|
export const InvalidAuthorization = () =>
|
|
({
|
|
code: '401',
|
|
statusCode: 401,
|
|
name: 'InvalidAuthorization',
|
|
message: 'Provided authorization credentials are invalid',
|
|
}) as FastifyError;
|