summary refs log tree commit diff
path: root/src/api/routes.js
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-06-01 17:41:31 +0200
committerRory& <root@rory.gay>2025-06-01 17:41:31 +0200
commit27cda7df659852317d751b4354f75dd54878d4a7 (patch)
tree6447a352b3b8395a3f51c4c4c647bc004473218a /src/api/routes.js
parentRewrite routing (diff)
downloadnodejs-final-assignment-27cda7df659852317d751b4354f75dd54878d4a7.tar.xz
Add sensor history, balance
Diffstat (limited to 'src/api/routes.js')
-rw-r--r--src/api/routes.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/api/routes.js b/src/api/routes.js

index ade440e..e808d50 100644 --- a/src/api/routes.js +++ b/src/api/routes.js
@@ -1,11 +1,13 @@ import * as routes from './routes/index.js'; -function logHttpEntry(method, route, exampleBody) { +function logHttpEntry(method, route, exampleBody, description) { + if (description) console.log('%', '#', description); + console.log('%', method, '{{baseUrl}}' + route, 'HTTP/1.1'); if (exampleBody) { console.log('%', 'Content-Type: application/json'); console.log('% '); - console.log('%', exampleBody); + console.log('%', JSON.stringify(exampleBody, null, 4)); console.log('% '); } console.log('% '); @@ -22,17 +24,22 @@ export function registerRoutes(app) { * @type {RouteDescription} */ const route = routes[routeName]; - console.log( - `Registering ${routeName} (${route.path})`, - routes[routeName] - ); Object.keys(route.methods).forEach(routeMethodName => { /** * @type {RouteMethod} */ const routeMethod = route.methods[routeMethodName]; - console.log(routeMethodName, routeMethod); + console.log( + 'Registering', + routeMethodName.toUpperCase(), + route.path + ); + logHttpEntry( + routeMethodName.toUpperCase(), + route.path, + routeMethod.exampleBody + ); app[routeMethodName](route.path, [ ...routeMethod.middlewares, routeMethod.method