Socket
Book a DemoInstallSign in
Socket

ravine

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ravine

ravine is a simple router middleware for nodejs

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

ravine

Build Status

ravine is a simple router middleware for nodejs

with ravine routes are just javascript arrays. use javascript array manipulation functions to construct and manipulate routes.

install

npm install ravine

use

http = require 'http'

ravine = require 'ravine'

middleware = ravine [
    ['ALL', '*', (req, res, next) ->
        # called before all following routes
        next()
    ]
    ['GET', '/', (req, res, next) ->
        # called only on GET /
        res.end 'hello'
    ]
    ['ALL', '/users*', (req, res, next) ->
        # called before all following routes if the request url starts with /users
        next()
    ]
    ['POST', '/users', (req, res, next) ->
        res.end 'post'
    ]
    ['PUT', '/users/:id', (req, res, next) ->
        # called on PUT /users/7 for example. req.params will then be {id: 7}
        res.end 'put ' + req.params.id
    ]
    ['DELETE', '/users/:id', (req, res, next) ->
        # called on DELETE /users/18 for example. req.params will then be {id: 18}
        res.end 'delete ' + req.params.id
    ]
]

server = http.createServer middleware

server.listen 80

see url-pattern for supported url patterns. the parameters extracted from the url will be available as req.params.

license: MIT

FAQs

Package last updated on 05 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts