Skip to content

PURISTA API / Modules / @purista/hono-http-server

Module: @purista/hono-http-server

Package for using a Hono as webserver.

Minimal example:

Example

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: {
    services: [pingService]
  }
})
await honoService.start()

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

Table of contents

Enumerations

Type Aliases

Variables

Functions

Type Aliases

BindingsBase

Ƭ BindingsBase: Object

Defined in

packages/hono-http-server/src/types/BindingsBase.ts:1


EndpointProtectMiddleware

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

Type parameters

NameType
Textends Service
Bindingsextends BindingsBase = BindingsBase
Variablesextends VariablesBase = VariablesBase

Type declaration

▸ (this, c, next): Promise<void | Response>

Parameters
NameType
thisT
cContext<{ Bindings: Bindings ; Variables: Variables }>
nextNext
Returns

Promise<void | Response>

Defined in

packages/hono-http-server/src/types/EndpointProtectMiddleware.ts:7


HealthFunction

Ƭ HealthFunction<T>: (this: T) => Promise<void>

Type parameters

NameType
Textends Service

Type declaration

▸ (this): Promise<void>

Parameters
NameType
thisT
Returns

Promise<void>

Defined in

packages/hono-http-server/src/types/HealthFunction.ts:3


HonoServiceV1Config

Ƭ HonoServiceV1Config: z.output<typeof honoServiceV1ConfigSchema>

Defined in

packages/hono-http-server/src/service/hono/v1/honoServiceConfig.ts:75


VariablesBase

Ƭ VariablesBase: Object

Type declaration

NameTypeDescription
additionalParameter?Record<string, unknown>Additional parameter passed to the commands
instanceId?stringThe instance ID
principalId?stringThe principal ID
tenantId?stringThe tenant ID
traceId?stringThe custom trace ID

Defined in

packages/hono-http-server/src/types/VariablesBase.ts:1

Variables

DEFAULT_API_MOUNT_PATH

Const DEFAULT_API_MOUNT_PATH: "/api"

Defined in

packages/hono-http-server/src/service/hono/v1/honoServiceConfig.ts:6


ExternalDocumentationObjectSchema

Const ExternalDocumentationObjectSchema: ZodObject<{ description: ZodOptional<ZodString> ; url: ZodString }, "strip", ZodTypeAny, { description?: string ; url: string }, { description?: string ; url: string }>

Defined in

packages/hono-http-server/src/service/hono/v1/honoServiceConfig.ts:14


InfoObjectSchema

Const InfoObjectSchema: ZodObject<{ contact: ZodOptional<ZodObject<{ email: ZodOptional<ZodString> ; name: ZodOptional<ZodString> ; url: ZodOptional<ZodString> }, "strip", ZodTypeAny, { email?: string ; name?: string ; url?: string }, { email?: string ; name?: string ; url?: string }>> ; description: ZodDefault<ZodString> ; license: ZodOptional<ZodObject<{ name: ZodString ; url: ZodOptional<ZodString> }, "strip", ZodTypeAny, { name: string ; url?: string }, { name: string ; url?: string }>> ; termsOfService: ZodOptional<ZodString> ; title: ZodDefault<ZodString> ; version: ZodDefault<ZodString> }, "strip", ZodTypeAny, { contact?: { email?: string ; name?: string ; url?: string } ; description: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title: string ; version: string }, { contact?: { email?: string ; name?: string ; url?: string } ; description?: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title?: string ; version?: string }>

Defined in

packages/hono-http-server/src/service/hono/v1/honoServiceConfig.ts:25


OPENAPI_DEFAULT_INFO

Const OPENAPI_DEFAULT_INFO: Object

Type declaration

NameType
descriptionstring
titlestring
versionstring

Defined in

packages/hono-http-server/src/service/hono/v1/honoServiceConfig.ts:8


ServerObjectSchema

Const ServerObjectSchema: ZodObject<{ description: ZodOptional<ZodString> ; url: ZodString ; variables: ZodOptional<ZodAny> }, "strip", ZodTypeAny, { description?: string ; url: string ; variables?: any }, { description?: string ; url: string ; variables?: any }>

Defined in

packages/hono-http-server/src/service/hono/v1/honoServiceConfig.ts:45


TagObjectSchema

Const TagObjectSchema: ZodObject<{ description: ZodOptional<ZodString> ; externalDocs: ZodOptional<ZodObject<{ description: ZodOptional<ZodString> ; url: ZodString }, "strip", ZodTypeAny, { description?: string ; url: string }, { description?: string ; url: string }>> ; name: ZodString }, "strip", ZodTypeAny, { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }, { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }>

Defined in

packages/hono-http-server/src/service/hono/v1/honoServiceConfig.ts:19


honoServiceV1ConfigSchema

Const honoServiceV1ConfigSchema: ZodObject<{ apiMountPath: ZodDefault<ZodOptional<ZodString>> ; enableDynamicRoutes: ZodDefault<ZodBoolean> ; enableHealth: ZodDefault<ZodOptional<ZodBoolean>> ; healthFunction: ZodDefault<ZodAny> ; healthPath: ZodDefault<ZodOptional<ZodString>> ; logLevel: ZodOptional<ZodEnum<["info", "error", "warn", "debug", "trace", "fatal"]>> ; openApi: ZodOptional<ZodObject<{ components: ZodOptional<ZodAny> ; enabled: ZodDefault<ZodOptional<ZodBoolean>> ; externalDocs: ZodOptional<ZodObject<{ description: ZodOptional<ZodString> ; url: ZodString }, "strip", ZodTypeAny, { description?: string ; url: string }, { description?: string ; url: string }>> ; info: ZodObject<{ contact: ZodOptional<ZodObject<{ email: ZodOptional<ZodString> ; name: ZodOptional<ZodString> ; url: ZodOptional<ZodString> }, "strip", ZodTypeAny, { email?: string ; name?: string ; url?: string }, { email?: string ; name?: string ; url?: string }>> ; description: ZodDefault<ZodString> ; license: ZodOptional<ZodObject<{ name: ZodString ; url: ZodOptional<ZodString> }, "strip", ZodTypeAny, { name: string ; url?: string }, { name: string ; url?: string }>> ; termsOfService: ZodOptional<ZodString> ; title: ZodDefault<ZodString> ; version: ZodDefault<ZodString> }, "strip", ZodTypeAny, { contact?: { email?: string ; name?: string ; url?: string } ; description: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title: string ; version: string }, { contact?: { email?: string ; name?: string ; url?: string } ; description?: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title?: string ; version?: string }> = InfoObjectSchema; openapi: ZodDefault<ZodString> ; paths: ZodOptional<ZodRecord<ZodString, ZodRecord<ZodString, ZodAny>>> ; security: ZodOptional<ZodArray<ZodAny, "many">> ; servers: ZodOptional<ZodArray<ZodObject<{ description: ZodOptional<ZodString> ; url: ZodString ; variables: ZodOptional<ZodAny> }, "strip", ZodTypeAny, { description?: string ; url: string ; variables?: any }, { description?: string ; url: string ; variables?: any }>, "many">> ; tags: ZodOptional<ZodArray<ZodObject<{ description: ZodOptional<ZodString> ; externalDocs: ZodOptional<ZodObject<{ description: ZodOptional<ZodString> ; url: ZodString }, "strip", ZodTypeAny, { description?: string ; url: string }, { description?: string ; url: string }>> ; name: ZodString }, "strip", ZodTypeAny, { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }, { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }>, "many">> }, "strip", ZodTypeAny, { components?: any ; enabled: boolean ; externalDocs?: { description?: string ; url: string } ; info: { contact?: { email?: string ; name?: string ; url?: string } ; description: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title: string ; version: string } = InfoObjectSchema; openapi: string ; paths?: Record<string, Record<string, any>> ; security?: any[] ; servers?: { description?: string ; url: string ; variables?: any }[] ; tags?: { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }[] }, { components?: any ; enabled?: boolean ; externalDocs?: { description?: string ; url: string } ; info: { contact?: { email?: string ; name?: string ; url?: string } ; description?: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title?: string ; version?: string } = InfoObjectSchema; openapi?: string ; paths?: Record<string, Record<string, any>> ; security?: any[] ; servers?: { description?: string ; url: string ; variables?: any }[] ; tags?: { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }[] }>> ; protectHandler: ZodDefault<ZodAny> ; services: ZodDefault<ZodOptional<ZodArray<ZodType<Service<unknown>, ZodTypeDef, Service<unknown>>, "many">>> ; traceHeaderField: ZodDefault<ZodString> }, "strip", ZodTypeAny, { apiMountPath: string ; enableDynamicRoutes: boolean ; enableHealth: boolean ; healthFunction?: any ; healthPath: string ; logLevel?: "info" | "error" | "warn" | "debug" | "trace" | "fatal" ; openApi?: { components?: any ; enabled: boolean ; externalDocs?: { description?: string ; url: string } ; info: { contact?: { email?: string ; name?: string ; url?: string } ; description: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title: string ; version: string } = InfoObjectSchema; openapi: string ; paths?: Record<string, Record<string, any>> ; security?: any[] ; servers?: { description?: string ; url: string ; variables?: any }[] ; tags?: { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }[] } ; protectHandler?: any ; services: Service<unknown>[] ; traceHeaderField: string }, { apiMountPath?: string ; enableDynamicRoutes?: boolean ; enableHealth?: boolean ; healthFunction?: any ; healthPath?: string ; logLevel?: "info" | "error" | "warn" | "debug" | "trace" | "fatal" ; openApi?: { components?: any ; enabled?: boolean ; externalDocs?: { description?: string ; url: string } ; info: { contact?: { email?: string ; name?: string ; url?: string } ; description?: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title?: string ; version?: string } = InfoObjectSchema; openapi?: string ; paths?: Record<string, Record<string, any>> ; security?: any[] ; servers?: { description?: string ; url: string ; variables?: any }[] ; tags?: { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }[] } ; protectHandler?: any ; services?: Service<unknown>[] ; traceHeaderField?: string }>

Defined in

packages/hono-http-server/src/service/hono/v1/honoServiceConfig.ts:50


honoV1Service

Const honoV1Service: ServiceBuilder<{ apiMountPath: string ; enableDynamicRoutes: boolean ; enableHealth: boolean ; healthFunction?: any ; healthPath: string ; logLevel?: "info" | "error" | "warn" | "debug" | "trace" | "fatal" ; openApi?: { components?: any ; enabled: boolean ; externalDocs?: { description?: string ; url: string } ; info: { contact?: { email?: string ; name?: string ; url?: string } ; description: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title: string ; version: string } = InfoObjectSchema; openapi: string ; paths?: Record<string, Record<string, any>> ; security?: any[] ; servers?: { description?: string ; url: string ; variables?: any }[] ; tags?: { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }[] } ; protectHandler?: any ; services: Service<unknown>[] ; traceHeaderField: string }, { apiMountPath?: string ; enableDynamicRoutes?: boolean ; enableHealth?: boolean ; healthFunction?: any ; healthPath?: string ; logLevel?: "info" | "error" | "warn" | "debug" | "trace" | "fatal" ; openApi?: { components?: any ; enabled?: boolean ; externalDocs?: { description?: string ; url: string } ; info: { contact?: { email?: string ; name?: string ; url?: string } ; description?: string ; license?: { name: string ; url?: string } ; termsOfService?: string ; title?: string ; version?: string } = InfoObjectSchema; openapi?: string ; paths?: Record<string, Record<string, any>> ; security?: any[] ; servers?: { description?: string ; url: string ; variables?: any }[] ; tags?: { description?: string ; externalDocs?: { description?: string ; url: string } ; name: string }[] } ; protectHandler?: any ; services?: Service<unknown>[] ; traceHeaderField?: string }, HonoServiceClass<BindingsBase, VariablesBase>>

Defined in

packages/hono-http-server/src/service/hono/v1/honoV1Service.ts:16


puristaVersion

Const puristaVersion: "1.11.0"

Defined in

packages/hono-http-server/src/version.ts:1

Functions

addPathToOpenApi

addPathToOpenApi(openApiBuilder, metadata, path, config): void

Parameters

NameType
openApiBuilderOpenApiBuilder
metadataObject
metadata.expose{ contentEncodingRequest?: string ; contentEncodingResponse?: string ; contentTypeRequest?: string ; contentTypeResponse?: string ; deprecated?: boolean ; inputPayload?: SchemaObject ; outputPayload?: SchemaObject ; parameter?: SchemaObject } & { http: { method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE" ; openApi?: { additionalStatusCodes?: StatusCode[] ; description: string ; isSecure: boolean ; operationId?: string ; query?: QueryParameter<{}>[] ; summary: string ; tags?: string[] } ; path: string } }
pathstring
configConfig

Returns

void

Defined in

packages/hono-http-server/src/helper/addPathToOpenApi.ts:14


getErrorName

getErrorName(code): string

Parameters

NameType
codeStatusCode

Returns

string

Defined in

packages/hono-http-server/src/helper/getErrorName.ts:3


getErrorResponseSchema

getErrorResponseSchema(code, message, schema?): SchemaObject

Parameters

NameType
codeStatusCode
messagestring
schema?SchemaObject

Returns

SchemaObject

Defined in

packages/hono-http-server/src/helper/getErrorResponseSchema.ts:55


getParameterDefinition

getParameterDefinition(path, parameterschema?): ParameterObject[]

Parameters

NameType
pathstring
parameterschema?SchemaObject

Returns

ParameterObject[]

Defined in

packages/hono-http-server/src/helper/getParameterDefinition.ts:6


getQueryDefintion

getQueryDefintion(queryDefinition, parameterschema?): ParameterObject[]

Parameters

NameType
queryDefinitionundefined | QueryParameter<Record<string, unknown>>[]
parameterschema?SchemaObject

Returns

ParameterObject[]

Defined in

packages/hono-http-server/src/helper/getQueryDefintion.ts:5