Skip to content

PURISTA API


PURISTA API / @purista/httpserver / HttpServerClass

Class: HttpServerClass<ConfigType>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:39

A simple http server based on fastify.

Deprecated

Please migrate to @purista/hono-http-server.

Extends

Type Parameters

ConfigType

ConfigType extends HttpServerServiceV1ConfigRaw

Constructors

Constructor

new HttpServerClass<ConfigType>(config): HttpServerClass<ConfigType>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:50

Parameters

config

ServiceConstructorInput<ServiceClassTypes<ConfigType, EmptyObject>>

Returns

HttpServerClass<ConfigType>

Overrides

Service.constructor

Properties

activeStreamSessions

protected activeStreamSessions: Map<string, { cancelled: boolean; cancelReason?: string; onCancel: (reason?) => void[]; }>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:65

Inherited from

Service.activeStreamSessions


beforeResponse

beforeResponse: Trouter<BeforeResponseHook>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:48


commandDefinitionList

commandDefinitionList: CommandDefinitionListResolved<any>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:76

Inherited from

Service.commandDefinitionList


commands

protected commands: Map<string, CommandDefinition<any, any, any, any, any, any, any, any, any, any, EmptyObject, any, any, any, any, any, any>>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:61

Inherited from

Service.commands


config

config: ConfigType

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:79

Inherited from

Service.config


configSchema

protected configSchema: Schema | undefined

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:31

Inherited from

Service.configSchema


configStore

protected configStore: ConfigStore

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:29

Inherited from

Service.configStore


eventBridge

protected eventBridge: EventBridge

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:24

Inherited from

Service.eventBridge


info

readonly info: ServiceInfoType

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:23

Inherited from

Service.info


isStarted

isStarted: boolean

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:81

Inherited from

Service.isStarted


logger

logger: Logger

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:25

Inherited from

Service.logger


queueDefinitionList

protected queueDefinitionList: QueueDefinitionListResolved<any>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:63

Inherited from

Service.queueDefinitionList


queueWorkerDefinitionList

protected queueWorkerDefinitionList: QueueWorkerDefinitionListResolved<any>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:64

Inherited from

Service.queueWorkerDefinitionList


resources

resources: EmptyObject

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:80

Inherited from

Service.resources


routeDefinitions

routeDefinitions: object[] = []

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:44

expose

expose: object & object

Type Declaration
contentEncodingRequest?

optional contentEncodingRequest: string

contentEncodingResponse?

optional contentEncodingResponse: string

contentTypeRequest?

optional contentTypeRequest: string

contentTypeResponse?

optional contentTypeResponse: string

deprecated?

optional deprecated: boolean

inputPayload?

optional inputPayload: SchemaObject

outputPayload?

optional outputPayload: SchemaObject

parameter?

optional parameter: SchemaObject

Type Declaration
http

http: object

http.method

method: "GET" | "DELETE" | "PATCH" | "POST" | "PUT"

http.mode?

optional mode: "sync" | "async"

http.openApi?

optional openApi: object

http.openApi.additionalStatusCodes?

optional additionalStatusCodes: StatusCode[]

http.openApi.description

description: string

http.openApi.isSecure

isSecure: boolean

http.openApi.operationId?

optional operationId: string

http.openApi.query?

optional query: QueryParameter<Record<..., ...>>[]

http.openApi.summary

summary: string

http.openApi.tags?

optional tags: string[]

http.path

path: string


routes

routes: Trouter<Function>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:46


secretStore

protected secretStore: SecretStore

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:28

Inherited from

Service.secretStore


server?

optional server: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:42


spanProcessor

spanProcessor: SpanProcessor | undefined

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:26

Inherited from

Service.spanProcessor


stateStore

protected stateStore: StateStore

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:30

Inherited from

Service.stateStore


streamDefinitionList

streamDefinitionList: StreamDefinitionListResolved<any>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:78

Inherited from

Service.streamDefinitionList


streams

protected streams: Map<string, StreamDefinition<any, any, any, any, any, any, any, EmptyObject, any, any, any, any, any, any>>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:62

Inherited from

Service.streams


subscriptionDefinitionList

subscriptionDefinitionList: SubscriptionDefinitionListResolved<any>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:77

Inherited from

Service.subscriptionDefinitionList


subscriptions

