ericclemmons / polydev

Faster, route-centric development for Node.js apps with built-in Hot Module Replacement.
282 stars 6 forks source link

per-branch deployments #38

Open ericclemmons opened 5 years ago

ericclemmons commented 5 years ago

Here's a crazy idea:

  1. /routes/branch/:name
  2. module.exports = async () => ...
  3. Clone that branch into that a tmp folder.
  4. return require(tmp)

In theory, this could work!

There would need to be a ~5 minute or ~10 minute timer to kill lambdas, but that's easy.

ericclemmons commented 5 years ago

This seems necessary, mainly because of the need to rewrite URLs:

https://github.com/chimurai/http-proxy-middleware

With that said, the support for package.json could be an option.

Here's a potential solution:

module.exports = (req, res) => {
  const { branch } req.params

  if (!started) {
    execSync(...allTheThings)
    require('./path/to/branch/server') // PORT should be set!
  }

  return httpProxyMiddleware(...)
}