|
|
@ -6,16 +6,16 @@ export default class Request |
|
|
|
* Handle the incoming request |
|
|
|
*/ |
|
|
|
public async handle(request: FastifyRequest, reply: FastifyReply) { |
|
|
|
if (!this.checkFormat(request)) { |
|
|
|
reply.status(401); |
|
|
|
if (!this.isAuthorized(request)) { |
|
|
|
reply.status(403); |
|
|
|
return { |
|
|
|
status: "unauthorized" |
|
|
|
status: "Forbidden" |
|
|
|
}; |
|
|
|
} |
|
|
|
if (!this.checkFormat(request)) { |
|
|
|
reply.status(400); |
|
|
|
return { |
|
|
|
status: "bad request" |
|
|
|
status: "Bad request" |
|
|
|
}; |
|
|
|
} |
|
|
|
try { |
|
|
@ -23,7 +23,7 @@ export default class Request |
|
|
|
} catch(errors) { |
|
|
|
reply.status(422); |
|
|
|
return { |
|
|
|
status: "unprocessable entities", |
|
|
|
status: "Unprocessable entities", |
|
|
|
errors |
|
|
|
}; |
|
|
|
} |
|
|
@ -34,7 +34,7 @@ export default class Request |
|
|
|
/** |
|
|
|
* Check if the user is authorized to make this request |
|
|
|
*/ |
|
|
|
public isAuthorized() { |
|
|
|
public isAuthorized(request: FastifyRequest) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|