3 ms·
One example would be a url router for a web server that turns the url variables into the handler's expected argument type and ignores requests that do not.
by hombre_fatal 8y ago
One example would be a url router for a web server that turns the url variables into the handler's expected argument type and ignores requests that do not.
router.get('/users/:id', (id: UUID) => ...)
router.get('/products/:id', (id: Int) => ...)
- tracker1 8y agoThat would be relatively easy to do something very similar with middleware for express/koa router.get('/users/:id'. skipNonUuid(id => ...)) You simply have a function/middleware that does the check.... or `compose(skipNonUuid, dbo.findUserById, ui.formatView('modelName'))` You can do function composition that is nearly as simple and far more flexible in general with JS