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
Service<ServiceClassTypes<ConfigType>>
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
Properties
activeStreamSessions
protectedactiveStreamSessions:Map<string, {cancelled:boolean;cancelReason?:string;onCancel: (reason?) =>void[]; }>
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:65
Inherited from
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
commands
protectedcommands: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
config
config:
ConfigType
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:79
Inherited from
configSchema
protectedconfigSchema:Schema|undefined
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:31
Inherited from
configStore
protectedconfigStore:ConfigStore
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:29
Inherited from
eventBridge
protectedeventBridge:EventBridge
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:24
Inherited from
info
readonlyinfo:ServiceInfoType
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:23
Inherited from
isStarted
isStarted:
boolean
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:81
Inherited from
logger
logger:
Logger
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:25
Inherited from
queueDefinitionList
protectedqueueDefinitionList:QueueDefinitionListResolved<any>
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:63
Inherited from
queueWorkerDefinitionList
protectedqueueWorkerDefinitionList: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
routeDefinitions
routeDefinitions:
object[] =[]
Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:44
expose
expose:
object&object
Type Declaration
contentEncodingRequest?
optionalcontentEncodingRequest:string
contentEncodingResponse?
optionalcontentEncodingResponse:string
contentTypeRequest?
optionalcontentTypeRequest:string
contentTypeResponse?
optionalcontentTypeResponse:string
deprecated?
optionaldeprecated:boolean
inputPayload?
optionalinputPayload:SchemaObject
outputPayload?
optionaloutputPayload:SchemaObject
parameter?
optionalparameter:SchemaObject
Type Declaration
http
http:
object
http.method
method:
"GET"|"DELETE"|"PATCH"|"POST"|"PUT"
http.mode?
optionalmode:"sync"|"async"
http.openApi?
optionalopenApi:object
http.openApi.additionalStatusCodes?
optionaladditionalStatusCodes:StatusCode[]
http.openApi.description
description:
string
http.openApi.isSecure
isSecure:
boolean
http.openApi.operationId?
optionaloperationId:string
http.openApi.query?
optionalquery:QueryParameter<Record<..., ...>>[]
http.openApi.summary
summary:
string
http.openApi.tags?
optionaltags:string[]
http.path
path:
string
routes
routes:
Trouter<Function>
Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:46
secretStore
protectedsecretStore:SecretStore
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:28
Inherited from
server?
optionalserver: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
stateStore
protectedstateStore:StateStore
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:30
Inherited from
streamDefinitionList
streamDefinitionList:
StreamDefinitionListResolved<any>
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:78
Inherited from
streams
protectedstreams: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
subscriptionDefinitionList
subscriptionDefinitionList:
SubscriptionDefinitionListResolved<any>
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:77
Inherited from
Service.subscriptionDefinitionList
subscriptions
protectedsubscriptions: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
traceProvider
traceProvider:
NodeTracerProvider
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:27
Inherited from
Accessors
name
Get Signature
get name():
string
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:83
Returns
string
Inherited from
serviceInfo
Get Signature
get serviceInfo():
ServiceInfoType
Defined in: core/dist/commonjs/core/Service/ServiceBaseClass/ServiceBaseClass.impl.d.ts:45
Get service info
Returns
Inherited from
Methods
addBeforeResponse()
addBeforeResponse(
method,pattern,handler):void
Defined in: httpserver/src/service/httpServer/v1/HttpServerClass.impl.ts:142
Parameters
method
HTTPMethods
pattern
string
handler
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
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?
Returns
void
Inherited from
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
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
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
getAgentInvokeFunction()
protectedgetAgentInvokeFunction<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
payload
PayloadType
parameter
ParameterType
Returns
AgentInvocation<InvokeResponseType>
Inherited from
Service.getAgentInvokeFunction
getConsumeStreamFunction()
protectedgetConsumeStreamFunction<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
Inherited from
Service.getConsumeStreamFunction
getContextFunctions()
getContextFunctions(
logger,queueNamespace?):ContextBase
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:134
Parameters
logger
queueNamespace?
Returns
Inherited from
getEmitFunction()
protectedgetEmitFunction<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
getInvokeFunction()
protectedgetInvokeFunction<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
invokePayload
Payload
invokeparameter
Parameter
contentType?
string
contentEncoding?
string
Returns
Promise<any>
Inherited from
getQueueNamespace()
protectedgetQueueNamespace(queueInvokes?,traceId?,principalId?,tenantId?):object
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:110
Parameters
queueInvokes?
traceId?
string
principalId?
string
tenantId?
string
Returns
object
enqueue
enqueue:
QueueInvokeFunction&QueueInvokeClientMap<QueueInvokeList>
scheduleAt
scheduleAt:
QueueScheduleFunction&QueueScheduleProxy<QueueInvokeClientMap<QueueInvokeList>>
Inherited from
getServiceHealth()
getServiceHealth():
Promise<ServiceHealthState>
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:183
Returns
Promise<ServiceHealthState>
Inherited from
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
initializeEventbridgeConnect()
protectedinitializeEventbridgeConnect(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()
protectedinitializeQueues():Promise<void>
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:92
Returns
Promise<void>
Inherited from
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
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
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
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
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
removeAllListeners()
removeAllListeners():
void
Defined in: core/dist/commonjs/core/types/GenericEventEmitter.d.ts:17
Returns
void
Inherited from
sendServiceInfo()
protectedsendServiceInfo(infoType,target?,payload?):Promise<Readonly<EBMessage>>
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:98
Broadcast service info message
Parameters
infoType
type of info message
target?
string
function name is need in messages like InfoServiceFunctionAdded
payload?
Record<string, unknown>
Returns
Promise<Readonly<EBMessage>>
Inherited from
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
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
startQueueWorkers()
protectedstartQueueWorkers():void
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:177
Returns
void
Inherited from
stopQueueWorkers()
protectedstopQueueWorkers():Promise<void>
Defined in: core/dist/commonjs/core/Service/Service.impl.d.ts:178
Returns
Promise<void>
Inherited from
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
