New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

wee-router

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wee-router

A router middleware for wee.

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

wee-router

A router middleware for easywee. Convention over Configuration

Installation

npm install wee-router --save

Usage

const router = require('wee-router');
const app = require('koa')();
app.use(router({
    routes: './routes.js' // routes table defination file
}));

app.listen(5000);

Then define route in the routes.js file

module.exports = [
    "get /login => accounts#login",
    "get /logout => accounts#logout",

    //rest api
    "get /posts", //get all posts
    "get /posts/:id", //get a post using id :id, such as "/posts/211" will get a parameter id=211
    "post /posts", //create a post
];

We recommend using .js file to define routing information, because you can use the comments to describe the route in .js file . Also you can define the routing table using .json file.

Route data will be stored at ctx.route in every request, and route params will be stored at ctx.params or ctx.request.params

Options

Default options (As convention)

{
    cwd: process.cwd(),
    routes: 'config/routes.json'
}
  • cwd current working directory
  • routes routes table defination file, relative to cwd

License

MIT

Keywords

router

FAQs

Package last updated on 15 Aug 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