MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at type-hints-typescript 13 lines 590 B view raw
1import { createRouter, addRoute, findRoute } from './index.js'; 2 3const router = createRouter(); 4 5addRoute(router, 'GET', '/path', { payload: 'this path' }); 6addRoute(router, 'POST', '/path/:name', { payload: 'named route' }); 7addRoute(router, 'GET', '/path/foo/**', { payload: 'wildcard route' }); 8addRoute(router, 'GET', '/path/foo/**:name', { payload: 'named wildcard route' }); 9 10console.log(findRoute(router, 'GET', '/path')); 11console.log(findRoute(router, 'POST', '/path/fooval')); 12console.log(findRoute(router, 'GET', '/path/foo/bar/baz')); 13console.log(findRoute(router, 'GET', '/'));