racer-http
TypeScript icon, indicating that this package has built-in type declarations

0.1.8 • Public • Published

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!

Package Sidebar

Install

npm i racer-http

Weekly Downloads

3

Version

0.1.8

License

MIT

Unpacked Size

38.5 kB

Total Files

12

Last publish

Collaborators

  • webd