protected subscriptions: Map<string, SubscriptionDefinition<any, any, any, any, any, any, any, any, EmptyObject, any, any, any, any, any, any>>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:60

Inherited from

Service.subscriptions


traceProvider

traceProvider: NodeTracerProvider

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:27

Inherited from

Service.traceProvider

Accessors

name

Get Signature

get name(): string

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:83

Returns

string

Inherited from

Service.name


serviceInfo

Get Signature

get serviceInfo(): ServiceInfoType

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:45

Get service info

Returns

ServiceInfoType

Inherited from

Service.serviceInfo

Methods

addBeforeResponse()

addBeforeResponse(method, pattern, handler): void

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:142

Parameters

method

HTTPMethods

pattern

string

handler

BeforeResponseHook

Returns

void


destroy()

destroy(): Promise<void>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:280

Stop and destroy the current service

Returns

Promise<void>

Overrides

Service.destroy


emit()

emit<K>(eventName, parameter?): void

Defined in: core/dist/commonjs/core/types/GenericEventEmitter.d.ts:16

Type Parameters

K

K extends EventKey<ServiceEvents>

Parameters

eventName

K

parameter?

ServiceEvents[K]

Returns

void

Inherited from

Service.emit


executeCommand()

executeCommand(message): Promise<Readonly<Omit<{ contentEncoding: "utf-8"; contentType: "application/json"; correlationId: string; eventName?: string; id: string; isHandledError: boolean; messageType: CommandErrorResponse; otp?: string; payload: { data?: unknown; message: string; status: StatusCode; }; principalId?: string; receiver: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; sender: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; tenantId?: string; timestamp: number; traceId?: string; }, "instanceId">> | { contentEncoding: string; contentType: string; correlationId: string; eventName?: string; id: string; messageType: CommandSuccessResponse; otp: string; payload: unknown; principalId?: string; receiver: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; sender: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; tenantId?: string; timestamp: number; traceId?: string; }>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:140

Called when a command is received by the service

Parameters

message

Readonly<Command>

Command envelope to execute

Returns

Promise<Readonly<Omit<{ contentEncoding: "utf-8"; contentType: "application/json"; correlationId: string; eventName?: string; id: string; isHandledError: boolean; messageType: CommandErrorResponse; otp?: string; payload: { data?: unknown; message: string; status: StatusCode; }; principalId?: string; receiver: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; sender: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; tenantId?: string; timestamp: number; traceId?: string; }, "instanceId">> | { contentEncoding: string; contentType: string; correlationId: string; eventName?: string; id: string; messageType: CommandSuccessResponse; otp: string; payload: unknown; principalId?: string; receiver: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; sender: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; tenantId?: string; timestamp: number; traceId?: string; }>

Inherited from

Service.executeCommand


executeStream()

executeStream(message): Promise<void>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:184

Parameters

message

Readonly<StreamMessage>

Returns

Promise<void>

Inherited from

Service.executeStream


executeSubscription()

executeSubscription(message, subscriptionName): Promise<Omit<{ contentEncoding: string; contentType: string; correlationId?: string; eventName: string; id: string; messageType: CustomMessage; otp?: string; payload?: unknown; principalId?: string; receiver?: EBMessageAddress; sender: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; tenantId?: string; timestamp: number; traceId?: string; }, "id" | "timestamp"> | undefined>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:186

Parameters

message

Readonly<EBMessage>

subscriptionName

string

Returns

Promise<Omit<{ contentEncoding: string; contentType: string; correlationId?: string; eventName: string; id: string; messageType: CustomMessage; otp?: string; payload?: unknown; principalId?: string; receiver?: EBMessageAddress; sender: { instanceId: string; serviceName: string; serviceTarget: string; serviceVersion: string; }; tenantId?: string; timestamp: number; traceId?: string; }, "id" | "timestamp"> | undefined>

Inherited from

Service.executeSubscription


getAgentInvokeFunction()

protected getAgentInvokeFunction<Invokes>(serviceTarget, traceId?, principalId?, tenantId?, agentInvokes?): <InvokeResponseType, PayloadType, ParameterType>(receiver, payload, parameter) => AgentInvocation<InvokeResponseType>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:100

Type Parameters

Invokes

Invokes extends AgentInvokeList

Parameters

serviceTarget

string

traceId?

string

principalId?

string

tenantId?

string

agentInvokes?

Invokes

Returns

