Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 3x 3x 3x 3x 3x 3x 21x 4x 4x 17x 2x 2x 17x 17x 17x 17x 17x 17x 17x 17x 3x | 'use strict'; import RoutesMap from '../routes.map'; import fixUrl from './fix.url'; import fixTags from './fix.tags'; import fixSchema from './fix.schema'; import fixRouteMethod from './fix.route.method'; const addRoute: Function = (fastify: any, route: any, relativeFilePath: string, verbose: boolean = false): void => { if (!route || typeof route !== 'object' || Array.isArray(route)) { if (verbose) console.log('[@owservable/fastify-auto-routes] -> addRoute: ROUTE PROBLEM', relativeFilePath, route); return; } if (!('url' in route)) { if (verbose) console.log('[@owservable/fastify-auto-routes] -> addRoute: MISSING URL WARNING', relativeFilePath); route.url = '/'; } const {url} = route; if (!url.toLowerCase().startsWith(relativeFilePath)) route.url = fixUrl(url, relativeFilePath); route.method = fixRouteMethod(route, verbose); route.schema = fixSchema(route); route.schema.tags = fixTags(route, relativeFilePath); fastify.route(route); RoutesMap.add(route.method, route.url); if (verbose) console.log('[@owservable/fastify-auto-routes] -> addRoute: Added route', route.method, route.url); }; export default addRoute; |