Packages · @purista/hono-http-server

@purista/hono-http-server

Package for using a Hono as webserver.

Signature

@purista/hono-http-server.tstypescript
@purista/hono-http-server

Examples

example-1.tstypescript
import { serve } from '@hono/node-server'
import { DefaultEventBridge } from '@purista/core'
import { honoV1Service } from '@purista/hono-http-server'

// create and init our eventbridge
const eventBridge = new DefaultEventBridge()
await eventBridge.start()

// add your service
const pingService = await pingV1Service.getInstance(eventBridge)
await pingService.start()

const honoService = await honoV1Service.getInstance(eventBridge, {
  serviceConfig: {
    enableDynamicRoutes: false,
  }
})
honoService.registerService(pingService)
await honoService.start()

const _serverInstance = serve({
  fetch: honoService.app.fetch,
  port: 3000,
})

Classes

1 entry

HonoServiceClass

Classes

Source
HonoServiceClass.tstypescript
class HonoServiceClass<Bindings, Variables>

PURISTA service that exposes command, stream and async queue-backed endpoints through Hono.

Type Aliases

14 entries

AnyService

Types

Source
AnyService.tstypescript
type AnyService = Service<any>

Service instance accepted by the Hono HTTP projection registry.

BindingsBase

Types

Source
BindingsBase.tstypescript
type BindingsBase = EmptyObject

Base Hono bindings type used by the Hono HTTP service.

Config

Types

Source
Config.tstypescript
type Config = void

OpenAPI generation settings needed by HTTP helper functions.

EndpointProtectMiddleware

Types

Source
EndpointProtectMiddleware.tstypescript
type EndpointProtectMiddleware = (this: T, c: Context<{ Bindings: Bindings; Variables: Variables }>, next: Next) => Promise<void | Response>

Middleware type for protected generated Hono endpoints.

HealthFunction

Types

Source
HealthFunction.tstypescript
type HealthFunction = (this: T) => Promise<void>

Health callback for the Hono HTTP service.

HonoServiceV1Config

Types

Source
HonoServiceV1Config.tstypescript
type HonoServiceV1Config = z.output<typeof honoServiceV1ConfigSchema>

Fully parsed Hono service config with defaults applied.

HonoServiceV1ConfigPartial

Types

Source
HonoServiceV1ConfigPartial.tstypescript
type HonoServiceV1ConfigPartial = z.input<typeof honoServiceV1ConfigSchema>

Partial Hono service config accepted by `honoV1Service.getInstance`.

HonoV1ServiceCommandsToRestApiInputPayload

Types

Source
HonoV1ServiceCommandsToRestApiInputPayload.tstypescript
type HonoV1ServiceCommandsToRestApiInputPayload = z.output<typeof honoV1ServiceCommandsToRestApiInputPayloadSchema>

Payload shape for service metadata messages that trigger dynamic HTTP endpoint registration.

ProblemDetails

Types

Source
ProblemDetails.tstypescript
type ProblemDetails = void

RFC 9457-style problem details response returned by generated Hono endpoints.

ProblemTypeConfig

Types

Source
ProblemTypeConfig.tstypescript
type ProblemTypeConfig = void

Controls generated problem type URIs.

ProtocolSseEvent

Types

Source
ProtocolSseEvent.tstypescript
type ProtocolSseEvent = void

Protocol-native SSE event passed through by stream handlers.

PuristaOpenApiOperationOwner

Types

Source
PuristaOpenApiOperationOwner.tstypescript
type PuristaOpenApiOperationOwner = void

PURISTA owner metadata attached to generated OpenAPI operations.

StreamTransportFramePayload

Types

Source
StreamTransportFramePayload.tstypescript
type StreamTransportFramePayload = void

Normalized payload shape used by HTTP stream transport frames.

VariablesBase

Types

Source
VariablesBase.tstypescript
type VariablesBase = void

Hono variables read by generated PURISTA HTTP handlers.

Variables

17 entries

DEFAULT_API_MOUNT_PATH

Variables

Source
DEFAULT_API_MOUNT_PATH.tstypescript
const DEFAULT_API_MOUNT_PATH: "/api"

Default base path for generated HTTP command and stream endpoints.

DEFAULT_MAX_REQUEST_BODY_BYTES

Variables

Source
DEFAULT_MAX_REQUEST_BODY_BYTES.tstypescript
const DEFAULT_MAX_REQUEST_BODY_BYTES: number

Default maximum size, in bytes, accepted for an HTTP request body.

ExternalDocumentationObjectSchema

Variables

Source
ExternalDocumentationObjectSchema.tstypescript
const ExternalDocumentationObjectSchema: ZodObject<{ description: ZodOptional<ZodString>; url: ZodString }, $strip>

Schema for OpenAPI external documentation objects.

getQueryDefintion

Variables

