Add controllers for 404 and the root endpoint

This commit is contained in:
Stephan
2022-05-17 16:16:26 +02:00
parent 645baf1f8a
commit 3ec5f92429
2 changed files with 32 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import { Request, Response } from "express";
// Only called when no other route matches
export function notFoundHandler(req: Request, res: Response) {
return res.status(404).json({
type: "error",
payload: {
message: `The ${req.method} HTTP method is implemented for '${req.path}'`,
_links: [
{
rel: "root",
href: "/api",
},
],
},
});
}
export function rootHandler(req: Request, res: Response) {
return res.status(200).json({
type: "success",
payload: {
message: "Detleph event API",
detail: "This is the API for the Detleph event system",
},
});
}