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

decorator-router-express

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decorator-router-express

Express strategy for decorator-router

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

decorator-router-express Build Status

Express strategy for decorator-router

Install

$ npm install --save decorator-router decorator-router-express

Usage

Given a controller controller/homeCtrl.js

import {httpGet, middlewareFactory} from 'decorator-router';

const isLoggedIn = middlewareFactory(function(res, req, next){
    /*   check if user is logged in   */
    next();
});

const isRole = middlewareFactory(role => function(res, req, next){
    /*   check if user have the right role   */
    next();
});

export default {
    @isLoggedIn
    @httpGet('/')
    getIndex(req, res){
        res.ok();
    },

    @isRole('admin')
    @httpGet('/admin')
    getAdminPortal(req, res){
        res.ok();
    }
}

You can register those routes by doing:

import decoratorRouter = from 'decorator-router';
import decoratorRouterExpress = from 'decorator-router-express';
import express from 'express';

let app = express();

decoratorRouter('controller/*Ctrl.js', decoratorRouterExpress, app)
.then(x => {
    console.log('done');
});

License

MIT © Thomas Sileghem

FAQs

Package last updated on 29 Nov 2015

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