Source
getQueryDefintion.tstypescript
const getQueryDefintion: (queryDefinition: QueryParameter<Record<string, unknown>>[] | undefined, parameterschema?: SchemaObject) => ParameterObject[]

Backward-compatible alias for the misspelled query definition helper.

honoServiceInfo

Variables

Source
honoServiceInfo.tstypescript
const honoServiceInfo: ServiceInfoType

Service metadata for version 1 of the built-in Hono HTTP service.

honoServiceV1ConfigSchema

Variables

Source
honoServiceV1ConfigSchema.tstypescript
const honoServiceV1ConfigSchema: ZodObject<{ apiMountPath: ZodDefault<ZodOptional<ZodString>>; autoRegisterServicesFromConfig: ZodDefault<ZodOptional<ZodBoolean>>; enableDynamicRoutes: ZodDefault<ZodBoolean>; enableHealth: ZodDefault<ZodOptional<ZodBoolean>>; healthFunction: ZodOptional<ZodAny>; healthPath: ZodDefault<ZodOptional<ZodString>>; ... }, $strip>

Runtime configuration schema for the Hono HTTP service.

honoV1Service

Variables

Source
honoV1Service.tstypescript
const honoV1Service: ServiceBuilder<SetNewTypeValue<SetNewTypeValues<ServiceBuilderTypes, { ConfigInputType: { apiMountPath: unknown; autoRegisterServicesFromConfig: unknown; enableDynamicRoutes: unknown; enableHealth: unknown; healthFunction: unknown; healthPath: unknown; ... }; ConfigType: { apiMountPath: unknown; autoRegisterServicesFromConfig: unknown; enableDynamicRoutes: unknown; enableHealth: unknown; healthFunction: unknown; healthPath: unknown; ... }; ServiceClassType: Service<unknown> }>, "ServiceClassType", HonoServiceClass<EmptyObject, VariablesBase>>>

Built-in Hono HTTP service definition.

honoV1ServiceBuilder

Variables

Source
honoV1ServiceBuilder.tstypescript
const honoV1ServiceBuilder: ServiceBuilder<SetNewTypeValue<SetNewTypeValues<ServiceBuilderTypes, { ConfigInputType: { apiMountPath: unknown; autoRegisterServicesFromConfig: unknown; enableDynamicRoutes: unknown; enableHealth: unknown; healthFunction: unknown; healthPath: unknown; ... }; ConfigType: { apiMountPath: unknown; autoRegisterServicesFromConfig: unknown; enableDynamicRoutes: unknown; enableHealth: unknown; healthFunction: unknown; healthPath: unknown; ... }; ServiceClassType: Service<unknown> }>, "ServiceClassType", HonoServiceClass<EmptyObject, VariablesBase>>>

Builder for the built-in Hono HTTP service.

honoV1ServiceCommandsToRestApiInputPayloadSchema

Variables

Source
honoV1ServiceCommandsToRestApiInputPayloadSchema.tstypescript
const honoV1ServiceCommandsToRestApiInputPayloadSchema: ZodRecord<ZodString, ZodUnknown>

Schema for dynamic endpoint metadata received from service definition info messages.

InfoObjectSchema

Variables

Source
InfoObjectSchema.tstypescript
const InfoObjectSchema: ZodObject<{ contact: ZodOptional<ZodObject<{ email: unknown; name: unknown; url: unknown }, $strip>>; description: ZodDefault<ZodString>; license: ZodOptional<ZodObject<{ name: unknown; url: unknown }, $strip>>; termsOfService: ZodOptional<ZodString>; title: ZodDefault<ZodString>; version: ZodDefault<ZodString> }, $strip>

Schema for the OpenAPI info object.

OPENAPI_DEFAULT_INFO

Variables

Source
OPENAPI_DEFAULT_INFO.tstypescript
const OPENAPI_DEFAULT_INFO: { description: string; title: string; version: string }

Default OpenAPI info block used when no application-specific metadata is supplied.

ProblemDetailsObjectSchema

Variables

Source
ProblemDetailsObjectSchema.tstypescript
const ProblemDetailsObjectSchema: ZodObject<{ typeBaseUri: ZodOptional<ZodString> }, $strip>

Schema for RFC 9457 problem details configuration.

puristaVersion

Variables

Source
puristaVersion.tstypescript
const puristaVersion: "3.2.3"

ServerObjectSchema

Variables

Source
ServerObjectSchema.tstypescript
const ServerObjectSchema: ZodObject<{ description: ZodOptional<ZodString>; url: ZodString; variables: ZodOptional<ZodAny> }, $strip>

Schema for OpenAPI server objects.

serviceCommandsToRestApiSubscriptionBuilder

Variables

