-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.d.ts
40 lines (33 loc) · 1.18 KB
/
index.d.ts
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
import { CallbackComponent } from 'systemic'
import { ErrorRequestHandler, Express, RequestHandler } from 'express'
export type AppConfig = {
settings: Record<string, any>
}
export type ServerConfig = {
port: number
host?: string
shutdown?: { delay?: string }
}
type MiddlewareOptions = {
notFound?: RequestHandler
error?: ErrorRequestHandler
}
export type MiddleWareConfig = {
showErrorDetail?: boolean
}
/**
* Systemic component that creates and configures an Express app
* @param options optionally a function that creates a basic Express app can be passed into the component
*/
export function app(options?: { express?: () => Express }): CallbackComponent<Express, { config?: AppConfig; logger?: any }>
/**
* Starts the Express server
*/
export function server(): CallbackComponent<void, { config: ServerConfig; app: Express; logger?: any }>
/**
* Adds default notFound and error middleware to the app
* @param options Custom notfound and error middleware can be passed in. If omitted default middleware will be used.
*/
export function defaultMiddleware(
options?: MiddlewareOptions,
): CallbackComponent<void, { config?: MiddleWareConfig; app: Express; logger?: any }>