From 27cda7df659852317d751b4354f75dd54878d4a7 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 1 Jun 2025 17:41:31 +0200 Subject: Add sensor history, balance --- src/api/routes.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/api/routes.js') 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 -- cgit 1.5.1