@cedarjs/api-server 9.0.0-canary.1784 → 9.0.0-canary.3124

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.
Files changed (127) hide show
  1. package/README.md +0 -1
  2. package/dist/apiCLIConfig.d.ts.map +1 -1
  3. package/dist/apiCLIConfig.js +1 -1
  4. package/dist/apiCLIConfigHandler.d.ts.map +1 -1
  5. package/dist/apiCLIConfigHandler.js +5 -0
  6. package/dist/bin.js +316 -98
  7. package/dist/bothCLIConfig.d.ts.map +1 -1
  8. package/dist/bothCLIConfig.js +2 -2
  9. package/dist/bothCLIConfigHandler.d.ts.map +1 -1
  10. package/dist/bothCLIConfigHandler.js +8 -2
  11. package/dist/cliHelpers.d.ts +22 -4
  12. package/dist/cliHelpers.d.ts.map +1 -1
  13. package/dist/cliHelpers.js +43 -11
  14. package/dist/createServer.d.ts +19 -3
  15. package/dist/createServer.d.ts.map +1 -1
  16. package/dist/createServer.js +18 -11
  17. package/dist/createServerHelpers.d.ts +15 -2
  18. package/dist/createServerHelpers.d.ts.map +1 -1
  19. package/dist/createServerHelpers.js +14 -4
  20. package/dist/fastify.d.ts.map +1 -1
  21. package/dist/fastify.js +5 -0
  22. package/dist/logFormatter/formatters.d.ts +1 -1
  23. package/dist/logFormatter/formatters.d.ts.map +1 -1
  24. package/dist/logFormatter/index.d.ts.map +1 -1
  25. package/dist/plugins/api.d.ts +4 -5
  26. package/dist/plugins/api.d.ts.map +1 -1
  27. package/dist/plugins/api.js +15 -15
  28. package/dist/plugins/graphql.d.ts +20 -3
  29. package/dist/plugins/graphql.d.ts.map +1 -1
  30. package/dist/plugins/graphql.js +69 -28
  31. package/dist/plugins/lambdaLoader.d.ts +16 -6
  32. package/dist/plugins/lambdaLoader.d.ts.map +1 -1
  33. package/dist/plugins/lambdaLoader.js +73 -10
  34. package/dist/requestHandlers/awsLambdaFastify.d.ts.map +1 -1
  35. package/dist/requestHandlers/awsLambdaFastify.js +16 -4
  36. package/dist/serverFile.d.ts +23 -0
  37. package/dist/serverFile.d.ts.map +1 -0
  38. package/dist/serverFile.js +35 -0
  39. package/dist/types.d.ts +4 -4
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/utils.d.ts +0 -3
  42. package/dist/utils.d.ts.map +1 -1
  43. package/dist/utils.js +0 -20
  44. package/package.json +56 -72
  45. package/LICENSE +0 -21
  46. package/dist/buildManager.d.ts +0 -15
  47. package/dist/buildManager.d.ts.map +0 -1
  48. package/dist/buildManager.js +0 -50
  49. package/dist/cjs/apiCLIConfig.d.ts +0 -6
  50. package/dist/cjs/apiCLIConfig.d.ts.map +0 -1
  51. package/dist/cjs/apiCLIConfig.js +0 -71
  52. package/dist/cjs/apiCLIConfigHandler.d.ts +0 -3
  53. package/dist/cjs/apiCLIConfigHandler.d.ts.map +0 -1
  54. package/dist/cjs/apiCLIConfigHandler.js +0 -67
  55. package/dist/cjs/bin.d.ts +0 -2
  56. package/dist/cjs/bin.d.ts.map +0 -1
  57. package/dist/cjs/bin.js +0 -896
  58. package/dist/cjs/bothCLIConfig.d.ts +0 -6
  59. package/dist/cjs/bothCLIConfig.d.ts.map +0 -1
  60. package/dist/cjs/bothCLIConfig.js +0 -76
  61. package/dist/cjs/bothCLIConfigHandler.d.ts +0 -3
  62. package/dist/cjs/bothCLIConfigHandler.d.ts.map +0 -1
  63. package/dist/cjs/bothCLIConfigHandler.js +0 -107
  64. package/dist/cjs/buildManager.d.ts +0 -15
  65. package/dist/cjs/buildManager.d.ts.map +0 -1
  66. package/dist/cjs/buildManager.js +0 -74
  67. package/dist/cjs/cliHelpers.d.ts +0 -5
  68. package/dist/cjs/cliHelpers.d.ts.map +0 -1
  69. package/dist/cjs/cliHelpers.js +0 -52
  70. package/dist/cjs/createServer.d.ts +0 -30
  71. package/dist/cjs/createServer.d.ts.map +0 -1
  72. package/dist/cjs/createServer.js +0 -144
  73. package/dist/cjs/createServerHelpers.d.ts +0 -38
  74. package/dist/cjs/createServerHelpers.d.ts.map +0 -1
  75. package/dist/cjs/createServerHelpers.js +0 -112
  76. package/dist/cjs/fastify.d.ts +0 -13
  77. package/dist/cjs/fastify.d.ts.map +0 -1
  78. package/dist/cjs/fastify.js +0 -91
  79. package/dist/cjs/logFormatter/ambient.d.js +0 -1
  80. package/dist/cjs/logFormatter/bin.d.ts +0 -2
  81. package/dist/cjs/logFormatter/bin.d.ts.map +0 -1
  82. package/dist/cjs/logFormatter/bin.js +0 -369
  83. package/dist/cjs/logFormatter/formatters.d.ts +0 -30
  84. package/dist/cjs/logFormatter/formatters.d.ts.map +0 -1
  85. package/dist/cjs/logFormatter/formatters.js +0 -275
  86. package/dist/cjs/logFormatter/index.d.ts +0 -2
  87. package/dist/cjs/logFormatter/index.d.ts.map +0 -1
  88. package/dist/cjs/logFormatter/index.js +0 -184
  89. package/dist/cjs/package.json +0 -1
  90. package/dist/cjs/plugins/api.d.ts +0 -14
  91. package/dist/cjs/plugins/api.d.ts.map +0 -1
  92. package/dist/cjs/plugins/api.js +0 -78
  93. package/dist/cjs/plugins/graphql.d.ts +0 -10
  94. package/dist/cjs/plugins/graphql.d.ts.map +0 -1
  95. package/dist/cjs/plugins/graphql.js +0 -109
  96. package/dist/cjs/plugins/lambdaLoader.d.ts +0 -24
  97. package/dist/cjs/plugins/lambdaLoader.d.ts.map +0 -1
  98. package/dist/cjs/plugins/lambdaLoader.js +0 -134
  99. package/dist/cjs/requestHandlers/awsLambdaFastify.d.ts +0 -5
  100. package/dist/cjs/requestHandlers/awsLambdaFastify.d.ts.map +0 -1
  101. package/dist/cjs/requestHandlers/awsLambdaFastify.js +0 -103
  102. package/dist/cjs/requestHandlers/utils.d.ts +0 -26
  103. package/dist/cjs/requestHandlers/utils.d.ts.map +0 -1
  104. package/dist/cjs/requestHandlers/utils.js +0 -55
  105. package/dist/cjs/serverManager.d.ts +0 -8
  106. package/dist/cjs/serverManager.d.ts.map +0 -1
  107. package/dist/cjs/serverManager.js +0 -137
  108. package/dist/cjs/types.d.ts +0 -19
  109. package/dist/cjs/types.d.ts.map +0 -1
  110. package/dist/cjs/utils.d.ts +0 -6
  111. package/dist/cjs/utils.d.ts.map +0 -1
  112. package/dist/cjs/utils.js +0 -58
  113. package/dist/cjs/watch.d.ts +0 -10
  114. package/dist/cjs/watch.d.ts.map +0 -1
  115. package/dist/cjs/watch.js +0 -394
  116. package/dist/cjs/watchPaths.d.ts +0 -3
  117. package/dist/cjs/watchPaths.d.ts.map +0 -1
  118. package/dist/cjs/watchPaths.js +0 -140
  119. package/dist/serverManager.d.ts +0 -8
  120. package/dist/serverManager.d.ts.map +0 -1
  121. package/dist/serverManager.js +0 -102
  122. package/dist/watch.d.ts +0 -10
  123. package/dist/watch.d.ts.map +0 -1
  124. package/dist/watch.js +0 -370
  125. package/dist/watchPaths.d.ts +0 -3
  126. package/dist/watchPaths.d.ts.map +0 -1
  127. package/dist/watchPaths.js +0 -109
