import { Server } from 'node:http'; import { ApolloServer } from '@apollo/server'; import type { KeyValueCache } from '@apollo/utils.keyvaluecache'; import express, { Express, NextFunction, Request, RequestHandler, Response } from 'express'; import { RateLimitExceededEventHandler } from 'express-rate-limit'; import { WebSocketServer } from 'ws'; import { AppBaseInitParams, AppSeed } from './app-seed'; import { AccessInfo, AuthDirective } from './common'; export type { Express, NextFunction, RateLimitExceededEventHandler, Request, RequestHandler, Response }; export { express }; export declare const DEFAULT_RATE_LIMIT_WINDOW: number; export declare const DEFAULT_RATE_LIMIT_MAX_REQ_PER_WINDOW = 100; export interface MyContext { req: Request; accessInfo: AccessInfo; cache: KeyValueCache; } export interface MyPubSubContext { req?: any; accessInfo: AccessInfo; cache?: KeyValueCache; sessionId?: string; transactionSessionId?: string; } export declare abstract class AppBase extends AppSeed { protected app: Express; protected listener: Server; protected httpServer: Server; protected wsServer: WebSocketServer; protected apolloServer: ApolloServer; protected correlator: any; protected abstract get liveness(): boolean; protected abstract get readiness(): boolean; constructor(name?: string, version?: string); protected init(params?: AppBaseInitParams): Promise; private setupBaseMiddleware; private setupBaseComponents; private setupAuthComponents; term(): Promise; /** * FIX ME. The Apollo Server won't close the http server during the drain process * HttpServer.close need to be called due to unknown reason from the Apollo Server shutdown process * Expected the Apollo Server will call the close and terminate gracefully */ termEx(): Promise; run(port?: number, hostname?: string): Promise; runEx(port?: number, hostname?: string): Promise; protected handler(thisObject: any, func: RequestHandler, authDirective: AuthDirective | undefined, logging?: boolean, raw?: boolean): RequestHandler; protected fileHandler(cachePath: string, maxFileSize: number, fileFieldName?: string): RequestHandler; /** * @api {get} /liveness Liveness health check * @apiVersion 1.0.0 * @apiName onLiveness * @apiGroup HealthCheck * @apiPermission none * * @apiDescription Service liveness health check. * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK * * @apiErrorExample Error-Response: * HTTP/1.1 500 Service is offline */ private onLiveness; /** * @api {get} /readiness Readiness health check * @apiVersion 1.0.0 * @apiName onReadiness * @apiGroup HealthCheck * @apiPermission none * * @apiDescription Service readiness health check. * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK * * @apiErrorExample Error-Response: * HTTP/1.1 429 Service is not ready */ private onReadiness; /** * @api {get} / Service information * @apiVersion 1.0.0 * @apiName onRoot * @apiGroup HealthCheck * @apiPermission none * * @apiDescription Service information. * * @apiSuccess {String} message Service information * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK * { * "message": "Welcome to the coolest API on earth - ServiceName:1.0.0" * } */ private onRoot; }