# decorator-router-express

> Express strategy for decorator-router

Latest version **1.1.0** (published 2015-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install decorator-router-express
pnpm add decorator-router-express
yarn add decorator-router-express
bun add decorator-router-express
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2015-11-29 |
| First published | 2015-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Thomas Sileghem |
| Maintainers | mastilver |

## Links

- npm: https://www.npmjs.com/package/decorator-router-express
- Repository: https://github.com/mastilver/decorator-router-express
- Homepage: https://github.com/mastilver/decorator-router-express#readme
- Issues: https://github.com/mastilver/decorator-router-express/issues
- npm.io page: https://npm.io/package/decorator-router-express

## Recent versions

- 1.1.0 (latest) — 2015-11-29
- 1.0.0 — 2015-11-27

## README

# decorator-router-express [![Build Status](https://travis-ci.org/mastilver/decorator-router-express.svg?branch=master)](https://travis-ci.org/mastilver/decorator-router-express)

> Express strategy for [decorator-router](https://github.com/mastilver/decorator-router)


## Install

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


## Usage

Given a controller `controller/homeCtrl.js`
```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:
```js
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](http://mastilver.com)

---
_Source: https://npm.io/package/decorator-router-express · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
