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

route-scout

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

route-scout

A framework that handles the routing for you and makes your server-creating life much easier. Also makes you look younger and more attractive. Results may vary.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

Route Scout - Finds the paths for you!

A framework that handles the routing for you and makes your server-creating life much easier. Also makes you look younger and more attractive. Results may vary.

Features

  • easy to use
  • simplifies using all common routing requests
  • lets you create your own routing requests
  • built in handler for static files
  • lets add variables to your routes
  • lightweight

Is it any good?

Yes.

Installation

$ npm install route-scout

Getting Started

Route-Scout relies on the built in http node module as demonstrated below.

const routescout = require('route-scout');
const server = require('http');

routescout.get('/', (req, res) => {
  res.write( 'Hello World!' );
  res.end();
});

server.createServer(routescout.routes()).listen(9000);

Framework Methods

  • routescout.get( path, callback )

Creates a route for incoming GET requests at the passed in URL, the callback takes two arguments: request and response.

GET requests retrieve data form the server. GET reads.

  • routescout.post( path, callback )

Creates a route for incoming POST requests at the passed in URL, the callback takes two arguments: request and response.

POST requests are used to send data to the server. POST creates.

  • routescout.patch( path, callback )

Creates a route for incoming PATCH requests at the passed in URL, the callback takes two arguments: request and response.

PATCH requests change data on the server. PATCH updates/modifies

  • routescout.put( path, callback )

Creates a route for incoming PUT requests at the passed in URL, the callback takes two arguments: request and response.

PUT requests change or replace data on the server. PUT updates/replaces

  • routescout.delete( path, callback )

Creates a route for incoming DELETE requests at the passed in URL, the callback takes two arguments: request and response.

DELETE requests delete data from the server.

  • routescout.createRoute( object )

Creates a route for whatever you want to create a route for at the passed in URL. The object requires three keys: URL, method and handler. Method must be all uppercase!

  • routescout.static( path )

Serves static objects from the folder located in path.

Examples

var routescout = require( 'routescout' );

// GET Request
routescout.get( '/examplePath', (req, res) => {
  res.write ( 'GET request to the homepage.' );
  res.end();
});

// POST Request
routescout.post( '/examplePath', (req, res) => {
  res.write ( 'POST request to the homepage.' );
  res.end();
});

// PATCH Request
routescout.patch( '/examplePath', (req, res) => {
  res.write ( 'PATCH request to the homepage.' );
  res.end();
});

// PUT request
routescout.put( '/examplePath', (req,res) => {
  res.write ( 'PUT request to the homepage.');
  res.end();
});

// DELETE Request
routescout.delete( '/examplePath', (req, res) => {
  res.write ( 'DELETE request to the homepage.' );
  res.end();
});

// CREATE ROUTE Request
routescout.createRoute( {
  url: '/example/path',
  method: 'HEAD',
  handler: (req, res) => {
    res.write ( 'HEAD request to the homepage.' );
    res.end();
  })
});

// Static handler
routescout.static( '/public');



Options

URL Variables and Request Parameters

For URL you can add a variable with a : and this will pass it to the request object with a property of params.

// Parameters in the Request object
routescout.get( '/examplePath/:variable', (req, res) => {
  res.write ( 'Access variable' + req.params.variable );
  res.end();
});

Dependencies

None. We're independent that way :)

Dev Dependencies

FAQs

Package last updated on 27 May 2016

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