npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-hotmods

v1.0.3

Published

Reload and use new modules without restarting Express.

Downloads

2

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:

$ npm install express-hotmods

Use:

in your express router e.g app.js

var app = express();
app.use('/api', require('express-hotmods')(__dirname + '/api', '__reload'));

Constructor:

 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
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

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.