npm.io
0.1.5 • Published yesterdayCLI

@lit-pigeon/rest

Licence
MIT
Version
0.1.5
Deps
3
Size
40 kB
Vulns
0
Weekly
0

@lit-pigeon/rest

Framework-agnostic Node REST adapter for Lit Pigeon — render, parse, validate, and lint PigeonDocuments over HTTP. Mount the handler in Express/Fastify/Connect, run a stand-alone server, or launch the bundled lit-pigeon-rest CLI.

Install

npm install @lit-pigeon/rest

Usage

Stand-alone Node server:

import { createServer } from '@lit-pigeon/rest';

const { server, ready } = createServer({ port: 3000 });
const { host, port } = await ready;
console.log(`listening on http://${host}:${port}`);

Or mount into an existing framework via a (req, res) handler:

import { createHandler } from '@lit-pigeon/rest';

const handler = createHandler({ bearerToken: process.env.API_TOKEN });
// e.g. Node http.createServer(handler), or wire into Express/Connect.
CLI
npx lit-pigeon-rest        # honours PORT / HOST / LIT_PIGEON_REST_TOKEN
Endpoints

GET /health, plus POST /render, /render/mjml, /validate, /parse, /lint, and /lint/async. Each POST takes { document, options? } JSON. A lower-level pure router, handleRequest(jsonRequest, ctx), is also exported for custom transports.

Rendering, parsing, and linting are powered by @lit-pigeon/ssr and @lit-pigeon/lint.

Part of Lit Pigeon — open-source drag-and-drop email editor.

License

MIT

Keywords