0.1.8 • Published 6 years ago

racer-http v0.1.8

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Racer

Build Status npm

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!

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.0.5

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago