@soniccodes/hotpress
v0.5.3
Published
Were you ever sick of waiting for express to restart the server just to test a simple change, now that's a thing of the past.
Downloads
16
Maintainers
Readme
HotPress 🔥 - Hot Reloading for ExpressJs
Philosophy
- Why should you restart a http server just for a small change in your source code. isn't HTTP meant to be stateless.
- Aren't you meant to have a static fetch-once properties for development.
If you agree with those philosophies, then you'll love HotPress.
What HotPress does is that it only initializes the server and required parameters once and pass it to your virtual server (Router).
Usage
npm install @soniccodes/hotpress
yarn add @soniccodes/hotpress
./foo.js - The reloadable file
/**
@param server : Router
**/
function reload(server) {
server.get("/hi",function(req, res){
res.send("hi")
})
//Anything you'd do with a normal server.
}
modules.export = reload //This is very important
server.js
global.rootPatch = __dirname //Very important
const express = require("express")
const {setup,reload} = require("@soniccodes/hotpress")
const app = express()
setup({server:app,reloadable:"./foo.js"}) //Note: Relative path
app.listen(port,(err)=>{
if(err) throw err;
console.log("⚡ Ready on http://localhost:"+port);
})
Here's what you should expect.
Before
After
License
Copyright 2021 Rami Mohammed
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.