-
Notifications
You must be signed in to change notification settings - Fork 10
/
types.ts
108 lines (88 loc) · 2.47 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
import Router from './Router';
import { AxiosBasicCredentials, AxiosProxyConfig, AxiosInstance } from 'axios';
import { DocumentNode } from 'graphql';
import express from 'express';
export interface IGlobalConfiguration {
cacheEngine?: ICacheEngine;
defaultTimeoutInMs?: number;
defaultCacheTimeInMs?: number;
logger?: ILogger;
defaultLogLevel?: LogLevel;
autoDiscoverEndpoints?: boolean;
optimizeQueryRequest?: boolean;
headers?: Record<string, unknown>;
passThroughHeaders?: string[];
auth?: AxiosBasicCredentials;
proxy?: AxiosProxyConfig;
}
export interface IConstructorRouteOptions {
schema: DocumentNode | string; // GraphQL Document Type
operationName: string;
axios: AxiosInstance;
logger?: ILogger;
defaultLogLevel: LogLevel;
path?: string;
cacheTimeInMs?: number;
method?: string;
passThroughHeaders?: string[];
staticVariables?: Record<string, unknown>;
defaultVariables?: Record<string, unknown>;
}
export interface IRouteOptions {
path?: string;
cacheTimeInMs?: number;
method?: string;
passThroughHeaders?: string[];
staticVariables?: Record<string, unknown>;
defaultVariables?: Record<string, unknown>;
}
export interface IOperationVariableMap {
[variableName: string]: IOperationVariable;
}
export interface IOperationVariable {
name: string;
required: boolean;
type: string;
array: boolean;
defaultValue?: string | boolean | number;
}
export interface IResponse {
statusCode: number;
body: Record<string, unknown>;
}
export interface IOpenApiOptions {
title: string;
version: string;
termsOfService?: string;
license?: string;
basePath?: string;
host?: string;
}
export interface IMountableItem {
path: string;
httpMethod: string;
at: (path: string) => this;
asExpressRoute: () => (req: express.Request, res: express.Response) => void;
asKoaRoute: () => void;
asMetal: () => void;
withOptions: (options: Record<string, unknown>) => this;
onMount?: (router: Router) => this
}
export interface ICacheEngine {
get: (key: string, setFn?: () => string|number|boolean) => string|number|boolean;
set: (key: string, value: string|number|boolean) => void;
}
export interface ILogger {
error: (message: string) => void;
warn: (message: string) => void;
info: (message: string) => void;
debug: (message: string) => void;
}
export type LogLevel = -1 | 0 | 1 | 2 | 3;
export interface ILogLevels {
SILENT: LogLevel,
ERROR: LogLevel,
WARN: LogLevel,
INFO: LogLevel,
DEBUG: LogLevel,
}