PURISTA API / Modules / @purista/hono-http-server
Module: @purista/hono-http-server
Package for using a Hono as webserver.
Minimal example:
Example
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
- DEFAULT_API_MOUNT_PATH
- ExternalDocumentationObjectSchema
- InfoObjectSchema
- OPENAPI_DEFAULT_INFO
- ServerObjectSchema
- TagObjectSchema
- honoServiceV1ConfigSchema
- honoV1Service
- puristaVersion
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
Name | Type |
---|---|
T | extends Service |
Bindings | extends BindingsBase = BindingsBase |
Variables | extends VariablesBase = VariablesBase |
Type declaration
▸ (this
, c
, next
): Promise
<void
| Response
>
Parameters
Name | Type |
---|---|
this | T |
c | Context <{ Bindings : Bindings ; Variables : Variables }> |
next | Next |
Returns
Promise
<void
| Response
>
Defined in
packages/hono-http-server/src/types/EndpointProtectMiddleware.ts:7
HealthFunction
Ƭ HealthFunction<T
>: (this
: T
) => Promise
<void
>
Type parameters
Name | Type |
---|---|
T | extends Service |
Type declaration
▸ (this
): Promise
<void
>
Parameters
Name | Type |
---|---|
this | T |
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
Name | Type | Description |
---|---|---|
additionalParameter? | Record <string , unknown > | Additional parameter passed to the commands |
instanceId? | string | The instance ID |
principalId? | string | The principal ID |
tenantId? | string | The tenant ID |
traceId? | string | The 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
Name | Type |
---|---|
description | string |
title | string |
version | string |
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
Name | Type |
---|---|
openApiBuilder | OpenApiBuilder |
metadata | Object |
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 } } |
path | string |
config | Config |
Returns
void
Defined in
packages/hono-http-server/src/helper/addPathToOpenApi.ts:14
getErrorName
▸ getErrorName(code
): string
Parameters
Name | Type |
---|---|
code | StatusCode |
Returns
string
Defined in
packages/hono-http-server/src/helper/getErrorName.ts:3
getErrorResponseSchema
▸ getErrorResponseSchema(code
, message
, schema?
): SchemaObject
Parameters
Name | Type |
---|---|
code | StatusCode |
message | string |
schema? | SchemaObject |
Returns
SchemaObject
Defined in
packages/hono-http-server/src/helper/getErrorResponseSchema.ts:55
getParameterDefinition
▸ getParameterDefinition(path
, parameterschema?
): ParameterObject
[]
Parameters
Name | Type |
---|---|
path | string |
parameterschema? | SchemaObject |
Returns
ParameterObject
[]
Defined in
packages/hono-http-server/src/helper/getParameterDefinition.ts:6
getQueryDefintion
▸ getQueryDefintion(queryDefinition
, parameterschema?
): ParameterObject
[]
Parameters
Name | Type |
---|---|
queryDefinition | undefined | QueryParameter <Record <string , unknown >>[] |
parameterschema? | SchemaObject |
Returns
ParameterObject
[]