# express-hotmods

> Reload and use new modules without restarting Express.

Latest version **1.0.3** (published 2016-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-hotmods
pnpm add express-hotmods
yarn add express-hotmods
bun add express-hotmods
```

## 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.0.3 |
| Published | 2016-03-09 |
| First published | 2016-03-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Slade Colling |
| Maintainers | slade |
| Keywords | Express, modules, middleware, reload |

## Links

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

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2016-03-09
- 1.0.2 — 2016-03-05
- 1.0.1 — 2016-03-04
- 1.0.0 — 2016-03-04

## README

# express-hotmods

### Automatically reload your express modules with a keyword parameter in url. 

One thing i enjoyed about PHP was the ability to edit a .php script and just reload the web page to see changes.
Now with express-hotmods you can reload your modules and their child modules by adding a keyword parameter to your urls while you are developing.
##### http://my_express_server.com/path/to/module?some_param=value&_reload

### Installation:
```sh
$ npm install express-hotmods
```
### Use:
in your express router e.g  *app.js*
```js
var app = express();
app.use('/api', require('express-hotmods')(__dirname + '/api', '__reload'));
```
### Constructor:
```js
 require('express-hotmods')('path', 'keyword'));
```
 - path: full path to folder with express modules.
 - keyword: parameter to reload modules.  e.g '_debug'

### Modules
example express app
```
.
+-- app.js
+-- views/
+-- routes/
+-- api/
    +-- my_module.js
    +-- another_module.js
```

```js
app.use('/api', require('express-hotmods')(__dirname + '/api', '_reload'));
```
###### http://my_express_server.com/api/my_module?_reload
The module name is called directly in url (- .js)

#### Call function endpoints in modules:
###### http://my_express_server.com/api/another_module/_function1?_reload
If the last path item starts with '_' **express-hotmods** will attempt to call _function_ name.

in *another_module.js*
```js
module.exports = {
    function1: function1,
    function2: function2,    
};
...
function function1(req,res){
  ...
}
...
function function2(req,res){
  ...
}
```
#### Child modules
**express-hotmods** will also try reload all child modules required by your module.

##### Note
Use of `setInterval` in a module gets loaded in the global space and does not get destroyed on reload, so you will end up with multiple `setInterval` running after each reloading, so not recommended at the moment, unless I can figure out how to control them.
##### TODO
 - Finish rendering a module usage viewer if you hit http://my_express_server.com/folder/ 
 - Node does not seem to list child modules correctly in *Modules* object  if another module has already loaded same child module  
This is my first published npm module, so any pointers or improvements would be appreciated.

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