An open API service indexing awesome lists of open source software.

https://github.com/anonrig/politics

Politics is a simplistic router with async/await support for node.js with a 1.7 kB size.
https://github.com/anonrig/politics

Last synced: 3 months ago
JSON representation

Politics is a simplistic router with async/await support for node.js with a 1.7 kB size.

Awesome Lists containing this project

README

          

Politics for node.js
===

Without the hassle, without the politics, let's just return json.

Usage
===

```javascript
const Politics = require('politics')
const app = new Politics({port: 8000})
const router = new Politics.Router()

router.get('/', (req, res) => ({hello: 'world'}))
router.get('/users(/:id)', ({params, query, method}, res) => ({id: params.id, query, method}))
router.delete('/users(/:id)', ({params, query, method}, res) => ({id: params.id, query, method}))
router.set404((req, res) => ({status: 404}))

app.setRouter(router)

app
.listen()
.then(() => console.info(`Server listening on port ${app.port}`))
.catch(console.error)
```