<InvokeResponseType, PayloadType, ParameterType>(receiver, payload, parameter): AgentInvocation<InvokeResponseType>

Type Parameters
InvokeResponseType

InvokeResponseType = { history: any[]; message: any; }

PayloadType

PayloadType = {[x: string]: unknown; attachments: any[]; conversationId?: string; history: any[]; message: string; }

ParameterType

ParameterType = EmptyObject

Parameters
receiver

EBMessageAddress

payload

PayloadType

parameter

ParameterType

Returns

AgentInvocation<InvokeResponseType>

Inherited from

Service.getAgentInvokeFunction


getConsumeStreamFunction()

protected getConsumeStreamFunction<StreamInvokes>(serviceTarget, traceId?, principalId?, tenantId?, streamInvokes?): OpenStreamFunction

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:132

Type Parameters

StreamInvokes

StreamInvokes extends StreamInvokeList

Parameters

serviceTarget

string

traceId?

string

principalId?

string

tenantId?

string

streamInvokes?

StreamInvokes

Returns

OpenStreamFunction

Inherited from

Service.getConsumeStreamFunction


getContextFunctions()

getContextFunctions(logger, queueNamespace?): ContextBase

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:134

Parameters

logger

Logger

queueNamespace?

QueueContext

Returns

ContextBase

Inherited from

Service.getContextFunctions


getEmitFunction()

protected getEmitFunction<EmitList>(serviceTarget, traceId?, principalId?, tenantId?, emitList?): <K, Payload>(eventName, eventPayload?, contentType?, contentEncoding?) => Promise<void>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:133

Type Parameters

EmitList

EmitList extends Record<string, Schema> = EmptyObject

Parameters

serviceTarget

string

traceId?

string

principalId?

string

tenantId?

string

emitList?

EmitList

Returns

<K, Payload>(eventName, eventPayload?, contentType?, contentEncoding?): Promise<void>

Type Parameters
K

K extends string | number | symbol

Payload

Payload = EmitList[K]

Parameters
eventName

K

eventPayload?

Payload

contentType?

string

contentEncoding?

string

Returns

Promise<void>

Inherited from

Service.getEmitFunction


getInvokeFunction()

protected getInvokeFunction<Invokes>(serviceTarget, traceId?, principalId?, tenantId?, invokes?): <Payload, Parameter>(receiver, invokePayload, invokeparameter, contentType?, contentEncoding?) => Promise<any>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:99

Type Parameters

Invokes

Invokes extends InvokeList

Parameters

serviceTarget

string

traceId?

string

principalId?

string

tenantId?

string

invokes?

Invokes

Returns

<Payload, Parameter>(receiver, invokePayload, invokeparameter, contentType?, contentEncoding?): Promise<any>

Type Parameters
Payload

Payload

Parameter

Parameter extends EmptyObject

Parameters
receiver

EBMessageAddress

invokePayload

Payload

invokeparameter

Parameter

contentType?

string

contentEncoding?

string

Returns

Promise<any>

Inherited from

Service.getInvokeFunction


getQueueNamespace()

protected getQueueNamespace(queueInvokes?, traceId?, principalId?, tenantId?): object

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:110

Parameters

queueInvokes?

QueueInvokeList

traceId?

string

principalId?

string

tenantId?

string

Returns

object

enqueue

enqueue: QueueInvokeFunction & QueueInvokeClientMap<QueueInvokeList>

scheduleAt

scheduleAt: QueueScheduleFunction & QueueScheduleProxy<QueueInvokeClientMap<QueueInvokeList>>

Inherited from

Service.getQueueNamespace


getServiceHealth()

getServiceHealth(): Promise<ServiceHealthState>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:183

Returns

Promise<ServiceHealthState>

Inherited from

Service.getServiceHealth


getTracer()

getTracer(name?, version?): Tracer

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:51

Returns open telemetry tracer of this service

Parameters

name?

string

version?

string

Returns

Tracer

Tracer

Inherited from

Service.getTracer


initializeEventbridgeConnect()

protected initializeEventbridgeConnect(commandDefinitionList, subscriptions, streams): Promise<void>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:91

Connect service to event bridge to receive commands and command responses

Parameters

commandDefinitionList

CommandDefinitionListResolved<any>

subscriptions

SubscriptionDefinitionListResolved<any>

streams

StreamDefinitionListResolved<any>

