minitel-cloudflare-worker
v2.0.2
Published
A cloudflare worker for access through MiniPAVI
Downloads
11
Readme
minitel-cloudflare-worker
[!NOTE] This is meant specifically for users of the
minitel-
ecosystem by me (immjs), and specifically for use with cloudflare workersIt can also be used by whomever needs to hook up MiniPAVI with a websocket based minitel server.
Opens up an HTTP(s) server for access through minipavi
[!NOTE] Unlike
minitel-minipavi
, the first argument tominitelFactory
is already a duplex stream which means you need to enable nodejs compat You may access the request using the second argument, for instance to access the PAVI argument if you setprovidePAVI: true
Example
import { Minitel, TextNode } from 'minitel-standalone';
import { createMinipaviHandler } from 'minitel-cloudflare-worker';
export default createMinipaviHandler(
(stream) => {
const minitel = new Minitel(stream, {});
minitel.appendChild(new TextNode('Hello world!', {}, minitel));
minitel.renderToStream();
setTimeout(() => stream.end(), 10_000);
},
).then(() => console.log('MiniPavi handler ready!'));
Reference
createMinipaviHandler
Function
Returns
A Promise that will resolve when the MiniPAVI handler will be up and running
Parameters
| Parameter | Type | Description |
| ---------------- | ------------------------- | --------------------------------------------------- |
| minitelFactory
| (stream: Duplex) => any
| A factory function to handle WebSocket connections. |
| options
| MinipaviHandlerOptions
| Configuration options for the handler. |
MinipaviHandlerOptions
| Option | Type | Description |
| ------------------ | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| version
| string
| Optional. Specifies the version that will be given to MiniPAVI. Defaults to '1.0'
. |
| providePavi
| boolean
| Optional. If true, provides the PAVI field as query parameters. Defaults to false
. |
| provideDirectUrl
| boolean
| Optional. If true, provides the DIRECTURL field as query parameters. Defaults to false
. |