Skip to main content

Built and signed on GitHub Actions

Federation types, validators and cryptography for Versia server implementations.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
52%
Published
2 days ago (0.1.1)
class RequestParserHandler

A class to parse the body of a request and call the appropriate callback.

Examples

const body = { ... }; const validator = new EntityValidator(); const parser = new RequestParserHandler(body, validator);

await parser.parseBody({ note: (note) => { // If the object is a Note, this will be called console.log(note); }, follow: (follow) => { // If the object is a Follow, this will be called console.log(follow); }, ... });

Constructors

new
RequestParserHandler(
body: Record<string, >,
validator: EntityValidator,
)

Methods

parseBody<ReturnType = void>(callbacks: Partial<ParserCallbacks<ReturnType>>): Promise<ReturnType>

Parse the body of the request and call the appropriate callback. To change the return type, edit the ReturnType generic parameter. const parser = new RequestParserHandler(body, validator);

Add Package

deno add jsr:@versia/federation

Import symbol

import { RequestParserHandler } from "@versia/federation";

---- OR ----

Import directly with a jsr specifier

import { RequestParserHandler } from "jsr:@versia/federation";

Add Package

npx jsr add @versia/federation

Import symbol

import { RequestParserHandler } from "@versia/federation";

Add Package

yarn dlx jsr add @versia/federation

Import symbol

import { RequestParserHandler } from "@versia/federation";

Add Package

pnpm dlx jsr add @versia/federation

Import symbol

import { RequestParserHandler } from "@versia/federation";

Add Package

bunx jsr add @versia/federation

Import symbol

import { RequestParserHandler } from "@versia/federation";