-
-
Notifications
You must be signed in to change notification settings - Fork 798
Expand file tree
/
Copy pathdeclarations.ts
More file actions
68 lines (61 loc) · 2.03 KB
/
Copy pathdeclarations.ts
File metadata and controls
68 lines (61 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import http from 'http'
import express, { Express } from 'express'
import {
Application as FeathersApplication,
Params as FeathersParams,
HookContext,
ServiceMethods,
ServiceInterface,
RouteLookup
} from '@feathersjs/feathers'
interface ExpressUseHandler<T, Services> {
<L extends keyof Services & string>(
path: L,
...middlewareOrService: (
| Express
| express.RequestHandler
| express.RequestHandler[]
| (keyof any extends keyof Services ? ServiceInterface : Services[L])
)[]
): T
(path: string | RegExp, ...expressHandlers: express.RequestHandler[]): T
(...expressHandlers: express.RequestHandler[]): T
(handler: Express | express.ErrorRequestHandler): T
}
export interface ExpressOverrides<Services> {
listen(port: number, hostname: string, backlog: number, callback?: () => void): Promise<http.Server>
listen(port: number, hostname: string, callback?: () => void): Promise<http.Server>
listen(port: number | string | any, callback?: () => void): Promise<http.Server>
listen(callback?: () => void): Promise<http.Server>
use: ExpressUseHandler<this, Services>
server?: http.Server
}
export type Application<Services = any, Settings = any> = Omit<Express, 'listen' | 'use' | 'get' | 'set'> &
FeathersApplication<Services, Settings> &
ExpressOverrides<Services>
declare module '@feathersjs/feathers/lib/declarations' {
interface ServiceOptions {
express?: {
before?: express.RequestHandler[]
after?: express.RequestHandler[]
composed?: express.RequestHandler
}
}
}
declare module 'express-serve-static-core' {
interface Request {
feathers: Partial<FeathersParams> & { [key: string]: any }
lookup?: RouteLookup
}
interface Response {
data?: any
hook?: HookContext
}
interface IRouterMatcher<T> {
// eslint-disable-next-line
<P extends Params = ParamsDictionary, ResBody = any, ReqBody = any>(
path: PathParams,
...handlers: (RequestHandler<P, ResBody, ReqBody> | Partial<ServiceMethods> | Application)[]
): T
}
}