@cedarjs/api-server 5.0.4-next.167 → 5.0.4-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +2 -7
- package/dist/cjs/apiCLIConfig.d.ts +6 -0
- package/dist/cjs/apiCLIConfig.d.ts.map +1 -0
- package/dist/cjs/apiCLIConfig.js +71 -0
- package/dist/cjs/apiCLIConfigHandler.d.ts +3 -0
- package/dist/cjs/apiCLIConfigHandler.d.ts.map +1 -0
- package/dist/cjs/apiCLIConfigHandler.js +67 -0
- package/dist/cjs/bin.d.ts +2 -0
- package/dist/cjs/bin.d.ts.map +1 -0
- package/dist/cjs/bin.js +1002 -0
- package/dist/cjs/bothCLIConfig.d.ts +6 -0
- package/dist/cjs/bothCLIConfig.d.ts.map +1 -0
- package/dist/cjs/bothCLIConfig.js +76 -0
- package/dist/cjs/bothCLIConfigHandler.d.ts +3 -0
- package/dist/cjs/bothCLIConfigHandler.d.ts.map +1 -0
- package/dist/cjs/bothCLIConfigHandler.js +107 -0
- package/dist/cjs/buildManager.d.ts +15 -0
- package/dist/cjs/buildManager.d.ts.map +1 -0
- package/dist/cjs/buildManager.js +79 -0
- package/dist/cjs/cliHelpers.d.ts +6 -0
- package/dist/cjs/cliHelpers.d.ts.map +1 -0
- package/dist/cjs/cliHelpers.js +57 -0
- package/dist/cjs/createServer.d.ts +30 -0
- package/dist/cjs/createServer.d.ts.map +1 -0
- package/dist/cjs/createServer.js +145 -0
- package/dist/cjs/createServerHelpers.d.ts +38 -0
- package/dist/cjs/createServerHelpers.d.ts.map +1 -0
- package/dist/cjs/createServerHelpers.js +112 -0
- package/dist/cjs/fastify.d.ts +13 -0
- package/dist/cjs/fastify.d.ts.map +1 -0
- package/dist/cjs/fastify.js +96 -0
- package/dist/cjs/logFormatter/ambient.d.js +1 -0
- package/dist/cjs/logFormatter/bin.d.ts +2 -0
- package/dist/cjs/logFormatter/bin.d.ts.map +1 -0
- package/dist/cjs/logFormatter/bin.js +369 -0
- package/dist/cjs/logFormatter/formatters.d.ts +30 -0
- package/dist/cjs/logFormatter/formatters.d.ts.map +1 -0
- package/dist/cjs/logFormatter/formatters.js +275 -0
- package/dist/cjs/logFormatter/index.d.ts +2 -0
- package/dist/cjs/logFormatter/index.d.ts.map +1 -0
- package/dist/cjs/logFormatter/index.js +184 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/api.d.ts +14 -0
- package/dist/cjs/plugins/api.d.ts.map +1 -0
- package/dist/cjs/plugins/api.js +78 -0
- package/dist/cjs/plugins/graphql.d.ts +10 -0
- package/dist/cjs/plugins/graphql.d.ts.map +1 -0
- package/dist/cjs/plugins/graphql.js +135 -0
- package/dist/cjs/plugins/lambdaLoader.d.ts +34 -0
- package/dist/cjs/plugins/lambdaLoader.d.ts.map +1 -0
- package/dist/cjs/plugins/lambdaLoader.js +199 -0
- package/dist/cjs/requestHandlers/awsLambdaFastify.d.ts +5 -0
- package/dist/cjs/requestHandlers/awsLambdaFastify.d.ts.map +1 -0
- package/dist/cjs/requestHandlers/awsLambdaFastify.js +105 -0
- package/dist/cjs/requestHandlers/utils.d.ts +26 -0
- package/dist/cjs/requestHandlers/utils.d.ts.map +1 -0
- package/dist/cjs/requestHandlers/utils.js +55 -0
- package/dist/cjs/serverManager.d.ts +8 -0
- package/dist/cjs/serverManager.d.ts.map +1 -0
- package/dist/cjs/serverManager.js +137 -0
- package/dist/cjs/types.d.ts +19 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/utils.d.ts +6 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +58 -0
- package/dist/cjs/watch.d.ts +10 -0
- package/dist/cjs/watch.d.ts.map +1 -0
- package/dist/cjs/watch.js +399 -0
- package/dist/cjs/watchPaths.d.ts +3 -0
- package/dist/cjs/watchPaths.d.ts.map +1 -0
- package/dist/cjs/watchPaths.js +140 -0
- package/package.json +71 -40
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var formatters_exports = {};
|
|
30
|
+
__export(formatters_exports, {
|
|
31
|
+
NEWLINE: () => NEWLINE,
|
|
32
|
+
emojiLog: () => emojiLog,
|
|
33
|
+
formatBundleSize: () => formatBundleSize,
|
|
34
|
+
formatCustom: () => formatCustom,
|
|
35
|
+
formatData: () => formatData,
|
|
36
|
+
formatDate: () => formatDate,
|
|
37
|
+
formatErrorProp: () => formatErrorProp,
|
|
38
|
+
formatLevel: () => formatLevel,
|
|
39
|
+
formatLoadTime: () => formatLoadTime,
|
|
40
|
+
formatMessage: () => formatMessage,
|
|
41
|
+
formatMessageName: () => formatMessageName,
|
|
42
|
+
formatMethod: () => formatMethod,
|
|
43
|
+
formatName: () => formatName,
|
|
44
|
+
formatNs: () => formatNs,
|
|
45
|
+
formatOperationName: () => formatOperationName,
|
|
46
|
+
formatQuery: () => formatQuery,
|
|
47
|
+
formatRequestId: () => formatRequestId,
|
|
48
|
+
formatResponseCache: () => formatResponseCache,
|
|
49
|
+
formatStack: () => formatStack,
|
|
50
|
+
formatStatusCode: () => formatStatusCode,
|
|
51
|
+
formatTracing: () => formatTracing,
|
|
52
|
+
formatUrl: () => formatUrl,
|
|
53
|
+
formatUserAgent: () => formatUserAgent,
|
|
54
|
+
ignoredCustomData: () => ignoredCustomData,
|
|
55
|
+
isEmptyObject: () => isEmptyObject,
|
|
56
|
+
isObject: () => isObject,
|
|
57
|
+
isPinoLog: () => isPinoLog,
|
|
58
|
+
isWideEmoji: () => isWideEmoji,
|
|
59
|
+
noEmpty: () => noEmpty
|
|
60
|
+
});
|
|
61
|
+
module.exports = __toCommonJS(formatters_exports);
|
|
62
|
+
var import_ansis = __toESM(require("ansis"), 1);
|
|
63
|
+
var import_pretty_bytes = __toESM(require("pretty-bytes"), 1);
|
|
64
|
+
var import_pretty_ms = __toESM(require("pretty-ms"), 1);
|
|
65
|
+
const NEWLINE = "\n";
|
|
66
|
+
const emojiLog = {
|
|
67
|
+
warn: "\u{1F6A6}",
|
|
68
|
+
info: "\u{1F332}",
|
|
69
|
+
error: "\u{1F6A8}",
|
|
70
|
+
debug: "\u{1F41B}",
|
|
71
|
+
fatal: "\u{1F480}",
|
|
72
|
+
trace: "\u{1F9F5}"
|
|
73
|
+
};
|
|
74
|
+
const ignoredCustomData = [
|
|
75
|
+
"time",
|
|
76
|
+
"pid",
|
|
77
|
+
"hostname",
|
|
78
|
+
"msg",
|
|
79
|
+
"res",
|
|
80
|
+
"req",
|
|
81
|
+
"reqId",
|
|
82
|
+
"responseTime"
|
|
83
|
+
];
|
|
84
|
+
const isObject = (object) => {
|
|
85
|
+
return object && Object.prototype.toString.apply(object) === "[object Object]";
|
|
86
|
+
};
|
|
87
|
+
const isEmptyObject = (object) => {
|
|
88
|
+
return object && !Object.keys(object).length;
|
|
89
|
+
};
|
|
90
|
+
const isPinoLog = (log) => {
|
|
91
|
+
return log && Object.prototype.hasOwnProperty.call(log, "level");
|
|
92
|
+
};
|
|
93
|
+
const isWideEmoji = (character) => {
|
|
94
|
+
return character !== "\u{1F6A6}";
|
|
95
|
+
};
|
|
96
|
+
const formatBundleSize = (bundle) => {
|
|
97
|
+
const bytes = parseInt(bundle, 10);
|
|
98
|
+
const size = (0, import_pretty_bytes.default)(bytes).replace(/ /, "");
|
|
99
|
+
return import_ansis.default.gray(size);
|
|
100
|
+
};
|
|
101
|
+
const formatCustom = (query) => {
|
|
102
|
+
if (!query) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
ignoredCustomData.forEach((key) => {
|
|
106
|
+
delete query[key];
|
|
107
|
+
});
|
|
108
|
+
if (!isEmptyObject(query)) {
|
|
109
|
+
return import_ansis.default.white(
|
|
110
|
+
NEWLINE + "\u{1F5D2} Custom" + NEWLINE + JSON.stringify(query, null, 2)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
};
|
|
115
|
+
const formatData = (data) => {
|
|
116
|
+
if (!isEmptyObject(data)) {
|
|
117
|
+
return import_ansis.default.white(
|
|
118
|
+
NEWLINE + "\u{1F4E6} Result Data" + NEWLINE + JSON.stringify(data, null, 2)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
};
|
|
123
|
+
const formatDate = (instant) => {
|
|
124
|
+
const date = new Date(instant);
|
|
125
|
+
const hours = date.getHours().toString().padStart(2, "0");
|
|
126
|
+
const minutes = date.getMinutes().toString().padStart(2, "0");
|
|
127
|
+
const seconds = date.getSeconds().toString().padStart(2, "0");
|
|
128
|
+
const prettyDate = hours + ":" + minutes + ":" + seconds;
|
|
129
|
+
return import_ansis.default.gray(prettyDate);
|
|
130
|
+
};
|
|
131
|
+
const formatErrorProp = (errorPropValue) => {
|
|
132
|
+
const errorType = errorPropValue["type"] || "Error";
|
|
133
|
+
delete errorPropValue["message"];
|
|
134
|
+
delete errorPropValue["stack"];
|
|
135
|
+
delete errorPropValue["type"];
|
|
136
|
+
return import_ansis.default.redBright(
|
|
137
|
+
NEWLINE + NEWLINE + `\u{1F6A8} ${errorType} Info` + NEWLINE + NEWLINE + JSON.stringify(errorPropValue, null, 2) + NEWLINE
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
const formatLevel = (level) => {
|
|
141
|
+
const emoji = emojiLog[level];
|
|
142
|
+
const padding = isWideEmoji(emoji) ? "" : " ";
|
|
143
|
+
return emoji + padding;
|
|
144
|
+
};
|
|
145
|
+
const formatLoadTime = (elapsedTime) => {
|
|
146
|
+
const elapsed = parseInt(elapsedTime, 10);
|
|
147
|
+
const time = (0, import_pretty_ms.default)(elapsed);
|
|
148
|
+
return import_ansis.default.gray(time);
|
|
149
|
+
};
|
|
150
|
+
const formatMessage = (logData) => {
|
|
151
|
+
const { level, message } = logData;
|
|
152
|
+
const msg = formatMessageName(message);
|
|
153
|
+
let pretty;
|
|
154
|
+
if (level === "error") {
|
|
155
|
+
pretty = import_ansis.default.red(msg);
|
|
156
|
+
}
|
|
157
|
+
if (level === "trace") {
|
|
158
|
+
pretty = import_ansis.default.white(msg);
|
|
159
|
+
}
|
|
160
|
+
if (level === "warn") {
|
|
161
|
+
const orange = "#ffa500";
|
|
162
|
+
pretty = import_ansis.default.hex(orange)(msg);
|
|
163
|
+
}
|
|
164
|
+
if (level === "debug") {
|
|
165
|
+
pretty = import_ansis.default.yellow(msg);
|
|
166
|
+
}
|
|
167
|
+
if (level === "info" || level === "customlevel") {
|
|
168
|
+
pretty = import_ansis.default.green(msg);
|
|
169
|
+
}
|
|
170
|
+
if (level === "fatal") {
|
|
171
|
+
pretty = import_ansis.default.white.bgRed(msg);
|
|
172
|
+
}
|
|
173
|
+
return pretty;
|
|
174
|
+
};
|
|
175
|
+
const formatMethod = (method) => {
|
|
176
|
+
return method && import_ansis.default.white(method);
|
|
177
|
+
};
|
|
178
|
+
const formatRequestId = (requestId) => {
|
|
179
|
+
return requestId && import_ansis.default.cyan(requestId);
|
|
180
|
+
};
|
|
181
|
+
const formatNs = (ns) => {
|
|
182
|
+
return ns && import_ansis.default.cyan(ns);
|
|
183
|
+
};
|
|
184
|
+
const formatName = (name) => {
|
|
185
|
+
return name && import_ansis.default.blue(name);
|
|
186
|
+
};
|
|
187
|
+
const formatMessageName = (message) => {
|
|
188
|
+
if (message === void 0) {
|
|
189
|
+
return "";
|
|
190
|
+
}
|
|
191
|
+
if (message === "request") {
|
|
192
|
+
return "<--";
|
|
193
|
+
}
|
|
194
|
+
if (message === "response") {
|
|
195
|
+
return "-->";
|
|
196
|
+
}
|
|
197
|
+
return message;
|
|
198
|
+
};
|
|
199
|
+
const formatOperationName = (operationName) => {
|
|
200
|
+
return import_ansis.default.white(NEWLINE + "\u{1F3F7} " + operationName);
|
|
201
|
+
};
|
|
202
|
+
const formatQuery = (query) => {
|
|
203
|
+
if (!isEmptyObject(query)) {
|
|
204
|
+
return import_ansis.default.white(
|
|
205
|
+
NEWLINE + "\u{1F52D} Query" + NEWLINE + JSON.stringify(query, null, 2)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
};
|
|
210
|
+
const formatResponseCache = (responseCache) => {
|
|
211
|
+
if (!isEmptyObject(responseCache)) {
|
|
212
|
+
return import_ansis.default.white(
|
|
213
|
+
NEWLINE + "\u{1F4BE} Response Cache" + NEWLINE + JSON.stringify(responseCache, null, 2)
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return;
|
|
217
|
+
};
|
|
218
|
+
const formatStatusCode = (statusCode) => {
|
|
219
|
+
statusCode = statusCode || "xxx";
|
|
220
|
+
return import_ansis.default.white(statusCode);
|
|
221
|
+
};
|
|
222
|
+
const formatStack = (stack) => {
|
|
223
|
+
return import_ansis.default.redBright(
|
|
224
|
+
stack ? NEWLINE + "\u{1F95E} Error Stack" + NEWLINE + NEWLINE + stack + NEWLINE : ""
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
const formatTracing = (data) => {
|
|
228
|
+
if (!isEmptyObject(data)) {
|
|
229
|
+
return import_ansis.default.white(
|
|
230
|
+
NEWLINE + "\u23F0 Timing" + NEWLINE + JSON.stringify(data, null, 2)
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
};
|
|
235
|
+
const formatUrl = (url) => {
|
|
236
|
+
return import_ansis.default.white(url);
|
|
237
|
+
};
|
|
238
|
+
const formatUserAgent = (userAgent) => {
|
|
239
|
+
return import_ansis.default.gray(NEWLINE + "\u{1F575}\uFE0F\u200D\u2640\uFE0F " + userAgent);
|
|
240
|
+
};
|
|
241
|
+
const noEmpty = (value) => {
|
|
242
|
+
return !!value;
|
|
243
|
+
};
|
|
244
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
245
|
+
0 && (module.exports = {
|
|
246
|
+
NEWLINE,
|
|
247
|
+
emojiLog,
|
|
248
|
+
formatBundleSize,
|
|
249
|
+
formatCustom,
|
|
250
|
+
formatData,
|
|
251
|
+
formatDate,
|
|
252
|
+
formatErrorProp,
|
|
253
|
+
formatLevel,
|
|
254
|
+
formatLoadTime,
|
|
255
|
+
formatMessage,
|
|
256
|
+
formatMessageName,
|
|
257
|
+
formatMethod,
|
|
258
|
+
formatName,
|
|
259
|
+
formatNs,
|
|
260
|
+
formatOperationName,
|
|
261
|
+
formatQuery,
|
|
262
|
+
formatRequestId,
|
|
263
|
+
formatResponseCache,
|
|
264
|
+
formatStack,
|
|
265
|
+
formatStatusCode,
|
|
266
|
+
formatTracing,
|
|
267
|
+
formatUrl,
|
|
268
|
+
formatUserAgent,
|
|
269
|
+
ignoredCustomData,
|
|
270
|
+
isEmptyObject,
|
|
271
|
+
isObject,
|
|
272
|
+
isPinoLog,
|
|
273
|
+
isWideEmoji,
|
|
274
|
+
noEmpty
|
|
275
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/logFormatter/index.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,YAAY,oBACG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WA6L3D,CAAA"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var logFormatter_exports = {};
|
|
30
|
+
__export(logFormatter_exports, {
|
|
31
|
+
LogFormatter: () => LogFormatter
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(logFormatter_exports);
|
|
34
|
+
var import_fast_json_parse = __toESM(require("fast-json-parse"), 1);
|
|
35
|
+
var import_formatters = require("./formatters.js");
|
|
36
|
+
const LogFormatter = () => {
|
|
37
|
+
const parse = (inputData) => {
|
|
38
|
+
let logData;
|
|
39
|
+
if (typeof inputData === "string") {
|
|
40
|
+
const parsedData = (0, import_fast_json_parse.default)(inputData);
|
|
41
|
+
if (!parsedData.value || parsedData.err || !(0, import_formatters.isPinoLog)(parsedData.value)) {
|
|
42
|
+
return inputData + import_formatters.NEWLINE;
|
|
43
|
+
}
|
|
44
|
+
logData = parsedData.value;
|
|
45
|
+
} else if ((0, import_formatters.isObject)(inputData) && (0, import_formatters.isPinoLog)(inputData)) {
|
|
46
|
+
logData = inputData;
|
|
47
|
+
} else {
|
|
48
|
+
return inputData + import_formatters.NEWLINE;
|
|
49
|
+
}
|
|
50
|
+
if (!logData.level) {
|
|
51
|
+
return inputData + import_formatters.NEWLINE;
|
|
52
|
+
}
|
|
53
|
+
if (!logData.message) {
|
|
54
|
+
logData.message = logData.msg;
|
|
55
|
+
}
|
|
56
|
+
if (typeof logData.level === "number") {
|
|
57
|
+
convertLogNumber(logData);
|
|
58
|
+
}
|
|
59
|
+
return output(logData) + import_formatters.NEWLINE;
|
|
60
|
+
};
|
|
61
|
+
const convertLogNumber = (logData) => {
|
|
62
|
+
if (logData.level === 10) {
|
|
63
|
+
logData.level = "trace";
|
|
64
|
+
}
|
|
65
|
+
if (logData.level === 20) {
|
|
66
|
+
logData.level = "debug";
|
|
67
|
+
}
|
|
68
|
+
if (logData.level === 30) {
|
|
69
|
+
logData.level = "info";
|
|
70
|
+
}
|
|
71
|
+
if (logData.level === 40) {
|
|
72
|
+
logData.level = "warn";
|
|
73
|
+
}
|
|
74
|
+
if (logData.level === 50) {
|
|
75
|
+
logData.level = "error";
|
|
76
|
+
}
|
|
77
|
+
if (logData.level === 60) {
|
|
78
|
+
logData.level = "fatal";
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const output = (logData) => {
|
|
82
|
+
const output2 = [];
|
|
83
|
+
output2.push((0, import_formatters.formatDate)(logData.time || Date.now()));
|
|
84
|
+
output2.push((0, import_formatters.formatLevel)(logData.level));
|
|
85
|
+
output2.push((0, import_formatters.formatNs)(logData.ns));
|
|
86
|
+
output2.push((0, import_formatters.formatName)(logData.name));
|
|
87
|
+
output2.push((0, import_formatters.formatRequestId)(logData.requestId));
|
|
88
|
+
output2.push((0, import_formatters.formatMessage)(logData));
|
|
89
|
+
const req = logData.req;
|
|
90
|
+
const res = logData.res;
|
|
91
|
+
const { statusCode: responseStatusCode } = res || {};
|
|
92
|
+
const { method: requestMethod, url: requestUrl } = req || {};
|
|
93
|
+
const {
|
|
94
|
+
level,
|
|
95
|
+
message,
|
|
96
|
+
name,
|
|
97
|
+
ns,
|
|
98
|
+
err: logDataErr,
|
|
99
|
+
stack: logDataStack,
|
|
100
|
+
statusCode: logDataStatusCode,
|
|
101
|
+
elapsed,
|
|
102
|
+
responseTime: logDataResponseTime,
|
|
103
|
+
method: logDataMethod,
|
|
104
|
+
custom,
|
|
105
|
+
contentLength,
|
|
106
|
+
operationName,
|
|
107
|
+
query,
|
|
108
|
+
data: graphQLData,
|
|
109
|
+
responseCache,
|
|
110
|
+
tracing,
|
|
111
|
+
url: logDataUrl,
|
|
112
|
+
userAgent,
|
|
113
|
+
...rest
|
|
114
|
+
} = logData;
|
|
115
|
+
const statusCode = responseStatusCode || logDataStatusCode;
|
|
116
|
+
const responseTime = logDataResponseTime || elapsed;
|
|
117
|
+
const method = requestMethod || logDataMethod;
|
|
118
|
+
const url = requestUrl || logDataUrl;
|
|
119
|
+
const logDataErrStack = logDataErr && logDataErr.stack;
|
|
120
|
+
const stack = level === "fatal" || level === "error" ? logDataStack || logDataErr && logDataErrStack : null;
|
|
121
|
+
const err = (level === "fatal" || level === "error") && logDataErr && Object.keys(logDataErr).find((key) => key !== "stack") ? logDataErr : null;
|
|
122
|
+
if (!message) {
|
|
123
|
+
logData.message = "";
|
|
124
|
+
}
|
|
125
|
+
if (!level) {
|
|
126
|
+
logData.level = "customlevel";
|
|
127
|
+
}
|
|
128
|
+
if (!name) {
|
|
129
|
+
logData.name = "";
|
|
130
|
+
}
|
|
131
|
+
if (!ns) {
|
|
132
|
+
logData.ns = "";
|
|
133
|
+
}
|
|
134
|
+
if (method != null) {
|
|
135
|
+
output2.push((0, import_formatters.formatMethod)(method));
|
|
136
|
+
output2.push((0, import_formatters.formatStatusCode)(statusCode));
|
|
137
|
+
}
|
|
138
|
+
if (url != null) {
|
|
139
|
+
output2.push((0, import_formatters.formatUrl)(url));
|
|
140
|
+
}
|
|
141
|
+
if (contentLength != null) {
|
|
142
|
+
output2.push((0, import_formatters.formatBundleSize)(contentLength));
|
|
143
|
+
}
|
|
144
|
+
if (custom) {
|
|
145
|
+
output2.push((0, import_formatters.formatCustom)(custom));
|
|
146
|
+
}
|
|
147
|
+
if (responseTime != null) {
|
|
148
|
+
output2.push((0, import_formatters.formatLoadTime)(responseTime));
|
|
149
|
+
}
|
|
150
|
+
if (userAgent != null) {
|
|
151
|
+
output2.push((0, import_formatters.formatUserAgent)(userAgent));
|
|
152
|
+
}
|
|
153
|
+
if (operationName != null) {
|
|
154
|
+
output2.push((0, import_formatters.formatOperationName)(operationName));
|
|
155
|
+
}
|
|
156
|
+
if (query != null) {
|
|
157
|
+
output2.push((0, import_formatters.formatQuery)(query));
|
|
158
|
+
}
|
|
159
|
+
if (graphQLData != null) {
|
|
160
|
+
output2.push((0, import_formatters.formatData)(graphQLData));
|
|
161
|
+
}
|
|
162
|
+
if (responseCache != null) {
|
|
163
|
+
output2.push((0, import_formatters.formatResponseCache)(responseCache));
|
|
164
|
+
}
|
|
165
|
+
if (tracing != null) {
|
|
166
|
+
output2.push((0, import_formatters.formatTracing)(tracing));
|
|
167
|
+
}
|
|
168
|
+
if (err != null) {
|
|
169
|
+
output2.push((0, import_formatters.formatErrorProp)(err));
|
|
170
|
+
}
|
|
171
|
+
if (stack != null) {
|
|
172
|
+
output2.push((0, import_formatters.formatStack)(stack));
|
|
173
|
+
}
|
|
174
|
+
if (rest) {
|
|
175
|
+
output2.push((0, import_formatters.formatCustom)(rest));
|
|
176
|
+
}
|
|
177
|
+
return output2.filter(import_formatters.noEmpty).join(" ");
|
|
178
|
+
};
|
|
179
|
+
return parse;
|
|
180
|
+
};
|
|
181
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
182
|
+
0 && (module.exports = {
|
|
183
|
+
LogFormatter
|
|
184
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Options as FastGlobOptions } from 'fast-glob';
|
|
2
|
+
import type { FastifyInstance } from 'fastify';
|
|
3
|
+
import type { Server } from '../createServerHelpers.js';
|
|
4
|
+
export interface CedarFastifyAPIOptions {
|
|
5
|
+
redwood: {
|
|
6
|
+
apiRootPath?: string;
|
|
7
|
+
fastGlobOptions?: FastGlobOptions;
|
|
8
|
+
discoverFunctionsGlob?: string | string[];
|
|
9
|
+
loadUserConfig?: boolean;
|
|
10
|
+
configureServer?: (server: Server) => void | Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function cedarFastifyAPI(fastify: FastifyInstance, opts: CedarFastifyAPIOptions): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/plugins/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAKvD,MAAM,WAAW,sBAAsB;IAErC,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,eAAe,CAAC,EAAE,eAAe,CAAA;QACjC,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACzC,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;KAI3D,CAAA;CACF;AAED,wBAAsB,eAAe,CACnC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,sBAAsB,iBA4C7B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var api_exports = {};
|
|
30
|
+
__export(api_exports, {
|
|
31
|
+
cedarFastifyAPI: () => cedarFastifyAPI
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(api_exports);
|
|
34
|
+
var import_url_data = __toESM(require("@fastify/url-data"), 1);
|
|
35
|
+
var import_fastify_raw_body = __toESM(require("fastify-raw-body"), 1);
|
|
36
|
+
var import_store = require("@cedarjs/context/dist/store");
|
|
37
|
+
var import_helpers = require("@cedarjs/fastify-web/dist/helpers.js");
|
|
38
|
+
var import_fastify = require("../fastify.js");
|
|
39
|
+
var import_lambdaLoader = require("./lambdaLoader.js");
|
|
40
|
+
async function cedarFastifyAPI(fastify, opts) {
|
|
41
|
+
const cedarOptions = opts.redwood ?? {};
|
|
42
|
+
cedarOptions.apiRootPath ??= "/";
|
|
43
|
+
cedarOptions.apiRootPath = (0, import_helpers.coerceRootPath)(cedarOptions.apiRootPath);
|
|
44
|
+
cedarOptions.fastGlobOptions ??= {};
|
|
45
|
+
cedarOptions.loadUserConfig ??= false;
|
|
46
|
+
fastify.register(import_url_data.default);
|
|
47
|
+
await fastify.register(import_fastify_raw_body.default);
|
|
48
|
+
fastify.addHook("onRequest", (_req, _reply, done) => {
|
|
49
|
+
(0, import_store.getAsyncStoreInstance)().run(/* @__PURE__ */ new Map(), done);
|
|
50
|
+
});
|
|
51
|
+
fastify.addContentTypeParser(
|
|
52
|
+
["application/x-www-form-urlencoded", "multipart/form-data"],
|
|
53
|
+
{ parseAs: "string" },
|
|
54
|
+
fastify.defaultTextParser
|
|
55
|
+
);
|
|
56
|
+
if (cedarOptions.loadUserConfig) {
|
|
57
|
+
const { configureFastify } = await (0, import_fastify.loadFastifyConfig)();
|
|
58
|
+
if (configureFastify) {
|
|
59
|
+
await configureFastify(fastify, {
|
|
60
|
+
side: "api",
|
|
61
|
+
apiRootPath: cedarOptions.apiRootPath
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (cedarOptions.configureServer) {
|
|
66
|
+
await cedarOptions.configureServer(fastify);
|
|
67
|
+
}
|
|
68
|
+
fastify.all(`${cedarOptions.apiRootPath}:routeName`, import_lambdaLoader.lambdaRequestHandler);
|
|
69
|
+
fastify.all(`${cedarOptions.apiRootPath}:routeName/*`, import_lambdaLoader.lambdaRequestHandler);
|
|
70
|
+
await (0, import_lambdaLoader.loadFunctionsFromDist)({
|
|
71
|
+
fastGlobOptions: cedarOptions.fastGlobOptions,
|
|
72
|
+
discoverFunctionsGlob: cedarOptions.discoverFunctionsGlob
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
cedarFastifyAPI
|
|
78
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FastifyInstance } from 'fastify';
|
|
2
|
+
import type { GraphQLYogaOptions } from '@cedarjs/graphql-server';
|
|
3
|
+
export interface RedwoodFastifyGraphQLOptions {
|
|
4
|
+
redwood: {
|
|
5
|
+
apiRootPath?: string;
|
|
6
|
+
graphql?: GraphQLYogaOptions;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function redwoodFastifyGraphQLServer(fastify: FastifyInstance, options: RedwoodFastifyGraphQLOptions): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/plugins/graphql.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,SAAS,CAAA;AAOhB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAKjE,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,OAAO,CAAC,EAAE,kBAAkB,CAAA;KAC7B,CAAA;CACF;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,4BAA4B,iBAuHtC"}
|