Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions frameworks/morojs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,26 @@ MoroJS on its native HTTP engine, clustered by the framework itself.
(TLS 1.3, ALPN `http/1.1`), when `/certs/server.crt` and `/certs/server.key` are mounted. Moro
locks one configuration per process, so that listener is a second process running the same file
with `MORO_ROLE=tls`, clustered the same way; it is not started when the certificates are absent. The
engine terminates TLS on its own OpenSSL BIOs (1.1.17): one copy in, ciphertext appended straight
into the buffer it sends from, and a body over 8 KiB encrypted from the caller's bytes rather than
engine terminates TLS with the BoringSSL it bundles (`@morojs/engine` 1.1.20; kept current by a
scheduled engine release for every upstream snapshot) on its own BIOs (1.1.17): one copy in,
ciphertext appended straight into the buffer it sends from, and a body over 8 KiB encrypted
from the caller's bytes rather than
copied behind the head first. Measured at one worker on these three request mixes, CPU per request
fell by a fifth on the static files, a seventh on the JSON bodies and a sixth on the 100 KB echo.
- `tls_check` is opted into: a third process of the same file (`MORO_ROLE=tlscheck`) listens on
`9000` reading `/certs-tls`, with `server.ssl.watch: true`, so a pair replaced on disk is
validated and swapped onto the running listener without a restart and without touching
connections already established. Only started when `/certs-tls` is mounted, which validate.sh
alone does.
- `baseline-h2`, `static-h2`, `baseline-h2c` and `json-h2c` run on Moro's HTTP/2 server, which is
Node's http2 module behind the framework's own request and response objects (`engine: 'node'`
with `http2: true`); the native engine speaks HTTP/1.1 only. `:8443` terminates TLS with ALPN
`h2` (HTTP/1.1 still accepted), `:8082` is cleartext prior-knowledge HTTP/2. Each is its own
process for the same one-configuration-per-process reason, clustered as node:cluster processes,
which is Moro's transport for its Node servers.
- `baseline-h2`, `static-h2`, `baseline-h2c` and `json-h2c` run on the native engine's own HTTP/2
(`http2: true`; RFC 9113 and HPACK implemented in the engine, `@morojs/engine` 1.1.19), behind
the same request and response objects, routes and middleware as HTTP/1.1. `:8443` terminates TLS
with ALPN `h2` (HTTP/1.1 still accepted), `:8082` is cleartext prior-knowledge HTTP/2 with
HTTP/1.1 beside it. Each is its own process for the same one-configuration-per-process reason,
clustered on worker threads like the other listeners.
- `/echo` sends back `req.rawBody`, the request body as it arrived, `Content-Length` or chunked
alike. The engine collects the body where its reads land and hands that storage to JavaScript
without a copy (`@morojs/engine` 1.1.18); `req.rawBody` is a Buffer view of it. A Buffer handed
to `res.send()` goes out `application/octet-stream` through the framework's prepared reply.
alike, in the framework's default body handling. A Buffer handed to `res.send()` goes out
`application/octet-stream` through the framework's prepared reply.
- `/ws` is the engine's own RFC 6455 support through `app.websocket()` with `{ raw: true }`, so a
text frame reaches the handler as the string it carried and `socket.send()` returns it as one.
The engine corks the connection for the duration of each read (`@morojs/engine` 1.1.14), so
Expand Down
26 changes: 10 additions & 16 deletions frameworks/morojs/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ const CERTS_DIR = process.env.CERTS_DIR || '/certs';
// process. 'plain' serves :8080; 'tls' serves json-tls, static-tls and 8gbit
// on :8081 from /certs; 'tlscheck' serves the opt-in TLS hardening section on
// :9000 from /certs-tls, reloading the pair whenever the files change. The
// two HTTP/2 listeners run on Moro's own HTTP/2 server (Node's http2 module,
// `engine: 'node'` with `http2: true`): the native engine speaks HTTP/1.1
// only. 'h2' is TLS with ALPN h2 on :8443 for baseline-h2 and static-h2;
// two HTTP/2 listeners are the native engine's too (`http2: true`, engine
// 1.1.19): 'h2' is TLS with ALPN h2 on :8443 for baseline-h2 and static-h2;
// 'h2c' is cleartext prior-knowledge HTTP/2 on :8082 for baseline-h2c and
// json-h2c. Both cluster as node:cluster processes, Moro's transport for the
// Node servers.
// json-h2c. HTTP/1.1 is served beside HTTP/2 on both ports, and they cluster
// as every other listener here does, on worker threads.
const ROLE = process.env.MORO_ROLE || 'plain';
const LISTENERS = {
plain: { port: 8080 },
Expand Down Expand Up @@ -192,14 +191,10 @@ function defineRoutes(app) {
app.post('/baseline11').handler(baseline11);

// Behind the gateway proxies, which terminate TLS and h2 and forward this
// over loopback h1, and directly on the HTTP/2 listeners. On the native
// engine a bare number sent as a string is text/plain through the
// framework's prepared reply; on the HTTP/2 server the type is set by
// hand so it is text/plain there too, whatever a content sniff would make
// of it.
const textPlain = listener.http2 === true;
// over loopback h1, and directly on the HTTP/2 listeners. A bare number
// sent as a string is text/plain through the framework's prepared reply,
// on a stream as on an HTTP/1.1 connection.
app.get('/baseline2').handler((req, res) => {
if (textPlain) res.setHeader('Content-Type', 'text/plain');
res.send(String(sumQuery(req.query)));
});

Expand Down Expand Up @@ -255,9 +250,9 @@ function defineRoutes(app) {
}

// 8gbit: the body exactly as it arrived, Content-Length or chunked, sent
// back as the same bytes. req.rawBody is the framework's undecoded copy,
// and a Buffer sent as is goes out application/octet-stream through the
// framework's prepared reply.
// back as the same bytes. req.rawBody is the body undecoded, a Buffer of
// its own. A Buffer sent as is goes out application/octet-stream through
// the framework's prepared reply.
app.post('/echo').handler((req, res) => {
res.send(req.rawBody ?? Buffer.alloc(0));
});
Expand Down Expand Up @@ -442,7 +437,6 @@ if (listener.certs) {
server.ssl = { ...pairIn(listener.certs), ...(listener.watch ? { watch: true } : {}) };
}
if (listener.http2) {
server.engine = 'node';
server.http2 = true;
}

Expand Down
2 changes: 1 addition & 1 deletion frameworks/morojs/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"response": true
},
"engine": "@morojs/engine",
"description": "MoroJS 1.8 on its native HTTP engine (@morojs/engine), default configuration, clustered by the framework itself with one worker thread per core sharing the port through SO_REUSEPORT. Routing, path and query parameters and body parsing through the Moro request, JSON through res.json, compression (brotli quality 3 or gzip level 3 as the client accepts, one reused encoder per setting per worker, handed to the engine's own response path by the route middleware), static files from the built-in middleware's in-memory cache and the cache-aside through the built-in cache adapters, WebSockets through the engine's own RFC 6455 support, upgrades included, HTTP/2 through Moro's HTTP/2 server on Node's http2 module.",
"description": "MoroJS 1.8 on its native HTTP engine (@morojs/engine), clustered by the framework itself with one worker thread per core sharing the port through SO_REUSEPORT. Routing, path and query parameters and body parsing through the Moro request, JSON through res.json, compression (brotli quality 3 or gzip level 3 as the client accepts, one reused encoder per setting per worker, handed to the engine's own response path by the route middleware), static files from the built-in middleware's in-memory cache and the cache-aside through the built-in cache adapters, WebSockets through the engine's own RFC 6455 support, upgrades included, HTTP/2 through the engine's own implementation (ALPN h2 on TLS, prior knowledge on cleartext), TLS through the BoringSSL bundled with the engine.",
"repo": "https://github.com/Moro-JS/moro",
"enabled": true,
"tls_check": true,
Expand Down
2 changes: 1 addition & 1 deletion frameworks/morojs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "httparena-morojs",
"private": true,
"dependencies": {
"@morojs/moro": "^1.8.22",
"@morojs/moro": "^1.8.24",
"ejs": "^3.1.10",
"pg": "^8.16.3",
"redis": "^5.0.0"
Expand Down
18 changes: 9 additions & 9 deletions site/data/frameworks.json
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@
},
"morojs": {
"dir": "morojs",
"description": "MoroJS 1.8 on its native HTTP engine (@morojs/engine), default configuration, clustered by the framework itself with one worker thread per core sharing the port through SO_REUSEPORT. Routing, path and query parameters and body parsing through the Moro request, JSON through res.json, compression (brotli quality 3 or gzip level 3 as the client accepts, one reused encoder per setting per worker, handed to the engine's own response path by the route middleware), static files from the built-in middleware's in-memory cache and the cache-aside through the built-in cache adapters, WebSockets through the engine's own RFC 6455 support, upgrades included, HTTP/2 through Moro's HTTP/2 server on Node's http2 module.",
"description": "MoroJS 1.8 on its native HTTP engine (@morojs/engine), clustered by the framework itself with one worker thread per core sharing the port through SO_REUSEPORT. Routing, path and query parameters and body parsing through the Moro request, JSON through res.json, compression (brotli quality 3 or gzip level 3 as the client accepts, one reused encoder per setting per worker, handed to the engine's own response path by the route middleware), static files from the built-in middleware's in-memory cache and the cache-aside through the built-in cache adapters, WebSockets through the engine's own RFC 6455 support, upgrades included, HTTP/2 through the engine's own implementation (ALPN h2 on TLS, prior knowledge on cleartext), TLS through the BoringSSL bundled with the engine.",
"repo": "https://github.com/Moro-JS/moro",
"type": "emerging",
"engine": "@morojs/engine",
Expand Down Expand Up @@ -2748,14 +2748,6 @@
"type": "engine",
"engine": "veb"
},
"veil": {
"dir": "veil",
"description": "veil 0.10 reverse proxy from its published container image (full-container build: epoll readiness reactor, no tokio), one process with four listeners. A Proxy-Wasm module loaded into veil answers /baseline11 (including the POST body), /baseline2, /pipeline and /json/{count}, serializing the JSON body per request from the dataset veil loads at startup; /static/* is veil's File backend (sendfile, on-the-fly compression on every protocol, caches that follow the disk). TLS via rustls: HTTP/1.1 on :8081, h2 and h3 (quiche) on :8443, h2c on :8082.",
"repo": "https://github.com/aofusa/veil-proxy",
"type": "infrastructure",
"engine": "veil",
"website": "https://github.com/aofusa/veil-proxy"
},
"veil-api": {
"dir": "veil-api",
"description": "veil 0.10 API library (crates.io veil-proxy, full-container: epoll readiness reactor, no tokio or hyper). #[veil::route] handlers with path/query extraction, serde_json responses, compression through [api] compression, WebSocket through WebSocketUpgrade, gRPC services generated by veil-build (prost), /static/* through App::serve_dir. One process with four listeners from the configuration file; HTTP/3 via quiche.",
Expand Down Expand Up @@ -2783,6 +2775,14 @@
"middleware": false
}
},
"veil": {
"dir": "veil",
"description": "veil 0.10 reverse proxy from its published container image (full-container build: epoll readiness reactor, no tokio), one process with four listeners. A Proxy-Wasm module loaded into veil answers /baseline11 (including the POST body), /baseline2, /pipeline and /json/{count}, serializing the JSON body per request from the dataset veil loads at startup; /static/* is veil's File backend (sendfile, on-the-fly compression on every protocol, caches that follow the disk). TLS via rustls: HTTP/1.1 on :8081, h2 and h3 (quiche) on :8443, h2c on :8082.",
"repo": "https://github.com/aofusa/veil-proxy",
"type": "infrastructure",
"engine": "veil",
"website": "https://github.com/aofusa/veil-proxy"
},
"velocity": {
"dir": "velocity",
"description": "Velocity, a lightweight Express.js alternative on node:http with the cluster module for multi-core scaling.",
Expand Down
Loading