1.1.0 • Published 8 years ago

route-401 v1.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

Documentation

Route-401 is an express style router.

Things To Be Aware Of

The callback for all routes takes a "request" and a "response" argument. There is functionality to add request parameters, but only one. These are accessible through the req.params object. Ex:

app.get('/files/:file', (req, res) => { // this will work
  console.log(req.params.file); // will log the file name you requested
});

app.get('/:user/files/:file') // this will NOT work

Set Up Router

Here is an example of how to set up your router:

const http = require('http');
const Router = require('route-401');
const app = new Router();

app.get('/', (req, res) => {
  // Do Stuff
});

app.post('/uploads', (req, res) => {
  // Do Stuff
});

app.delete('/uploads/:file', (req, res) => {
  // Delete Stuff
});

http.createServer(app.serverCallback()).listen(3000, () => {console.log('server up');});