1.3.2 • Published 3 years ago

@nr-sfly/express-dynamic-routes v1.3.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Express Dynamic Router

Create a dynamic Express router based on files structure

Usage

Install

npm install @nr-sfly/express-dynamic-routes --save

Usage

import express from 'express';
import {dynamicRouter} from "@nr-sfly/express-dynamic-routes";

const port = 3000;

const app = express();
app.use(express.json());

app.use(dynamicRouter(__dirname))

app.listen(port, () => console.log(`listen port ${port}`));

This folder/file structure

│
├───base
│   ├───index.get.ts
│   ├───health.get.ts
│   └───todos
│       ├───index.get.ts
│       ├───create.post.ts
│       └───:id.get.ts
│
└───app.ts

will transform

URLFileMethod
/base/index.get.tsGET
/healthbase/health.get.tsGET
/todosbase/todos/index.get.tsGET
/todos/createbase/todos/create.post.tsPOST
/todos/:idbase/todos/:id.tsGET
1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago