laplax
v0.1.5
Published
A Node.js http/1.0 multithreaded framework with a basic IPC. <img src="https://raw.githubusercontent.com/lastshadowpl/laplax/master/logo.svg" alt="logo"/>
Downloads
3
Readme
Laplax
A Node.js http/1.0 multithreaded framework with a basic IPC.
Features
- Full intellisense support.
- Built-in IPC support.
Getting started
Basic Usage
const Laplax = require('laplax')
const m = new Laplax.Master()
m.get('/', ({ req, res }) => {
res.write('Hello!')
})
m.listen(8000)
More Advanced Routing
const { Master, sendMessage } = require('laplax')
/* Accepts a list of commands to run before initializing the server */
const master = new Master([
'npm run build'
])
master.enslave('GET', '/', async ({ res }) => {
/* Sends a message to the master process in order to get/update the state */
const { name } = await sendMessage(process, {
workerId: process.env['workerId'],
msgs: [
{
type: 'update',
key: 'name',
payload: 'Jon Snow',
}
]
})
res.write(`You know nothing ${name}`)
return {
continue: false,
}
})
master.listen(8000)
Known issues
- EventEmitter memory leak in sendMessage when overloaded with requests. Event listeners are cleared anyway, so it's not such a big issue.