Returns

Promise<void>

Inherited from

Service.initializeEventbridgeConnect


initializeQueues()

protected initializeQueues(): Promise<void>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:92

Returns

Promise<void>

Inherited from

Service.initializeQueues


invoke()

invoke<T>(input, endpoint): Promise<T>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:242

Type Parameters

T

T

Parameters

input

Omit<Command, "id" | "messageType" | "timestamp" | "correlationId" | "sender">

endpoint

string

Returns

Promise<T>


off()

off<K>(eventName, fn): void

Defined in: core/dist/commonjs/core/types/GenericEventEmitter.d.ts:15

Type Parameters

K

K extends EventKey<ServiceEvents>

Parameters

eventName

K

fn

EventReceiver<ServiceEvents[K]>

Returns

void

Inherited from

Service.off


on()

on<K>(eventName, fn): void

Defined in: core/dist/commonjs/core/types/GenericEventEmitter.d.ts:14

Type Parameters

K

K extends EventKey<ServiceEvents>

Parameters

eventName

K

fn

EventReceiver<ServiceEvents[K]>

Returns

void

Inherited from

Service.on


openStream()

openStream(input, endpoint): Promise<StreamHandle<unknown, unknown>>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:257

Parameters

input

Omit<Command, "id" | "messageType" | "timestamp" | "correlationId" | "sender">

endpoint

string

Returns

Promise<StreamHandle<unknown, unknown>>


registerCommand()

registerCommand(commandDefinition): Promise<void>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:176

Parameters

commandDefinition

CommandDefinition<any, any, any, any, any, any, any, any, any, any, EmptyObject, any, any, any>

Returns

Promise<void>

Inherited from

Service.registerCommand


registerStream()

registerStream(streamDefinition): Promise<void>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:185

Parameters

streamDefinition

StreamDefinition<any, any, any, any, any, any, any, EmptyObject, any, any, any, any, any, any>

Returns

Promise<void>

Inherited from

Service.registerStream


registerSubscription()

registerSubscription(subscriptionDefinition): Promise<void>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:187

Parameters

subscriptionDefinition

SubscriptionDefinition<any, any, any, any, any, any, any, any, EmptyObject, any, any, any>

Returns

Promise<void>

Inherited from

Service.registerSubscription


removeAllListeners()

removeAllListeners(): void

Defined in: core/dist/commonjs/core/types/GenericEventEmitter.d.ts:17

Returns

void

Inherited from

Service.removeAllListeners


sendServiceInfo()

protected sendServiceInfo(infoType, target?, payload?): Promise<Readonly<EBMessage>>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:98

Broadcast service info message

Parameters

infoType

InfoMessageType

type of info message

target?

string

function name is need in messages like InfoServiceFunctionAdded

payload?

Record<string, unknown>

Returns

Promise<Readonly<EBMessage>>

Inherited from

Service.sendServiceInfo


start()

start(): Promise<void>

Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:146

It connects to the event bridge and subscribes to the topics that are in the subscription list.

Returns

Promise<void>

Overrides

Service.start


startActiveSpan()

startActiveSpan<F>(name, opts, context, fn): Promise<F>

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:60

Start a child span for opentelemetry tracking

Type Parameters

F

F

Parameters

name

string

name of span

opts

SpanOptions

span options

context

optional context

Context | undefined

fn

(span) => Promise<F>

function to be executed within the span

Returns

Promise<F>

return value of fn

Inherited from

Service.startActiveSpan


startQueueWorkers()

protected startQueueWorkers(): void

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:177

Returns

void

Inherited from

Service.startQueueWorkers


stopQueueWorkers()

protected stopQueueWorkers(): Promise<void>

Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:178

Returns

Promise<void>

Inherited from

Service.stopQueueWorkers


wrapInSpan()

wrapInSpan<F>(name, opts, fn, context?): Promise<F>

Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:76

Start span for opentelemetry tracking on same level. The created span will not become the "active" span within opentelemetry!

This means during logging and similar the spanId of parent span is logged.

Use wrapInSpan for marking points in flow of one bigger function, but not to trace the program flow itself

Type Parameters

F

F

Parameters

name

string

name of span

opts

SpanOptions

span options

fn

(span) => Promise<F>

function te be executed in the span

context?

Context

span context

Returns

Promise<F>

return value of fn

Inherited from

Service.wrapInSpan