Skip to content

Instantly share code, notes, and snippets.

@wadez
Last active June 13, 2021 22:07
Show Gist options
  • Save wadez/9815760613060015784d212e2da09bbd to your computer and use it in GitHub Desktop.
Save wadez/9815760613060015784d212e2da09bbd to your computer and use it in GitHub Desktop.
const express = require('express')
const app = express()
const Pool = require('jpool');
// middleare
app.use((req, res) => {
const pool = new Pool();
req.job = (filename) => {
pool.add(path.resolve(__dirname, `jobs/${filename}.js`), req)
}
})
// route
app.post('/email/change', function (req, res) {
req.job("sendEmail");
res.send('email change requested')
})
app.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment