Skip to main content

Class: ProtoCat<Extension>

The main ProtoCat server application class

Type parameters

NameType
Extensionunknown

Constructors

constructor

new ProtoCat<Extension>(options?)

Type parameters

NameType
Extensionunknown

Parameters

NameType
options?ChannelOptions

Defined in

lib/server/application.ts:21

Properties

methodDefinitions

Private methodDefinitions: Record<string, MethodDefinition<any, any>>

Map of loaded generated method stubs

Defined in

lib/server/application.ts:16


middleware

Private Readonly middleware: Middleware<Extension>[]

Global middleware functions

Defined in

lib/server/application.ts:20


server

server: Server

Underlying gRPC server

Defined in

lib/server/application.ts:14


serviceHandlers

Private serviceHandlers: Record<string, Middleware<unknown>[]>

Map of loaded method service implementations

Defined in

lib/server/application.ts:18

Methods

addService

addService<T>(serviceDefinition, serviceImplementation): void

Add service stub and its definition

Type parameters

NameType
Textends ServiceDefinition<UntypedServiceImplementation>

Parameters

NameType
serviceDefinitionT
serviceImplementationServiceImplementationExtended<T, Extension>

Returns

void

Defined in

lib/server/application.ts:38


start

start(address, creds?): Promise<number>

Internally register handlers, bind port and start server

Parameters

NameTypeDescription
addressstringe.g. 0.0.0.0:3000
credsServerCredentials-

Returns

Promise<number>

Defined in

lib/server/application.ts:83


stop

stop(): Promise<void>

Try to shutdown server gracefully.

Returns

Promise<void>

Defined in

lib/server/application.ts:96


use

use(...middleware): void

Add a global gRPC middleware for the application

Parameters

NameType
...middlewareMiddleware<Extension>[]

Returns

void

Defined in

lib/server/application.ts:31