# mlwn-derouter

> Declarative router module for Express.

Latest version **0.3.0** (published 2022-01-21) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install mlwn-derouter
pnpm add mlwn-derouter
yarn add mlwn-derouter
bun add mlwn-derouter
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2022-01-21 |
| First published | 2022-01-21 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 21.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tomas Kavan |
| Maintainers | jan.palenik |
| Keywords | express, router, declarative |

## Links

- npm: https://www.npmjs.com/package/mlwn-derouter
- Issues: https://github.com/tomasKavan/derouter/issues
- npm.io page: https://npm.io/package/mlwn-derouter

## Dependencies (4)

- [express](https://npm.io/package/express.md) ^4.17.1
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.6
- [express-session](https://npm.io/package/express-session.md) ^1.17.1
- [http-status-codes](https://npm.io/package/http-status-codes.md) ^2.1.4

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 0.3.0 (latest) — 2022-01-21

## README

![npm](https://img.shields.io/npm/v/derouter)

# derouter
Declaratory router for express js

## init path
-  depends on node env variable (process.env.INIT_CWD): 
```bash
INIT_CWD
```
- it should be set to root of project

## index.js file of app
```javascript
// Load modules
import express from 'express'
import derouter from '../../main.mjs'

const routerDeclaration = {
  prefix: '/hello',
  middleware: [
    (req, res, next) => {
      console.log('----hello middleware---')

      /**
       * Necessary to call function next() (Express middleware)
       */
      next()
    }
  ],
  routes: {
    GET: {
      '/:name': [
        'example.basic.action.today->date',
        'example.basic.action.greet:#Greetings:&.date:params.name'
      ]
    }
  }
}

const app = express()

async function init() {
  // load routes async
  const routes = await derouter(routerDeclaration)

  app.use(routes)

  const port = 8083
  app.listen(port, () => {
    console.log(`App listening on port ${port}`)
  })  
}

init()
```

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