Packages · @purista/hono-http-server

@purista/hono-http-server

Package for using a Hono as webserver.

Signature

@purista/hono-http-server.ts typescript
@purista/hono-http-server

Examples

example-1.ts typescript
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.ts typescript
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.ts typescript
type AnyService = Service<any>

Service instance accepted by the Hono HTTP projection registry.

BindingsBase

Types

Source
BindingsBase.ts typescript
type BindingsBase = EmptyObject

Base Hono bindings type used by the Hono HTTP service.

Config

Types

Source
Config.ts typescript
type Config = void

OpenAPI generation settings needed by HTTP helper functions.

EndpointProtectMiddleware

Types

Source
EndpointProtectMiddleware.ts typescript
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.ts typescript
type HealthFunction = (this: T) => Promise<void>

Health callback for the Hono HTTP service.

HonoServiceV1Config

Types

Source
HonoServiceV1Config.ts typescript
type HonoServiceV1Config = z.output<typeof honoServiceV1ConfigSchema>

Fully parsed Hono service config with defaults applied.

HonoServiceV1ConfigPartial

Types

Source
HonoServiceV1ConfigPartial.ts typescript
type HonoServiceV1ConfigPartial = z.input<typeof honoServiceV1ConfigSchema>

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

HonoV1ServiceCommandsToRestApiInputPayload

Types

Source
HonoV1ServiceCommandsToRestApiInputPayload.ts typescript
type HonoV1ServiceCommandsToRestApiInputPayload = z.output<typeof honoV1ServiceCommandsToRestApiInputPayloadSchema>

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

ProblemDetails

Types

Source
ProblemDetails.ts typescript
type ProblemDetails = void

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

ProblemTypeConfig

Types

Source
ProblemTypeConfig.ts typescript
type ProblemTypeConfig = void

Controls generated problem type URIs.

ProtocolSseEvent

Types

Source
ProtocolSseEvent.ts typescript
type ProtocolSseEvent = void

Protocol-native SSE event passed through by stream handlers.

PuristaOpenApiOperationOwner

Types

Source
PuristaOpenApiOperationOwner.ts typescript
type PuristaOpenApiOperationOwner = void

PURISTA owner metadata attached to generated OpenAPI operations.

StreamTransportFramePayload

Types

Source
StreamTransportFramePayload.ts typescript
type StreamTransportFramePayload = void

Normalized payload shape used by HTTP stream transport frames.

VariablesBase

Types

Source
VariablesBase.ts typescript
type VariablesBase = void

Hono variables read by generated PURISTA HTTP handlers.

Variables

16 entries

DEFAULT_API_MOUNT_PATH

Variables

Source
DEFAULT_API_MOUNT_PATH.ts typescript
const DEFAULT_API_MOUNT_PATH: "/api"

Default base path for generated HTTP command and stream endpoints.

ExternalDocumentationObjectSchema

Variables

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

Schema for OpenAPI external documentation objects.

getQueryDefintion

Variables

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

Backward-compatible alias for the misspelled query definition helper.

honoServiceInfo

Variables

Source
honoServiceInfo.ts typescript
const honoServiceInfo: ServiceInfoType

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

honoServiceV1ConfigSchema

Variables

Source
honoServiceV1ConfigSchema.ts typescript
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.ts typescript
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.ts typescript
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.ts typescript
const honoV1ServiceCommandsToRestApiInputPayloadSchema: ZodRecord<ZodString, ZodUnknown>

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

InfoObjectSchema

Variables

Source
InfoObjectSchema.ts typescript
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.ts typescript
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.ts typescript
const ProblemDetailsObjectSchema: ZodObject<{ typeBaseUri: ZodOptional<ZodString> }, $strip>

Schema for RFC 9457 problem details configuration.

puristaVersion

Variables

Source
puristaVersion.ts typescript
const puristaVersion: "3.0.1"

The PURISTA package version embedded in the published runtime build.

ServerObjectSchema

Variables

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

Schema for OpenAPI server objects.

serviceCommandsToRestApiSubscriptionBuilder

Variables

Source
serviceCommandsToRestApiSubscriptionBuilder.ts typescript
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.ts typescript
const ServiceEvent: object

Reserved service event map for the Hono HTTP service.

TagObjectSchema

Variables

Source
TagObjectSchema.ts typescript
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.ts typescript
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.ts typescript
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.ts typescript
encodeProtocolSseEvent(encoder: TextEncoder, event: ProtocolSseEvent): Uint8Array

getErrorName

Functions

Source
getErrorName.ts typescript
getErrorName(code: StatusCode): string

getErrorResponseSchema

Functions

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

getParameterDefinition

Functions

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

getProblemDetailsSchema

Functions

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

getProblemTypeUri

Functions

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

getQueryDefinition

Functions

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

isProtocolSseEvent

Functions

Source
isProtocolSseEvent.ts typescript
isProtocolSseEvent(value: unknown): value

isStreamErrorPayload

Functions

Source
isStreamErrorPayload.ts typescript
isStreamErrorPayload(payload: StreamTransportFramePayload): payload

isTransportControlFrame

Functions

Source
isTransportControlFrame.ts typescript
isTransportControlFrame(frameType: unknown): boolean

negotiateProblemRepresentation

Functions

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

renderProblemDetailsMarkdown

Functions

Source
renderProblemDetailsMarkdown.ts typescript
renderProblemDetailsMarkdown(problem: ProblemDetails): string

resolveHttpStreamingMode

Functions

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

toProblemDetails

Functions

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