1.4.1 • Published 9 months ago

minitel-minipavi v1.4.1

Weekly downloads
-
License
Hippocratic-2.1
Repository
github
Last release
9 months ago

minitel-minipavi

!NOTE This is meant specifically for users of the minitel- ecosystem by me (immjs).

It 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

Example

import { Minitel, TextNode } from 'minitel-standalone';
import { DuplexBridge } from 'ws-duplex-bridge';
import { createMinipaviHandler } from 'minitel-minipavi';

createMinipaviHandler(
  (ws) => {
    const stream = new DuplexBridge(ws, { decodeStrings: false });
    const minitel = new Minitel(stream, {});
    minitel.appendChild(new TextNode('Hello world!', {}, minitel));

    minitel.renderToStream();

    setTimeout(() => stream.end(), 10_000);
  },
  {
    host: '0.0.0.0',
    port: 4545,
  },
).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

ParameterTypeDescription
minitelFactory(ws: WebSocket) => anyA factory function to handle WebSocket connections.
optionsMinipaviHandlerOptionsConfiguration options for the handler.

MinipaviHandlerOptions

OptionTypeDescription
portnumberRequired. Specifies the port on which the server will listen.
hoststringRequired. Specifies the host for the server. Note that 0.0.0.0 is the option to allow all incomming connections, while 127.0.0.1 will only allow connections from 127.0.0.1.
versionstringOptional. Specifies the version that will be given to MiniPAVI. Defaults to '1.0'.
providePavibooleanOptional. If true, provides the PAVI field as query parameters. Defaults to false.
provideDirectUrlbooleanOptional. If true, provides the DIRECTURL field as query parameters. Defaults to false.
httpsbooleanOptional. If true, enables HTTPS. You will have to create the HTTPS server yourself, either by using serverFactory or third party software such as nginx). Defaults to false.
serverFactory(handler: any, opts: any) => http.ServerOptional. Custom server factory function. Defaults to creating an HTTP server.
withFastify(server: FastifyInstance) => anyOptional. Custom function to work with Fastify instance. Defaults to a no-op function.
1.4.1

9 months ago

1.4.0

9 months ago

1.3.0

11 months ago

1.2.0

12 months ago

1.1.2

12 months ago

1.1.0

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago