0.29.3 • Published 4 years ago
worker-runtime v0.29.3
Worker Runtime
A core component of a serverless architecture inspired by Cloudflare Workers
Get started
npm i
cd example
npm i
node index.js
Example
worker.js
addEventListener('fetch', (e) => {
e.respondWith(new Response('hello world', { status: 200 }))
})
index.js
const { Runtime } = require('worker-runtime')
const path = require('path')
const http = require('http')
const runtime = new Runtime(path.resolve(__dirname, './worker.js'))
runtime.start()
http
.createServer((request, response) => {
runtime.request({
type: 'fetch',
payload: { request, response },
})
})
.listen(8080, () => {
console.log('Listing on port 8080')
})
Roadmap
- Remove youkuohao-cli (use rollup config)
Extension Mechanism
TODO
Compatibility
node.js >=v16.0.0
Warning
IT'S NOT A SECURITY MECHANISM, DON'T RUN UNTRUSTED CODE.