/// /// import http = require("http"); import http2 = require("http2"); import fastify = require("fastify"); import { FastifyRequest, FastifyReply } from "fastify"; import Bookshelf = require("bookshelf"); export type FastifyInstance = fastify.FastifyInstance< HttpServer, HttpRequest, HttpResponse >; export type HttpServer = http.Server | http2.Http2Server; export type HttpRequest = http.IncomingMessage | http2.Http2ServerRequest; export type HttpResponse = http.ServerResponse | http2.Http2ServerResponse; export type Middleware = ( request?: FastifyRequest, reply?: FastifyReply ) => Promise; export interface IController { path: string; handler: PluginHandler; } export type PluginHandler = fastify.Plugin< HttpServer, HttpRequest, HttpResponse, any >; export interface IPlugin { handler: PluginHandler; options?: any; } export interface IModule { name: string; controllers: IController[]; repositories: IRepository[]; middlewares?: Middleware[]; plugins?: IPlugin[]; } export interface BootstrapOptions { modules: IModule[]; } export interface IExtendedModel extends Partial> { findAll: Middleware; findById: Middleware; upsert: Middleware; remove: Middleware; recover: Middleware; forge(props?: any, options?: any): any; watch(options: any): any; watchAll(options: any): any; } export interface IRepository { name: string; path: string; model: IExtendedModel; controller: IController; websocket: boolean; makeCrud(name: string, options: any): void; makeReactive(name: string): void; }