Skip to content

pakastin/subnode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

subnode

Child Node.js process which you can proxy to.

install

npm install subnode

usage

server.js

const express = require('express');
const subnode = require('subnode');

const api = subnode('./api/index');

const app = express();

app.use('/api', api.proxy);

app.get('/', (req, res, next) => {
  res.send('Hello from 80');
});

app.listen(80);

api/index.js

const express = require('express');

const { NODE_PORT } = process.env;

const app = express();

app.set('trust proxy', true);

app.get('/', (req, res, next) => {
  res.send(`Hello from ${NODE_PORT} to ${req.ip}`);
});

app.listen(NODE_PORT);

How does it work?

When you create "subnode", it gets forked with a random port number and included with NODE_PORT environment value.

About

Child Node.js process which you can proxy to.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published