Skip to content

Commit

Permalink
feat(api)[#33]: Logout route
Browse files Browse the repository at this point in the history
  • Loading branch information
corentin-lechene authored and DynamoRed committed Mar 5, 2023
1 parent 520544e commit 7c5ca93
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils/Responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@ import { Response } from "express";
export default class Responses {
static OK(res: Response): void {
res.status(200).send({message: "OK"});
console.log(`[${res.req.method}][${res.req.url}] <= ${res.statusCode}`);
}

static Custom(res: Response, body: object, status: number = 200): void {
res.status(status).send(body);
console.log(`[${res.req.method}][${res.req.url}] <= ${res.statusCode}`);
}

static BadRequest(res: Response): void {
res.status(400).send({message: "Bad Request"});
console.log(`[${res.req.method}][${res.req.url}] <= ${res.statusCode}`);
}

static NotFound(res: Response): void {
res.status(404).send({message: "Not Found"});
console.log(`[${res.req.method}][${res.req.url}] <= ${res.statusCode}`);
}

static Unauthorized(res: Response): void {
res.status(401).send({message: "Unauthorized"});
console.log(`[${res.req.method}][${res.req.url}] <= ${res.statusCode}`);
}

static ErrorUnknown(res: Response): void {
res.status(500).send({message: "Something went wrong"});
console.log(`[${res.req.method}][${res.req.url}] <= ${res.statusCode}`);
}
}

0 comments on commit 7c5ca93

Please sign in to comment.