1 |
|
2 | import http = require("http");
|
3 | import http2 = require("http2");
|
4 | import fastify = require("fastify");
|
5 | import { FastifyRequest, FastifyReply } from "fastify";
|
6 | import Bookshelf = require("bookshelf");
|
7 | export declare type FastifyInstance = fastify.FastifyInstance<HttpServer, HttpRequest, HttpResponse>;
|
8 | export declare type HttpServer = http.Server | http2.Http2Server;
|
9 | export declare type HttpRequest = http.IncomingMessage | http2.Http2ServerRequest;
|
10 | export declare type HttpResponse = http.ServerResponse | http2.Http2ServerResponse;
|
11 | export declare type Middleware = (request?: FastifyRequest<any>, reply?: FastifyReply<any>) => Promise<any>;
|
12 | export interface IController {
|
13 | path: string;
|
14 | handler: PluginHandler;
|
15 | }
|
16 | export declare type PluginHandler = fastify.Plugin<HttpServer, HttpRequest, HttpResponse, any>;
|
17 | export interface IPlugin {
|
18 | handler: PluginHandler;
|
19 | options?: any;
|
20 | }
|
21 | export interface IModule {
|
22 | name: string;
|
23 | controllers: IController[];
|
24 | repositories: IRepository[];
|
25 | middlewares?: Middleware[];
|
26 | plugins?: IPlugin[];
|
27 | }
|
28 | export interface BootstrapOptions {
|
29 | modules: IModule[];
|
30 | }
|
31 | export interface IExtendedModel extends Partial<Bookshelf.Model<any>> {
|
32 | findAll: Middleware;
|
33 | findById: Middleware;
|
34 | upsert: Middleware;
|
35 | remove: Middleware;
|
36 | recover: Middleware;
|
37 | forge(props?: any, options?: any): any;
|
38 | watch(options: any): any;
|
39 | watchAll(options: any): any;
|
40 | }
|
41 | export interface IRepository {
|
42 | name: string;
|
43 | path: string;
|
44 | model: IExtendedModel;
|
45 | controller: IController;
|
46 | websocket: boolean;
|
47 | makeCrud(name: string, options: any): void;
|
48 | makeReactive(name: string): void;
|
49 | }
|