arrest
Version:
OpenAPI v3 compliant REST framework for Node.js, with support for MongoDB and JSON-Schema
42 lines (41 loc) • 2.15 kB
TypeScript
/// <reference types="node" />
import { Logger } from 'debuggo';
import { NextFunction, Router, RouterOptions } from 'express';
import https from 'https';
import { OpenAPIV3, ParseOptions, SchemaObject } from 'openapi-police';
import { RESTError } from './error.js';
import { Resource } from './resource.js';
import { APIRequest, APIResponse } from './types.js';
export declare class API {
document: OpenAPIV3.Document;
protected logger: Logger;
protected resources: Resource[];
readonly originalSchemas: {
[name: string]: OpenAPIV3.SchemaObject;
};
protected dynamicSchemas: {
[name: string]: SchemaObject;
};
protected internalRouter: Promise<Router>;
protected parseOptions: ParseOptions;
constructor(info?: OpenAPIV3.InfoObject);
protected getDebugLabel(): string;
protected getDebugContext(): string;
protected defaultSchemaRetriever(url: string): Promise<any>;
addResource(resource: Resource): this;
registerSchema(name: string, schema: OpenAPIV3.SchemaObject): void;
registerDynamicSchema(name: string, schema: SchemaObject): void;
registerOperation(path: string, method: string, operation: OpenAPIV3.OperationObject): () => OpenAPIV3.OperationObject;
registerTag(tag: OpenAPIV3.TagObject): void;
registerOauth2Scope(name: string, description: string): void;
getOauth2Schemes(): OpenAPIV3.OAuth2SecurityScheme[];
listen(httpPort: number, httpsPort?: number, httpsOptions?: https.ServerOptions): Promise<any>;
router(options?: RouterOptions): Promise<Router>;
attach(base: Router, options?: RouterOptions): Promise<Router>;
initSecurity(req: APIRequest, _res: APIResponse, next: NextFunction): void;
securityValidator(req: APIRequest, res: APIResponse, next: NextFunction): void;
handleError(err: any, req: APIRequest, res: APIResponse, next?: NextFunction): void;
static newError(code: number, message?: string, info?: any, err?: any): RESTError;
static fireError(code: number, message?: string, info?: any, err?: any): never;
static handle404Error(req: APIRequest, res: APIResponse, next: NextFunction): void;
}