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 34 35 | 2x 2x 2x 2x 2x 2x 2x 2x | 'use strict'; import * as _ from 'lodash'; 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 => { Iif (!_.isPlainObject(route)) { Iif (verbose) console.log('[@owservable/fastify-auto-routes] -> addRoute: ROUTE PROBLEM', relativeFilePath, route); return; } Iif (!_.has(route, 'url')) { Iif (verbose) console.log('[@owservable/fastify-auto-routes] -> addRoute: MISSING URL WARNING', relativeFilePath); _.set(route, 'url', '/'); } const {url} = route; Iif (!_.startsWith(_.toLower(url), relativeFilePath)) _.set(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); Iif (verbose) console.log('[@owservable/fastify-auto-routes] -> addRoute: Added route', route.method, route.url, '\n'); }; export default addRoute; |