summary refs log tree commit diff
path: root/src/api/routes.js
diff options
context:
space:
mode:
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