wee-router
A router middleware for easywee. Convention over Configuration
Installation
npm install wee-router --save
Usage
const router = ;const app = ;app; app;
Then define route in the routes.js
file
moduleexports = "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 atctx.params
orctx.request.params
Options
Default options (As convention
)
cwd: process routes: 'config/routes.json'
cwd
current working directoryroutes
routes table defination file, relative to cwd