This neat little script let's you develop Express apps without using something like nodemon to reload your server between changes.
Usage:
- Put
dev.js
outside your project source folder,scripts/dev.js
is what I'm using. - Make sure your actual app in
src/index.js
exports the Express instance itself without listening:
import express from 'express'
const app = express()
app.use('/foo', (req, res) => res.send('Bar'))
export default app
- Run
node scripts/dev
and enjoy.
Nice reference! Think line 27 in dev.js needs to be
handler = require(sourcePath).default
?