Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osprey-router

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osprey-router

Simple middleware-style router for RAML based on router

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
639
decreased by-31.8%
Maintainers
3
Weekly downloads
 
Created
Source

Osprey Router

NPM version Build status Test coverage Greenkeeper badge

Simple middleware-style router for RAML based on router.

Installation

npm install osprey-router --save

Usage

This module is an instance of router with support for RAML paths and parameters.

Router(options)

All options and functions from router are supported, except the second argument can be an optional array of webapi-parser Parameter objects. For example:

const finalhandler = require('finalhandler')
const http = require('http')
const Router = require('osprey-router')
const utils = require('./utils')

const router = Router()
const parameters = utils.getUriParameters()

router.get('/{userId}', parameters, function (req, res) {
  console.log(typeof req.params.userId)

  res.setHeader('Content-Type', 'text/plain; charset=utf-8')
  res.end(req.params.userId)
})

const server = http.createServer(function (req, res) {
  router(req, res, finalhandler(req, res))
})

server.listen(3000)

When you specify the parameter type, it'll automatically be parsed in the native JavaScript type.

License

Apache 2.0

Keywords

FAQs

Package last updated on 28 Jul 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc