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.
- Host: GitHub
- URL: https://github.com/anonrig/politics
- Owner: anonrig
- Created: 2018-08-07T14:37:12.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-07T14:52:10.000Z (almost 8 years ago)
- Last Synced: 2025-03-18T12:12:40.096Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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)
```