Packages · @purista/hono-http-server
@purista/hono-http-server
Package for using a Hono as webserver.
Signature
@purista/hono-http-serverExamples
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
class HonoServiceClass<Bindings, Variables>PURISTA service that exposes command, stream and async queue-backed endpoints through Hono.
Type Aliases
14 entries
AnyService
Types
type AnyService = Service<any>Service instance accepted by the Hono HTTP projection registry.
BindingsBase
Types
type BindingsBase = EmptyObjectBase Hono bindings type used by the Hono HTTP service.
Config
Types
type Config = voidOpenAPI generation settings needed by HTTP helper functions.
EndpointProtectMiddleware
Types
type EndpointProtectMiddleware = (this: T, c: Context<{ Bindings: Bindings; Variables: Variables }>, next: Next) => Promise<void | Response>Middleware type for protected generated Hono endpoints.
HealthFunction
Types
type HealthFunction = (this: T) => Promise<void>Health callback for the Hono HTTP service.
HonoServiceV1Config
Types
type HonoServiceV1Config = z.output<typeof honoServiceV1ConfigSchema>Fully parsed Hono service config with defaults applied.
HonoServiceV1ConfigPartial
Types
type HonoServiceV1ConfigPartial = z.input<typeof honoServiceV1ConfigSchema>Partial Hono service config accepted by `honoV1Service.getInstance`.
HonoV1ServiceCommandsToRestApiInputPayload
Types
type HonoV1ServiceCommandsToRestApiInputPayload = z.output<typeof honoV1ServiceCommandsToRestApiInputPayloadSchema>Payload shape for service metadata messages that trigger dynamic HTTP endpoint registration.
ProblemDetails
Types
type ProblemDetails = voidRFC 9457-style problem details response returned by generated Hono endpoints.
ProblemTypeConfig
Types
type ProblemTypeConfig = voidControls generated problem type URIs.
ProtocolSseEvent
Types
type ProtocolSseEvent = voidProtocol-native SSE event passed through by stream handlers.
PuristaOpenApiOperationOwner
Types
type PuristaOpenApiOperationOwner = voidPURISTA owner metadata attached to generated OpenAPI operations.
StreamTransportFramePayload
Types
type StreamTransportFramePayload = voidNormalized payload shape used by HTTP stream transport frames.
VariablesBase
Types
type VariablesBase = voidHono variables read by generated PURISTA HTTP handlers.
Variables
17 entries
DEFAULT_API_MOUNT_PATH
Variables
const DEFAULT_API_MOUNT_PATH: "/api"Default base path for generated HTTP command and stream endpoints.
DEFAULT_MAX_REQUEST_BODY_BYTES
Variables
const DEFAULT_MAX_REQUEST_BODY_BYTES: numberDefault maximum size, in bytes, accepted for an HTTP request body.
ExternalDocumentationObjectSchema
Variables
const ExternalDocumentationObjectSchema: ZodObject<{ description: ZodOptional<ZodString>; url: ZodString }, $strip>Schema for OpenAPI external documentation objects.
getQueryDefintion
Variables
const getQueryDefintion: (queryDefinition: QueryParameter<Record<string, unknown>>[] | undefined, parameterschema?: SchemaObject) => ParameterObject[]Backward-compatible alias for the misspelled query definition helper.
honoServiceInfo
Variables
const honoServiceInfo: ServiceInfoTypeService metadata for version 1 of the built-in Hono HTTP service.
honoServiceV1ConfigSchema
Variables
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
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
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
const honoV1ServiceCommandsToRestApiInputPayloadSchema: ZodRecord<ZodString, ZodUnknown>Schema for dynamic endpoint metadata received from service definition info messages.
InfoObjectSchema
Variables
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
const OPENAPI_DEFAULT_INFO: { description: string; title: string; version: string }Default OpenAPI info block used when no application-specific metadata is supplied.
ProblemDetailsObjectSchema
Variables
const ProblemDetailsObjectSchema: ZodObject<{ typeBaseUri: ZodOptional<ZodString> }, $strip>Schema for RFC 9457 problem details configuration.
puristaVersion
Variables
const puristaVersion: "3.2.3"ServerObjectSchema
Variables
const ServerObjectSchema: ZodObject<{ description: ZodOptional<ZodString>; url: ZodString; variables: ZodOptional<ZodAny> }, $strip>Schema for OpenAPI server objects.
serviceCommandsToRestApiSubscriptionBuilder
Variables
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
const ServiceEvent: objectReserved service event map for the Hono HTTP service.
TagObjectSchema
Variables
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
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): voidcollectAggregateStreamResult
Functions
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
encodeProtocolSseEvent(encoder: TextEncoder, event: ProtocolSseEvent): Uint8ArraygetErrorName
Functions
getErrorName(code: StatusCode): stringgetErrorResponseSchema
Functions
getErrorResponseSchema(code: StatusCode, message: string, schema?: SchemaObject, problemTypeConfig?: ProblemTypeConfig): SchemaObjectgetParameterDefinition
Functions
getParameterDefinition(path: string, parameterschema?: SchemaObject): ParameterObject[]getProblemDetailsSchema
Functions
getProblemDetailsSchema(code: StatusCode, message: string, schema?: SchemaObject, problemTypeConfig?: ProblemTypeConfig): SchemaObjectgetProblemTypeUri
Functions
getProblemTypeUri(status: number, data?: unknown, config?: ProblemTypeConfig): stringgetQueryDefinition
Functions
getQueryDefinition(queryDefinition: QueryParameter<Record<string, unknown>>[] | undefined, parameterschema?: SchemaObject): ParameterObject[]isProtocolSseEvent
Functions
isProtocolSseEvent(value: unknown): valueisStreamErrorPayload
Functions
isStreamErrorPayload(payload: StreamTransportFramePayload): payloadisTransportControlFrame
Functions
isTransportControlFrame(frameType: unknown): booleannegotiateProblemRepresentation
Functions
negotiateProblemRepresentation(acceptHeader?: string): "json" | "markdown"renderProblemDetailsMarkdown
Functions
renderProblemDetailsMarkdown(problem: ProblemDetails): stringresolveHttpStreamingMode
Functions
resolveHttpStreamingMode(input: { explicitMode: "stream" | "aggregate"; isDeclaredStreamDefinition: boolean; responseContentType: string }): "stream" | "aggregate"toProblemDetails
Functions
toProblemDetails(error: unknown, input: { instance: string; problemTypeConfig: ProblemTypeConfig; safeInternalDetails: boolean; statusCode: number; traceId: string }): ProblemDetails