@@ -1,275 +0,0 @@
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
- });
@@ -1,2 +0,0 @@
1
- export declare const LogFormatter: () => (inputData: string | Record<string, unknown>) => string;
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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,WA0L3D,CAAA"}
@@ -1,184 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- {"type":"commonjs"}
@@ -1,14 +0,0 @@
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 RedwoodFastifyAPIOptions {
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 redwoodFastifyAPI(fastify: FastifyInstance, opts: RedwoodFastifyAPIOptions): Promise<void>;
14
- //# sourceMappingURL=api.d.ts.map
@@ -1 +0,0 @@
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,wBAAwB;IACvC,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;KAC3D,CAAA;CACF;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,iBA4C/B"}
@@ -1,78 +0,0 @@
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
- redwoodFastifyAPI: () => redwoodFastifyAPI
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 redwoodFastifyAPI(fastify, opts) {
41
- const redwoodOptions = opts.redwood ?? {};
42
- redwoodOptions.apiRootPath ??= "/";
43
- redwoodOptions.apiRootPath = (0, import_helpers.coerceRootPath)(redwoodOptions.apiRootPath);
44
- redwoodOptions.fastGlobOptions ??= {};
45
- redwoodOptions.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 (redwoodOptions.loadUserConfig) {
57
- const { configureFastify } = await (0, import_fastify.loadFastifyConfig)();
58
- if (configureFastify) {
59
- await configureFastify(fastify, {
60
- side: "api",
61
- apiRootPath: redwoodOptions.apiRootPath
62
- });
63
- }
64
- }
65
- if (redwoodOptions.configureServer) {
66
- await redwoodOptions.configureServer(fastify);
67
- }
68
- fastify.all(`${redwoodOptions.apiRootPath}:routeName`, import_lambdaLoader.lambdaRequestHandler);
69
- fastify.all(`${redwoodOptions.apiRootPath}:routeName/*`, import_lambdaLoader.lambdaRequestHandler);
70
- await (0, import_lambdaLoader.loadFunctionsFromDist)({
71
- fastGlobOptions: redwoodOptions.fastGlobOptions,
72
- discoverFunctionsGlob: redwoodOptions.discoverFunctionsGlob
73
- });
74
- }
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
77
- redwoodFastifyAPI
78
- });
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/plugins/graphql.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,SAAS,CAAA;AAM3D,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,iBA8FtC"}
@@ -1,109 +0,0 @@
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 graphql_exports = {};
30
- __export(graphql_exports, {
31
- redwoodFastifyGraphQLServer: () => redwoodFastifyGraphQLServer
32
- });
33
- module.exports = __toCommonJS(graphql_exports);
34
- var import_multipart = __toESM(require("@fastify/multipart"), 1);
35
- var import_url_data = __toESM(require("@fastify/url-data"), 1);
36
- var import_fast_glob = __toESM(require("fast-glob"), 1);
37
- var import_store = require("@cedarjs/context/dist/store");
38
- var import_helpers = require("@cedarjs/fastify-web/dist/helpers.js");
39
- var import_graphql_server = require("@cedarjs/graphql-server");
40
- var import_project_config = require("@cedarjs/project-config");
41
- var import_awsLambdaFastify = require("../requestHandlers/awsLambdaFastify.js");
42
- async function redwoodFastifyGraphQLServer(fastify, options) {
43
- const redwoodOptions = options.redwood ?? {};
44
- redwoodOptions.apiRootPath ??= "/";
45
- redwoodOptions.apiRootPath = (0, import_helpers.coerceRootPath)(redwoodOptions.apiRootPath);
46
- fastify.register(import_url_data.default);
47
- fastify.register(import_multipart.default);
48
- const method = ["GET", "POST", "OPTIONS"];
49
- fastify.addHook("onRequest", (_req, _reply, done) => {
50
- (0, import_store.getAsyncStoreInstance)().run(/* @__PURE__ */ new Map(), done);
51
- });
52
- try {
53
- if (!redwoodOptions.graphql) {
54
- const [graphqlFunctionPath] = await (0, import_fast_glob.default)("dist/functions/graphql.{ts,js}", {
55
- cwd: (0, import_project_config.getPaths)().api.base,
56
- absolute: true
57
- });
58
- const filePath = `file://${graphqlFunctionPath}`;
59
- const { __rw_graphqlOptions } = await import(filePath);
60
- if (!__rw_graphqlOptions) {
61
- return;
62
- }
63
- redwoodOptions.graphql = __rw_graphqlOptions;
64
- }
65
- const graphqlOptions = redwoodOptions.graphql;
66
- if (graphqlOptions?.realtime) {
67
- const { useCedarRealtime } = await import("@cedarjs/realtime");
68
- const originalExtraPlugins = graphqlOptions.extraPlugins ?? [];
69
- originalExtraPlugins.push(useCedarRealtime(graphqlOptions.realtime));
70
- graphqlOptions.extraPlugins = originalExtraPlugins;
71
- if (graphqlOptions.realtime.subscriptions) {
72
- method.push("PUT");
73
- }
74
- }
75
- const { yoga } = (0, import_graphql_server.createGraphQLYoga)(graphqlOptions);
76
- const graphqlEndpoint = trimSlashes(yoga.graphqlEndpoint);
77
- const routePaths = ["", "/health", "/readiness", "/stream"];
78
- for (const routePath of routePaths) {
79
- fastify.route({
80
- url: `${redwoodOptions.apiRootPath}${graphqlEndpoint}${routePath}`,
81
- method,
82
- handler: (req, reply) => yoga.handleNodeRequestAndResponse(req, reply, {
83
- req,
84
- reply,
85
- event: (0, import_awsLambdaFastify.lambdaEventForFastifyRequest)(req)
86
- })
87
- });
88
- }
89
- fastify.addHook("onReady", (done) => {
90
- console.info(`GraphQL Yoga Server endpoint at ${graphqlEndpoint}`);
91
- console.info(
92
- `GraphQL Yoga Server Health Check endpoint at ${graphqlEndpoint}/health`
93
- );
94
- console.info(
95
- `GraphQL Yoga Server Readiness endpoint at ${graphqlEndpoint}/readiness`
96
- );
97
- done();
98
- });
99
- } catch (e) {
100
- console.log(e);
101
- }
102
- }
103
- function trimSlashes(path) {
104
- return path.replace(/^\/|\/$/g, "");
105
- }
106
- // Annotate the CommonJS export names for ESM import in node:
107
- 0 && (module.exports = {
108
- redwoodFastifyGraphQLServer
109
- });