This package has been deprecated

Author message:

not maintained

specla-router

0.0.6 • Public • Published

Specla Router

npm version Build Status

This is the routing module for the Specla Framework. Its a wrapper on top of the express router and it enables you to specify a path to the folder where your controllers are located. The goal of this module is to make it easier to include your controllers for your application.

Install

npm install specla-router --save

Setup

const Router = require('specla-router');
const express = require('express');
const app = express();

const router = new Router(app, {
  path: __dirname+'/api/controllers'
});

// basic route to a controller action
router.get('/', 'Controller.action');

// route with middleware
router.get('/authenticated', [authenticated], 'Controller.action');

app.listen(3000);

Controllers

The example below is the boilerplate code for a Controller. The class contuctor will work as a middleware function.

class Controller {

  constructor(req, res){
    // Do something before the action is triggered
  }

  action(req, res){
    res.send('Controller action!');
  }
}

module.exports = Controller;

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Published

Version History

  • Version
    Downloads (Last 7 Days)
    • Published

Package Sidebar

Install

npm i specla-router

Weekly Downloads

3

Version

0.0.6

License

MIT

Last publish

Collaborators

  • kvartborg