Skip to main content
Home
This release is 12 versions behind 0.0.16 — the latest version of @asgard/heimdall. Jump to latest

Built and signed on GitHub Actions

A modern TypeScript framework for building type-safe API endpoints with a focus on developer experience and cross-platform compatibility

This package works with Node.js, DenoIt is unknown whether this package works with Cloudflare Workers, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
64%
Published
a week ago (0.0.4)
class HeimdallEndpoint

Constructors

new
HeimdallEndpoint(options: HeimdallEndpointOptions<TPath, TBody, TResponse, TSearch, TParams, TServices>)

Type Parameters

TPath extends HeimdallPath
TBody extends StandardSchemaV1 | undefined = undefined
TResponse extends StandardSchemaV1 | undefined = undefined
TSearch extends StandardSchemaV1 | undefined = undefined
TParams extends StandardSchemaV1 | undefined = undefined
TServices extends HermodServiceConstructor[] = []

Properties

The standard schema for the request body.

The description of the endpoint. @example Get all users

execute: HeimdallEndpointHandler<TBody, TResponse, TSearch, TParams, TServices>
private
handler: HeimdallEndpointHandler<TBody, TResponse, TSearch, TParams, TServices>

The execute function for the endpoint. responsible for handling the request.

readonly
isAuthorized: HeimdallEndpointAuthorizer<TBody, TSearch, TParams, TServices>
readonly
method: HttpMethod

The HTTP method for the endpoint. @example GET, POST, PUT, DELETE

private
readonly
noopAuthorizer: HeimdallEndpointAuthorizer<TBody, TSearch, TParams, TServices>

The standard schema for the request params.

readonly
path: HeimdallPath

the endpoint path. @example /api/v1/users

The standard schema for the response body.

readonly
route: HeimdallRoute<TPath, HttpMethod>

The route for the endpoint.

The standard schema for the request search query.

The services used by the endpoint.

readonly
tags: string[]

The tags for the endpoint used for documentation.

Methods

body(data: unknown): Promise<HeimdallEndpointValidationOutput<TBody>>

Parses and validates request body.

params(data: unknown): Promise<HeimdallEndpointValidationOutput<TParams>>

Parses and validates request params.

private
parse<T extends StandardSchemaV1 | undefined = undefined>(
schema: T,
data: unknown,
): Promise<HeimdallEndpointValidationOutput<T>>
response<T extends HeimdallEndpointResponse<TResponse>>(data: T): Promise<HeimdallEndpointResponse<HeimdallEndpointValidationOutput<TResponse>>>

Parses and validates request response.

run(input: HeimdallEndpointHandlerInput<TBody, TSearch, TParams, TServices>): Promise<HeimdallEndpointValidationOutput<TResponse>>
search(data: unknown): Promise<HeimdallEndpointValidationOutput<TSearch>>

Parses and validates request search query.

Static Methods

isErrorResponse(response: unknown): response is HeimdallEndpointErrorResponse

Checks if the given response is a HeimdallEndpointErrorResponse.

isResponse(response: unknown): response is HeimdallEndpointResponse

Checks if the given response is a HeimdallEndpointResponse.

isSuccessResponse(response: unknown): response is HeimdallEndpointSuccessResponse

Checks if the given response is a HeimdallEndpointSuccessResponse.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@asgard/heimdall

Import symbol

import { HeimdallEndpoint } from "@asgard/heimdall";
or

Import directly with a jsr specifier

import { HeimdallEndpoint } from "jsr:@asgard/heimdall";

Add Package

pnpm i jsr:@asgard/heimdall
or (using pnpm 10.8 or older)
pnpm dlx jsr add @asgard/heimdall

Import symbol

import { HeimdallEndpoint } from "@asgard/heimdall";

Add Package

yarn add jsr:@asgard/heimdall
or (using Yarn 4.8 or older)
yarn dlx jsr add @asgard/heimdall

Import symbol

import { HeimdallEndpoint } from "@asgard/heimdall";

Add Package

npx jsr add @asgard/heimdall

Import symbol

import { HeimdallEndpoint } from "@asgard/heimdall";

Add Package

bunx jsr add @asgard/heimdall

Import symbol

import { HeimdallEndpoint } from "@asgard/heimdall";