Simple route middleware for Servie.
npm install servie-route --save
import { get, post } from 'servie-route'
import { compose } from 'throwback'
const animals = [
'rabbit',
'dog',
'cat'
]
const app = compose([
get('/pets', function () {
return new Response({ body: animals })
}),
get('/pets/:id', function (req) {
return new Response({ body: animals[Number(req.params[0])] })
})
])
This project is written using TypeScript and publishes the definitions directly to NPM.
Apache 2.0