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 36 37 38 39 40 41 42 43 | 2x 2x 2x 24x 1x 23x 23x 2x 18x 23x 26x 26x | // @ts-ignore
import Router from 'radix-router';
import { stripSlashes } from '@feathersjs/commons';
import { Application } from '@feathersjs/feathers';
export const ROUTER = Symbol('@feathersjs/transport-commons/router');
declare module '@feathersjs/feathers' {
interface Application<ServiceTypes> {
lookup(path: string): { [key: string]: string };
}
}
export const routing = () => (app: Application) => {
if (typeof app.lookup === 'function') {
return;
}
const router = new Router();
Object.assign(app, {
[ROUTER]: router,
lookup(path: string): { [key: string]: string } {
if (!path) {
return null;
}
return this[ROUTER].lookup(stripSlashes('' + path) || '/');
}
});
// Add a mixin that registers a service on the router
app.mixins.push((service, path) => {
// @ts-ignore
app[ROUTER].insert({ path, service });
// @ts-ignore
app[ROUTER].insert({
path: `${path}/:__id`,
service
});
});
};
|