Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpbberry/express-router-reload
Reload your express routes super easily
https://github.com/jpbberry/express-router-reload
developer-tools express express-js express-router
Last synced: about 1 month ago
JSON representation
Reload your express routes super easily
- Host: GitHub
- URL: https://github.com/jpbberry/express-router-reload
- Owner: jpbberry
- Created: 2019-04-17T20:59:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-03T22:50:09.000Z (over 5 years ago)
- Last Synced: 2024-11-15T05:51:42.244Z (about 2 months ago)
- Topics: developer-tools, express, express-js, express-router
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# express-router-reload
Easy to use, hot swapper for your express routes.## Examples
```js
const express = require('express'); // normal express what nots
var app = express();
var router = require('./routers/router.js');const RR = require('express-router-reload');
let reloader = new RR(app);app.use("/route", router);
// After whatever else. Let's say you change the file
delete require.cache[require.resolve("./routers/router.js")];
router = require('./routers/router.js');//now
reloader.reload("/route", router);// Overwrites the old router with the new refreshed one!
```#### An easier way:
```js
const RR = require('express-router-reload');
let reloader = new RR(app);//express stuff...
reloader.reloadFromFile("/route", path.resolve(__dirname, "./routes/router.js"));
//The second paramater MUST be the full path.
//This basically just does the delete require.cache[require.resolve(path)] for you!
```### Links
[NPM Package](https://npmjs.com/package/express-router-reload)\
[GitHub](https://github.com/jpbberry/express-router-reload)\
[Creator's Website](https://www.jt3ch.net)