forked from Matthew-Smith/general-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
134 lines (101 loc) · 3.51 KB
/
types.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { RateLimitConfig, Validator } from '@voiceflow/backend-utils';
import { BaseRequest, BaseTrace } from '@voiceflow/base-types';
import * as Express from 'express';
import http from 'http';
import { RuntimeRequest } from '@/lib/services/runtime/types';
import CacheDataAPI from '@/lib/services/state/cacheDataAPI';
import * as Runtime from './runtime';
export interface Config extends RateLimitConfig {
NODE_ENV: string;
PORT: string;
PORT_METRICS: string | null;
ERROR_RESPONSE_MS: number;
CLOUD_ENV: string | null;
IS_PRIVATE_CLOUD: boolean;
AWS_ACCESS_KEY_ID: string | null;
AWS_SECRET_ACCESS_KEY: string | null;
AWS_REGION: string | null;
AWS_ENDPOINT: string | null;
DYNAMO_ENDPOINT: string | null;
S3_ACCESS_KEY_ID: string | null;
S3_SECRET_ACCESS_KEY: string | null;
S3_TLS_BUCKET: string | null;
S3_ENDPOINT: string | null;
CODE_HANDLER_ENDPOINT: string | null;
INTEGRATIONS_HANDLER_ENDPOINT: string;
API_REQUEST_TIMEOUT_MS: number | null;
API_MAX_CONTENT_LENGTH_BYTES: number | null;
API_MAX_BODY_LENGTH_BYTES: number | null;
// Release information
GIT_SHA: string | null;
BUILD_NUM: string | null;
SEM_VER: string | null;
BUILD_URL: string | null;
GENERAL_SERVICE_ENDPOINT: string | null;
ML_GATEWAY_ENDPOINT: string | null;
KNOWLEDGE_BASE_LAMBDA_ENDPOINT: string | null;
AUTH_API_SERVICE_HOST: string | null;
AUTH_API_SERVICE_PORT_APP: string | null;
NLU_GATEWAY_SERVICE_HOST: string | null;
NLU_GATEWAY_SERVICE_PORT_APP: string | null;
CREATOR_API_ENDPOINT: string | null;
CREATOR_API_AUTHORIZATION: string | null;
CREATOR_APP_ORIGIN: string | null;
DISABLE_ORIGIN_CHECK: boolean;
// Logging
LOG_LEVEL: string | null;
MIDDLEWARE_VERBOSITY: string | null;
PROJECT_SOURCE: string | null;
REDIS_CLUSTER_HOST: string | null;
REDIS_CLUSTER_PORT: number | null;
SESSIONS_SOURCE: string;
MONGO_URI: string | null;
MONGO_DB: string | null;
ANALYTICS_ENDPOINT: string | null;
ANALYTICS_WRITE_KEY: string | null;
INGEST_V2_WEBHOOK_ENDPOINT: string | null;
}
export interface Request<
P extends Record<string, any> = Record<string, any>,
B = any,
H extends Record<string, any> = Record<string, any>,
Q = any,
RB = any
> extends Express.Request<P, RB, B, Q> {
headers: http.IncomingHttpHeaders & H;
}
export type Response = Express.Response;
export type Next = () => void;
export interface Route<Params = Record<string, any>, T = void> {
(req: Request<Params>): Promise<T>;
validations?: Validator.ValidationChain[];
callback?: boolean;
route?: unknown;
}
export type Controller = Record<string, Route>;
export type Middleware = (req: Request, res: Response, next: Next) => Promise<void>;
export type MiddlewareGroup = Record<string, Middleware>;
export interface Class<T, A extends any[]> {
new (...args: A): T;
}
export type AnyClass = Class<any, any[]>;
export enum VersionTag {
DEVELOPMENT = 'development',
PRODUCTION = 'production',
}
export const isVersionTag = (value: unknown): value is VersionTag =>
value === VersionTag.DEVELOPMENT || value === VersionTag.PRODUCTION;
export interface ContextData {
api: CacheDataAPI;
locale?: string;
config?: BaseRequest.RequestConfig;
reqHeaders?: {
origin?: string;
platform?: string;
sessionid?: string;
authorization?: string;
};
}
export type Context = Runtime.Context<RuntimeRequest, BaseTrace.AnyTrace, ContextData>;
export type ContextHandler = Runtime.ContextHandler<Context>;
export type InitContextHandler = Runtime.InitContextHandler<Context>;