racer-http
v0.1.8
Published
A lightweight HTTP library for NodeJS
Downloads
4
Readme
Racer
A lightweight HTTP library for NodeJS
Installation
With NPM:
$ npm install racer-http --save
Or with Yarn:
$ yarn add racer-http
Basic example
Note: This example uses Babel, but of course you can use the library without Babel.
import { Server, Router } from '../lib/'
import { join } from 'path'
Router.registerMiddleware('/', (req, res, next) => {
if(req.param('name') === 'google') {
return res.redirect('https://google.com')
}
return next(req, res)
})
Router.get('/', (req, res) => {
const name = req.name
res.view('app.pug', { name })
})
Router.post('/posts', (req, res) => {
const { title, content } = req.params
res.json({ error: false, message: 'Post created'})
})
new Server(8000)
.debug(true)
.start()
Documentation
Coming up!