1.3.2 • Published 2 years ago

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

Weekly downloads
-
License
ISC
Repository
-
Last release
2 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

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.9

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago