UNPKG

@akala/core

Version:
51 lines 1.51 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const r = __importStar(require("../router")); class Router extends r.Router { constructor(options) { super(options); } buildLayer(path, options, handler) { return new r.Layer(path, options, handler); } buildRoute(path) { return new r.Route(path); } } var router = new Router(); router.use('/api/', function (req, next) { console.log('api'); next(); }); var ra = new Router(); var rb = new Router(); ra.use('/:id?', function (req, next) { console.log('a' + req.url); console.log(req.params); }); rb.use('/:id?', function (req, next) { console.log('b' + req.url); console.log(req.params); }); router.use('/api/a', ra.router); router.use('/api/b', rb.router); // router.handleRoute({ path: '/' }); // router.handleRoute({ path: '/a' }); // router.handleRoute({ path: '/api/pwic' }); router.handle({ url: '/api/a' }, function () { console.log('failed'); }); // router.handle({ url: '/api/a/pwic' }, function () // { // console.log('failed'); // }); // router.handleRoute({ path: '/api/b' }); // router.handleRoute({ path: '/api/b/pwic' }); //# sourceMappingURL=router.js.map