UNPKG

1.7 kBTypeScriptView Raw
1/// <reference types="node" />
2import http = require("http");
3import http2 = require("http2");
4import fastify = require("fastify");
5import { FastifyRequest, FastifyReply } from "fastify";
6import Bookshelf = require("bookshelf");
7export declare type FastifyInstance = fastify.FastifyInstance<HttpServer, HttpRequest, HttpResponse>;
8export declare type HttpServer = http.Server | http2.Http2Server;
9export declare type HttpRequest = http.IncomingMessage | http2.Http2ServerRequest;
10export declare type HttpResponse = http.ServerResponse | http2.Http2ServerResponse;
11export declare type Middleware = (request?: FastifyRequest<any>, reply?: FastifyReply<any>) => Promise<any>;
12export interface IController {
13 path: string;
14 handler: PluginHandler;
15}
16export declare type PluginHandler = fastify.Plugin<HttpServer, HttpRequest, HttpResponse, any>;
17export interface IPlugin {
18 handler: PluginHandler;
19 options?: any;
20}
21export interface IModule {
22 name: string;
23 controllers: IController[];
24 repositories: IRepository[];
25 middlewares?: Middleware[];
26 plugins?: IPlugin[];
27}
28export interface BootstrapOptions {
29 modules: IModule[];
30}
31export 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}
41export 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}