Source
serviceCommandsToRestApiSubscriptionBuilder.tstypescript
const serviceCommandsToRestApiSubscriptionBuilder: SubscriptionDefinitionBuilder<HonoServiceClass<EmptyObject, VariablesBase>, SubscriptionDefinitionBuilderTypes<ZodRecord<ZodString, ZodUnknown>, any, any, any, any, any, EmptyObject, InvokeList, StreamInvokeList, Record<string, Schema>>>

Subscription builder that dynamically adds HTTP endpoints for newly announced commands.

ServiceEvent

Variables

Source
ServiceEvent.tstypescript
const ServiceEvent: object

Reserved service event map for the Hono HTTP service.

TagObjectSchema

Variables

Source
TagObjectSchema.tstypescript
const TagObjectSchema: ZodObject<{ description: ZodOptional<ZodString>; externalDocs: ZodOptional<ZodObject<{ description: unknown; url: unknown }, $strip>>; name: ZodString }, $strip>

Schema for OpenAPI tag objects.

Functions

16 entries

addPathToOpenApi

Functions

Source
addPathToOpenApi.tstypescript
addPathToOpenApi(openApiBuilder: OpenApiBuilder, metadata: { expose: { contentEncodingRequest: string; contentEncodingResponse: string; contentTypeRequest: string; contentTypeResponse: string; deprecated: boolean; inputPayload: SchemaObject; ... } & { http: { method: unknown | unknown | unknown | unknown | unknown; mode: unknown | unknown; openApi: { additionalStatusCodes: unknown; description: unknown; isSecure: unknown; operationId: unknown; query: unknown; summary: unknown; ... }; path: string; stream: { documentationUrl: unknown; mode: unknown; protocol: unknown } } } }, path: string, config: Config, owner?: PuristaOpenApiOperationOwner): void

collectAggregateStreamResult

Functions

Source
collectAggregateStreamResult.tstypescript
collectAggregateStreamResult(handle: StreamHandle): Promise<{ payload: { data: unknown; isHandledError: unknown; message: unknown; status: unknown; traceId: unknown } & { message: unknown; status: unknown }; status: "error"; statusCode: StatusCode | ContentfulStatusCode } | { payload: object | null; status: "success"; statusCode: ContentfulStatusCode }>

encodeProtocolSseEvent

Functions

Source
encodeProtocolSseEvent.tstypescript
encodeProtocolSseEvent(encoder: TextEncoder, event: ProtocolSseEvent): Uint8Array

getErrorName

Functions

Source
getErrorName.tstypescript
getErrorName(code: StatusCode): string

getErrorResponseSchema

Functions

Source
getErrorResponseSchema.tstypescript
getErrorResponseSchema(code: StatusCode, message: string, schema?: SchemaObject, problemTypeConfig?: ProblemTypeConfig): SchemaObject

getParameterDefinition

Functions

Source
getParameterDefinition.tstypescript
getParameterDefinition(path: string, parameterschema?: SchemaObject): ParameterObject[]

getProblemDetailsSchema

Functions

Source
getProblemDetailsSchema.tstypescript
getProblemDetailsSchema(code: StatusCode, message: string, schema?: SchemaObject, problemTypeConfig?: ProblemTypeConfig): SchemaObject

getProblemTypeUri

Functions

Source
getProblemTypeUri.tstypescript
getProblemTypeUri(status: number, data?: unknown, config?: ProblemTypeConfig): string

getQueryDefinition

Functions

Source
getQueryDefinition.tstypescript
getQueryDefinition(queryDefinition: QueryParameter<Record<string, unknown>>[] | undefined, parameterschema?: SchemaObject): ParameterObject[]

isProtocolSseEvent

Functions

Source
isProtocolSseEvent.tstypescript
isProtocolSseEvent(value: unknown): value

isStreamErrorPayload

Functions

Source
isStreamErrorPayload.tstypescript
isStreamErrorPayload(payload: StreamTransportFramePayload): payload

isTransportControlFrame

Functions

Source
isTransportControlFrame.tstypescript
isTransportControlFrame(frameType: unknown): boolean

negotiateProblemRepresentation

Functions

Source
negotiateProblemRepresentation.tstypescript
negotiateProblemRepresentation(acceptHeader?: string): "json" | "markdown"

renderProblemDetailsMarkdown

Functions

Source
renderProblemDetailsMarkdown.tstypescript
renderProblemDetailsMarkdown(problem: ProblemDetails): string

resolveHttpStreamingMode

Functions

Source
resolveHttpStreamingMode.tstypescript
resolveHttpStreamingMode(input: { explicitMode: "stream" | "aggregate"; isDeclaredStreamDefinition: boolean; responseContentType: string }): "stream" | "aggregate"

toProblemDetails

Functions

Source
toProblemDetails.tstypescript
toProblemDetails(error: unknown, input: { instance: string; problemTypeConfig: ProblemTypeConfig; safeInternalDetails: boolean; statusCode: number; traceId: string }): ProblemDetails