1 |
|
2 | import http from 'http';
|
3 | import express, { Express } from 'express';
|
4 | import { Application as FeathersApplication, Params as FeathersParams, HookContext, ServiceMethods, ServiceInterface, RouteLookup } from '@feathersjs/feathers';
|
5 | interface ExpressUseHandler<T, Services> {
|
6 | <L extends keyof Services & string>(path: L, ...middlewareOrService: (Express | express.RequestHandler | express.RequestHandler[] | (keyof any extends keyof Services ? ServiceInterface : Services[L]))[]): T;
|
7 | (path: string | RegExp, ...expressHandlers: express.RequestHandler[]): T;
|
8 | (...expressHandlers: express.RequestHandler[]): T;
|
9 | (handler: Express | express.ErrorRequestHandler): T;
|
10 | }
|
11 | export interface ExpressOverrides<Services> {
|
12 | listen(port: number, hostname: string, backlog: number, callback?: () => void): Promise<http.Server>;
|
13 | listen(port: number, hostname: string, callback?: () => void): Promise<http.Server>;
|
14 | listen(port: number | string | any, callback?: () => void): Promise<http.Server>;
|
15 | listen(callback?: () => void): Promise<http.Server>;
|
16 | use: ExpressUseHandler<this, Services>;
|
17 | server?: http.Server;
|
18 | }
|
19 | export type Application<Services = any, Settings = any> = Omit<Express, 'listen' | 'use' | 'get' | 'set'> & FeathersApplication<Services, Settings> & ExpressOverrides<Services>;
|
20 | declare module '@feathersjs/feathers/lib/declarations' {
|
21 | interface ServiceOptions {
|
22 | express?: {
|
23 | before?: express.RequestHandler[];
|
24 | after?: express.RequestHandler[];
|
25 | composed?: express.RequestHandler;
|
26 | };
|
27 | }
|
28 | }
|
29 | declare module 'express-serve-static-core' {
|
30 | interface Request {
|
31 | feathers: Partial<FeathersParams> & {
|
32 | [key: string]: any;
|
33 | };
|
34 | lookup?: RouteLookup;
|
35 | }
|
36 | interface Response {
|
37 | data?: any;
|
38 | hook?: HookContext;
|
39 | }
|
40 | interface IRouterMatcher<T> {
|
41 | <P extends Params = ParamsDictionary, ResBody = any, ReqBody = any>(path: PathParams, ...handlers: (RequestHandler<P, ResBody, ReqBody> | Partial<ServiceMethods> | Application)[]): T;
|
42 | }
|
43 | }
|
44 | export {};
|