-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpGatewayConfig.ts
46 lines (39 loc) · 1.34 KB
/
HttpGatewayConfig.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
41
42
43
44
45
46
import { ServiceConfig } from "composite-service";
import * as HttpProxyMiddleware from "http-proxy-middleware";
import serveStatic from "serve-static";
/**
* Configuration for an http gateway service
*/
export interface HttpGatewayConfig extends Omit<ServiceConfig, "command" | "ready"> {
/**
* Port to listen on.
*/
port: number | string;
/**
* Host to listen on.
* Defaults to `0.0.0.0`.
*/
host?: string;
/**
* Ordered collection of routes, where the key is an absolute URL path,
* and the value is configuration of how to handle requests to that path and all it's sub-paths.
*
* The order of entries is significant because requests will be handled by the *first* matching route.
* Therefore, if you have a route for `'/'`, it should be come last.
*/
routes: { [path: string]: HttpGatewayRouteConfig };
/**
* Hook to run after the service is ready but before it is registered as ready.
*/
onReady?: () => void | Promise<void>;
}
export type HttpGatewayRouteConfig =
| { proxy: HttpGatewayProxyHandlerConfig }
| { static: HttpGatewayStaticHandlerConfig };
export interface HttpGatewayProxyHandlerConfig extends HttpProxyMiddleware.Options {}
export interface HttpGatewayStaticHandlerConfig extends serveStatic.ServeStaticOptions {
/**
* Root directory to serve files from
*/
root: string;
}