@allthings/cloud-toolkit 4.3.0 → 4.3.1-beta.1

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 (3) hide show
  1. package/dist/lib.cjs.js +1158 -21
  2. package/dist/lib.esm.js +1124 -21
  3. package/package.json +1 -1
package/dist/lib.cjs.js CHANGED
@@ -1,23 +1,1160 @@
1
1
  'use strict';
2
2
 
3
- var __importDefault = (undefined && undefined.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.Logger = exports.logger = exports.sqs = exports.ses = exports.parameterStore = exports.lambda = exports.dynamodb = exports.DEFAULT_SES_CLIENT_CONFIG = exports.DEFAULT_PARAMETER_STORE_CLIENT_CONFIG = exports.ServerError = exports.ClientError = exports.alagarr = void 0;
8
- var alagarr_1 = require("./alagarr");
9
- Object.defineProperty(exports, "alagarr", { enumerable: true, get: function () { return __importDefault(alagarr_1).default; } });
10
- Object.defineProperty(exports, "ClientError", { enumerable: true, get: function () { return alagarr_1.ClientError; } });
11
- Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return alagarr_1.ServerError; } });
12
- var aws_1 = require("./aws");
13
- Object.defineProperty(exports, "DEFAULT_PARAMETER_STORE_CLIENT_CONFIG", { enumerable: true, get: function () { return aws_1.DEFAULT_PARAMETER_STORE_CLIENT_CONFIG; } });
14
- Object.defineProperty(exports, "DEFAULT_SES_CLIENT_CONFIG", { enumerable: true, get: function () { return aws_1.DEFAULT_SES_CLIENT_CONFIG; } });
15
- Object.defineProperty(exports, "dynamodb", { enumerable: true, get: function () { return aws_1.dynamodb; } });
16
- Object.defineProperty(exports, "lambda", { enumerable: true, get: function () { return aws_1.lambda; } });
17
- Object.defineProperty(exports, "parameterStore", { enumerable: true, get: function () { return aws_1.parameterStore; } });
18
- Object.defineProperty(exports, "ses", { enumerable: true, get: function () { return aws_1.ses; } });
19
- Object.defineProperty(exports, "sqs", { enumerable: true, get: function () { return aws_1.sqs; } });
20
- var logger_1 = require("./logger/logger");
21
- Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return __importDefault(logger_1).default; } });
22
- var winston_1 = require("winston");
23
- Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return winston_1.Logger; } });
3
+ var querystring = require('querystring');
4
+ var zlib = require('zlib');
5
+ var crypto = require('crypto');
6
+ var clientDynamodb = require('@aws-sdk/client-dynamodb');
7
+ var libDynamodb = require('@aws-sdk/lib-dynamodb');
8
+ var Bottleneck = require('bottleneck');
9
+ var clientLambda = require('@aws-sdk/client-lambda');
10
+ var clientSsm = require('@aws-sdk/client-ssm');
11
+ var clientSesv2 = require('@aws-sdk/client-sesv2');
12
+ var nodemailer = require('nodemailer');
13
+ var clientSqs = require('@aws-sdk/client-sqs');
14
+ var winston = require('winston');
15
+
16
+ function _interopNamespaceDefault(e) {
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
28
+ }
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
32
+
33
+ var querystring__namespace = /*#__PURE__*/_interopNamespaceDefault(querystring);
34
+ var zlib__namespace = /*#__PURE__*/_interopNamespaceDefault(zlib);
35
+ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
36
+
37
+ const defaultErrorHandler = (request, response, error) => {
38
+ const { requestId } = request.requestContext;
39
+ const errorName = error.name && typeof error.name === 'string'
40
+ ? error.name.replace(/([A-Z])([A-Z])([a-z])|([a-z])([A-Z])/g, '$1$4 $2$3$5')
41
+ : 'Error';
42
+ const errorMessage = error.message || '';
43
+ const statusCode = error.statusCode ? ` ${error.statusCode}` : '';
44
+ return error.name === 'ClientError' ||
45
+ (error.statusCode >= 400 && error.statusCode < 500)
46
+ ? response.respondTo({
47
+ html: `<html><body><strong>${errorName}${statusCode}</strong>: ${errorMessage}<br/>Request ID: ${requestId}</body></html>`,
48
+ json: { error: error.name, message: errorMessage, requestId },
49
+ }, error.statusCode || 400)
50
+ : response.respondTo({
51
+ html: `<html><body>An internal server error occurred.<br/>Request ID: ${requestId}</body></html>`,
52
+ json: {
53
+ error: 'Internal server error',
54
+ message: 'An internal server error occurred',
55
+ requestId,
56
+ },
57
+ }, 500);
58
+ };
59
+
60
+ class ClientError extends Error {
61
+ name = 'ClientError';
62
+ statusCode = 400;
63
+ constructor(message, name, statusCode = 400) {
64
+ super(String(message));
65
+ this.name = name || this.name;
66
+ this.statusCode = statusCode;
67
+ }
68
+ }
69
+
70
+ class ServerError extends Error {
71
+ name = 'ServerError';
72
+ statusCode = 500;
73
+ constructor(message, name, statusCode = 500) {
74
+ super(String(message));
75
+ this.name = name || this.name;
76
+ this.statusCode = statusCode;
77
+ }
78
+ }
79
+
80
+ const applyMiddleware = async (middlewareList, initialData, ...arguments_) => middlewareList.reduce(async (applied, middleware) => middleware(await applied, ...arguments_), Promise.resolve(initialData));
81
+
82
+ const decodeBase64 = (encoded) => {
83
+ const bodyBuffer = Buffer.from(encoded, 'base64');
84
+ return bodyBuffer.toString('utf8');
85
+ };
86
+ const decodeBase64Body = (request) => request.isBase64Encoded && typeof request.body === 'string'
87
+ ? {
88
+ ...request,
89
+ body: decodeBase64(request.body),
90
+ }
91
+ : request;
92
+
93
+ const parseCookiePair = (pair) => {
94
+ const indexOfEqualCharacter = pair.indexOf('=');
95
+ const looksLikeKeyValue = indexOfEqualCharacter !== -1;
96
+ const key = looksLikeKeyValue &&
97
+ pair.slice(0, Math.max(0, indexOfEqualCharacter)).trim();
98
+ const value = looksLikeKeyValue &&
99
+ pair.substr(indexOfEqualCharacter + 1, pair.length).trim();
100
+ const cleanValue = value && '"' === value[0] ? value.slice(1, -1) : value;
101
+ return key ? { [key]: cleanValue ? decodeURIComponent(cleanValue) : '' } : {};
102
+ };
103
+ const parseCookieHeader = (cookieHeader) => {
104
+ const pairs = cookieHeader.split(/; */);
105
+ return pairs.reduce((parsedCookies, pair) => ({ ...parsedCookies, ...parseCookiePair(pair) }), {});
106
+ };
107
+ const cookies = (request) => ({
108
+ ...request,
109
+ cookies: parseCookieHeader(request.headers?.cookie || ''),
110
+ });
111
+
112
+ const setHostname = (request) => ({
113
+ ...request,
114
+ hostname: request.headers?.host || undefined,
115
+ });
116
+
117
+ const parseJson = (stringified) => {
118
+ try {
119
+ return JSON.parse(stringified);
120
+ }
121
+ catch {
122
+ return {};
123
+ }
124
+ };
125
+ const parseJsonBody = (request) => {
126
+ const { headers, body } = request;
127
+ return headers['content-type']?.split(';').shift() === 'application/json' &&
128
+ typeof body === 'string'
129
+ ? { ...request, body: parseJson(body) }
130
+ : request;
131
+ };
132
+
133
+ const state = new Map([['invocationCount', 0]]);
134
+ const meta = (request) => {
135
+ const invocationCount = Number(state.get('invocationCount'));
136
+ return {
137
+ ...request,
138
+ meta: {
139
+ ...request.meta,
140
+ coldStart: !invocationCount,
141
+ invocationCount: state
142
+ .set('invocationCount', invocationCount + 1)
143
+ .get('invocationCount'),
144
+ },
145
+ };
146
+ };
147
+
148
+ const normalizeHeaders = ({ headers = {}, ...request }) => ({
149
+ ...request,
150
+ headers: Object.keys(headers).reduce((normalizedHeaders, key) => {
151
+ const normalizedHeaderKey = key.toLowerCase();
152
+ return request.provider === 'aws' &&
153
+ Reflect.has(normalizedHeaders, normalizedHeaderKey) &&
154
+ normalizedHeaderKey === 'content-type' &&
155
+ headers[key] === 'application/json'
156
+ ? normalizedHeaders
157
+ : {
158
+ ...normalizedHeaders,
159
+ [normalizedHeaderKey]: headers[key],
160
+ };
161
+ }, {}),
162
+ });
163
+
164
+ const normalizeProgrammingModel = (request) => ({
165
+ ...request,
166
+ method: request.httpMethod ??
167
+ request.requestContext?.http?.method ??
168
+ '',
169
+ path: request.path ??
170
+ request.requestContext?.http?.path ??
171
+ '',
172
+ provider: 'aws',
173
+ query: request.queryStringParameters || {},
174
+ source: request.requestContext ? 'api-gateway' : request.source,
175
+ });
176
+
177
+ const addTimestamp = (request) => ({
178
+ ...request,
179
+ timestamp: Date.now(),
180
+ });
181
+
182
+ const parseUrlEncodedBody = (request) => {
183
+ const { headers, body } = request;
184
+ return headers['content-type']?.split(';').shift() ===
185
+ 'application/x-www-form-urlencoded' && typeof body === 'string'
186
+ ? { ...request, body: querystring__namespace.parse(body) }
187
+ : request;
188
+ };
189
+
190
+ var makeRequest = async (event, context, options = {}) => applyMiddleware([
191
+ addTimestamp,
192
+ normalizeProgrammingModel,
193
+ normalizeHeaders,
194
+ decodeBase64Body,
195
+ cookies,
196
+ parseUrlEncodedBody,
197
+ parseJsonBody,
198
+ setHostname,
199
+ meta,
200
+ ...(options.requestMiddleware || []),
201
+ ], Object.freeze({
202
+ ...event,
203
+ context,
204
+ }), options);
205
+
206
+ const setHeader = (response, responseData, key, value) => {
207
+ Object.assign(responseData.headers, { [key]: value });
208
+ return response;
209
+ };
210
+
211
+ const makeResponseObject = (responseData, body = '', statusCode = 200, { headers = {}, ...options } = {}, contentType) => Object.freeze({
212
+ ...responseData,
213
+ body: body || '',
214
+ headers: {
215
+ ...responseData?.headers,
216
+ 'content-type': contentType,
217
+ ...headers,
218
+ },
219
+ statusCode,
220
+ ...options,
221
+ });
222
+
223
+ const html = (responseData, _, body, statusCode, options) => makeResponseObject(responseData, body, statusCode, options, 'text/html');
224
+
225
+ const stringifyIfNotStringifiedJson = (data) => {
226
+ const maybeTrimmedDataString = typeof data === 'string' ? data.trim() : data;
227
+ const isStringifiedJson = typeof data === 'string' &&
228
+ ['{', '"'].includes(maybeTrimmedDataString[0]) &&
229
+ ['}', '"'].includes(maybeTrimmedDataString.at(-1));
230
+ return isStringifiedJson ? maybeTrimmedDataString : JSON.stringify(data);
231
+ };
232
+ const json = (responseData, _, body, statusCode, options) => makeResponseObject(responseData, stringifyIfNotStringifiedJson(body), statusCode, options, 'application/json');
233
+
234
+ const COMPRESSIBLE = [
235
+ 'application/activity+json',
236
+ 'application/alto-costmap+json',
237
+ 'application/alto-costmapfilter+json',
238
+ 'application/alto-directory+json',
239
+ 'application/alto-endpointcost+json',
240
+ 'application/alto-endpointcostparams+json',
241
+ 'application/alto-endpointprop+json',
242
+ 'application/alto-endpointpropparams+json',
243
+ 'application/alto-error+json',
244
+ 'application/alto-networkmap+json',
245
+ 'application/alto-networkmapfilter+json',
246
+ 'application/atom+xml',
247
+ 'application/calendar+json',
248
+ 'application/coap-group+json',
249
+ 'application/csvm+json',
250
+ 'application/dart',
251
+ 'application/dicom+json',
252
+ 'application/ecmascript',
253
+ 'application/fhir+json',
254
+ 'application/fido.trusted-apps+json',
255
+ 'application/geo+json',
256
+ 'application/javascript',
257
+ 'application/jf2feed+json',
258
+ 'application/jose+json',
259
+ 'application/jrd+json',
260
+ 'application/json',
261
+ 'application/json-patch+json',
262
+ 'application/jsonml+json',
263
+ 'application/jwk+json',
264
+ 'application/jwk-set+json',
265
+ 'application/ld+json',
266
+ 'application/manifest+json',
267
+ 'application/merge-patch+json',
268
+ 'application/mud+json',
269
+ 'application/postscript',
270
+ 'application/ppsp-tracker+json',
271
+ 'application/problem+json',
272
+ 'application/raml+yaml',
273
+ 'application/rdap+json',
274
+ 'application/rdf+xml',
275
+ 'application/reputon+json',
276
+ 'application/rss+xml',
277
+ 'application/rtf',
278
+ 'application/scim+json',
279
+ 'application/soap+xml',
280
+ 'application/tar',
281
+ 'application/vcard+json',
282
+ 'application/vnd.amadeus+json',
283
+ 'application/vnd.api+json',
284
+ 'application/vnd.apothekende.reservation+json',
285
+ 'application/vnd.avalon+json',
286
+ 'application/vnd.bbf.usp.msg+json',
287
+ 'application/vnd.bekitzur-stech+json',
288
+ 'application/vnd.capasystems-pg+json',
289
+ 'application/vnd.collection+json',
290
+ 'application/vnd.collection.doc+json',
291
+ 'application/vnd.collection.next+json',
292
+ 'application/vnd.coreos.ignition+json',
293
+ 'application/vnd.dart',
294
+ 'application/vnd.datapackage+json',
295
+ 'application/vnd.dataresource+json',
296
+ 'application/vnd.document+json',
297
+ 'application/vnd.drive+json',
298
+ 'application/vnd.geo+json',
299
+ 'application/vnd.google-earth.kml+xml',
300
+ 'application/vnd.hal+json',
301
+ 'application/vnd.hc+json',
302
+ 'application/vnd.heroku+json',
303
+ 'application/vnd.hyper+json',
304
+ 'application/vnd.hyper-item+json',
305
+ 'application/vnd.hyperdrive+json',
306
+ 'application/vnd.ims.lis.v2.result+json',
307
+ 'application/vnd.ims.lti.v2.toolconsumerprofile+json',
308
+ 'application/vnd.ims.lti.v2.toolproxy+json',
309
+ 'application/vnd.ims.lti.v2.toolproxy.id+json',
310
+ 'application/vnd.ims.lti.v2.toolsettings+json',
311
+ 'application/vnd.ims.lti.v2.toolsettings.simple+json',
312
+ 'application/vnd.las.las+json',
313
+ 'application/vnd.mason+json',
314
+ 'application/vnd.micro+json',
315
+ 'application/vnd.miele+json',
316
+ 'application/vnd.mozilla.xul+xml',
317
+ 'application/vnd.ms-fontobject',
318
+ 'application/vnd.ms-opentype',
319
+ 'application/vnd.nearst.inv+json',
320
+ 'application/vnd.oftn.l10n+json',
321
+ 'application/vnd.oma.lwm2m+json',
322
+ 'application/vnd.oracle.resource+json',
323
+ 'application/vnd.pagerduty+json',
324
+ 'application/vnd.restful+json',
325
+ 'application/vnd.siren+json',
326
+ 'application/vnd.sun.wadl+xml',
327
+ 'application/vnd.tableschema+json',
328
+ 'application/vnd.vel+json',
329
+ 'application/vnd.xacml+json',
330
+ 'application/voucher-cms+json',
331
+ 'application/wasm',
332
+ 'application/webpush-options+json',
333
+ 'application/x-httpd-php',
334
+ 'application/x-javascript',
335
+ 'application/x-ns-proxy-autoconfig',
336
+ 'application/x-sh',
337
+ 'application/x-tar',
338
+ 'application/x-virtualbox-hdd',
339
+ 'application/x-virtualbox-ova',
340
+ 'application/x-virtualbox-ovf',
341
+ 'application/x-virtualbox-vbox',
342
+ 'application/x-virtualbox-vdi',
343
+ 'application/x-virtualbox-vhd',
344
+ 'application/x-virtualbox-vmdk',
345
+ 'application/x-web-app-manifest+json',
346
+ 'application/x-www-form-urlencoded',
347
+ 'application/xhtml+xml',
348
+ 'application/xml',
349
+ 'application/xml-dtd',
350
+ 'application/xop+xml',
351
+ 'application/yang-data+json',
352
+ 'application/yang-patch+json',
353
+ 'font/otf',
354
+ 'image/bmp',
355
+ 'image/svg+xml',
356
+ 'image/vnd.adobe.photoshop',
357
+ 'image/x-icon',
358
+ 'image/x-ms-bmp',
359
+ 'message/imdn+xml',
360
+ 'message/rfc822',
361
+ 'model/gltf+json',
362
+ 'model/gltf-binary',
363
+ 'model/x3d+xml',
364
+ 'text/cache-manifest',
365
+ 'text/calender',
366
+ 'text/cmd',
367
+ 'text/css',
368
+ 'text/csv',
369
+ 'text/html',
370
+ 'text/javascript',
371
+ 'text/jsx',
372
+ 'text/markdown',
373
+ 'text/n3',
374
+ 'text/plain',
375
+ 'text/richtext',
376
+ 'text/rtf',
377
+ 'text/tab-separated-values',
378
+ 'text/uri-list',
379
+ 'text/vcard',
380
+ 'text/vtt',
381
+ 'text/x-gwt-rpc',
382
+ 'text/x-jquery-tmpl',
383
+ 'text/x-markdown',
384
+ 'text/x-org',
385
+ 'text/x-processing',
386
+ 'text/x-suse-ymp',
387
+ 'text/xml',
388
+ 'x-shader/x-fragment',
389
+ 'x-shader/x-vertex',
390
+ ];
391
+ const ZLIB_DEFAULT_OPTIONS = {
392
+ level: 5,
393
+ };
394
+ const acceptEncoding = (accepts, encodings) => accepts.find((accept) => encodings.some((encoding) => accept === encoding));
395
+ const getBestAcceptEncoding = (request) => {
396
+ const { headers } = request;
397
+ const acceptEncodings = (headers['accept-encoding'] || '').split(/, */);
398
+ const encoding = acceptEncoding(acceptEncodings, [
399
+ 'gzip',
400
+ 'deflate',
401
+ 'identity',
402
+ ]);
403
+ return encoding === 'deflate' && acceptEncoding(acceptEncodings, ['gzip'])
404
+ ? acceptEncoding(acceptEncodings, ['gzip', 'identity'])
405
+ : encoding;
406
+ };
407
+ const compressResponse = (response, encoding) => {
408
+ const { body, headers, ...rest } = response;
409
+ const compressed = encoding === 'gzip'
410
+ ? zlib__namespace.gzipSync(body, ZLIB_DEFAULT_OPTIONS)
411
+ : zlib__namespace.deflateSync(body, ZLIB_DEFAULT_OPTIONS);
412
+ return {
413
+ ...rest,
414
+ body: compressed.toString('base64'),
415
+ headers: {
416
+ ...headers,
417
+ 'content-encoding': encoding,
418
+ 'content-length': compressed.byteLength,
419
+ },
420
+ isBase64Encoded: true,
421
+ };
422
+ };
423
+ const compress = (response, request) => {
424
+ const { body, headers } = response;
425
+ const encoding = getBestAcceptEncoding(request);
426
+ const weShouldCompress = COMPRESSIBLE.includes(headers['content-type']) &&
427
+ encoding !== undefined &&
428
+ encoding !== 'identity' &&
429
+ body &&
430
+ body.length > 256;
431
+ return weShouldCompress && encoding
432
+ ? compressResponse(response, encoding)
433
+ : response;
434
+ };
435
+
436
+ const contentLengthHeader = (response) => {
437
+ const { body, headers, ...rest } = response;
438
+ return {
439
+ ...rest,
440
+ body,
441
+ headers: {
442
+ ...headers,
443
+ 'content-length': headers['content-length'] || Buffer.byteLength(body),
444
+ },
445
+ };
446
+ };
447
+
448
+ const DEFAULT_POLICIES = {
449
+ 'default-src': "'self' https: 'unsafe-inline'",
450
+ 'img-src': '* data: blob:',
451
+ };
452
+ const cspHeaders = (response, _, options) => {
453
+ const { headers = {}, ...rest } = response;
454
+ const cspPolicies = {
455
+ ...DEFAULT_POLICIES,
456
+ ...options.cspPolicies,
457
+ };
458
+ const cspPolicy = Object.keys(cspPolicies)
459
+ .map((policy) => `${policy} ${cspPolicies[policy]}`)
460
+ .join(';');
461
+ return {
462
+ ...rest,
463
+ headers: {
464
+ ...headers,
465
+ 'content-security-policy': cspPolicy,
466
+ 'referrer-policy': 'strict-origin-when-cross-origin',
467
+ 'x-content-type-options': 'nosniff',
468
+ 'x-frame-options': {
469
+ "'none'": 'DENY',
470
+ "'self'": 'SAMEORIGIN',
471
+ }[cspPolicies['frame-ancestors']] || undefined,
472
+ 'x-xss-protection': '1; mode=block',
473
+ },
474
+ };
475
+ };
476
+
477
+ const enforcedHeaders = (response, _, options) => ({
478
+ ...response,
479
+ headers: {
480
+ ...response.headers,
481
+ ...(options.headers ?? {}),
482
+ },
483
+ });
484
+
485
+ const EMPTY_ENTITY_TAG = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
486
+ const entitytag = (entity) => {
487
+ const hash = crypto__namespace
488
+ .createHash('sha1')
489
+ .update(entity, 'utf8')
490
+ .digest('base64')
491
+ .slice(0, 27);
492
+ const length = typeof entity === 'string'
493
+ ? Buffer.byteLength(entity, 'utf8')
494
+ : entity.length;
495
+ return `"${length.toString(16)}-${hash}"`;
496
+ };
497
+ const etag = (entity) => entity.length === 0 ? EMPTY_ENTITY_TAG : entitytag(entity);
498
+ const etagHeader = (response) => ({
499
+ ...response,
500
+ headers: {
501
+ ...response.headers,
502
+ etag: etag(response.body),
503
+ },
504
+ });
505
+
506
+ const aws = (request) => {
507
+ const { headers: requestHeaders, requestContext, context } = request;
508
+ return {
509
+ apig: {
510
+ requestId: requestContext.requestId,
511
+ resourcePath: requestContext.resourcePath ??
512
+ '',
513
+ },
514
+ awsAccountId: requestContext.accountId,
515
+ cloudfront: {
516
+ country: requestHeaders['cloudfront-viewer-country'],
517
+ desktop: requestHeaders['cloudfront-is-desktop-viewer'] === 'true',
518
+ mobile: requestHeaders['cloudfront-is-mobile-viewer'] === 'true',
519
+ smarttv: requestHeaders['cloudfront-is-smarttv-viewer'] === 'true',
520
+ tablet: requestHeaders['cloudfront-is-tablet-viewer'] === 'true',
521
+ },
522
+ deploymentStage: requestContext.stage,
523
+ lambda: {
524
+ functionName: context.functionName,
525
+ memoryLimit: Number(context.memoryLimitInMB),
526
+ remainingExecutionTime: context.getRemainingTimeInMillis?.(),
527
+ requestId: context.awsRequestId,
528
+ },
529
+ sourceIp: requestContext.identity
530
+ ?.sourceIp ??
531
+ requestContext?.http?.sourceIp,
532
+ };
533
+ };
534
+ const logger$1 = (request, response) => {
535
+ const { source, headers: requestHeaders, meta, requestContext, provider, hostname, body, timestamp, path, query, } = request;
536
+ const error = response.statusCode >= 500 && response.statusCode < 600;
537
+ const logEntry = {
538
+ dateTime: new Date().toISOString(),
539
+ eventSource: source,
540
+ hostname,
541
+ httpMethod: requestContext.httpMethod,
542
+ httpProtocol: requestHeaders.via?.split(' ')[0],
543
+ httpReferrer: requestHeaders.referer,
544
+ httpUserAgent: requestHeaders['user-agent'],
545
+ requestContentLength: (body && body.length > 0) || 0,
546
+ requestTime: Date.now() - timestamp,
547
+ requestUri: path +
548
+ (query && Object.keys(query).length > 0
549
+ ? `?${querystring__namespace.stringify(query)}`
550
+ : ''),
551
+ responseContentLength: response.headers['content-length'],
552
+ statusCode: response.statusCode,
553
+ xForwardedHost: requestHeaders['x-forwarded-host'],
554
+ ...meta,
555
+ ...(provider === 'aws' && aws(request)),
556
+ };
557
+ return ((error ? process.stderr : process.stdout).write(JSON.stringify(logEntry)) &&
558
+ logEntry);
559
+ };
560
+ const logResponse = (response, request, options) => (options.enableLogger &&
561
+ (typeof options.logger === 'function'
562
+ ? options.logger(request, response)
563
+ : logger$1(request, response)) &&
564
+ response) ||
565
+ response;
566
+
567
+ const redirect = (responseData, _, location, statusCode = 302, options = {}) => makeResponseObject(responseData, '', statusCode, {
568
+ ...options,
569
+ headers: {
570
+ ...options.headers,
571
+ location,
572
+ },
573
+ });
574
+
575
+ const getBestMatchedFormat = (formats, accept) => {
576
+ const fallback = formats.default || 'html';
577
+ const acceptFormats = accept &&
578
+ typeof accept === 'string' &&
579
+ accept
580
+ .split(';')[0]
581
+ .split(',')
582
+ .map((type) => {
583
+ const mimeParts = type.split('/');
584
+ return mimeParts.at(-1);
585
+ });
586
+ return ((acceptFormats &&
587
+ acceptFormats.find((type) => Reflect.has(formats, type))) ||
588
+ fallback);
589
+ };
590
+ const getBestMatchedResponseHelper = (format) => {
591
+ switch (format) {
592
+ case 'html':
593
+ return html;
594
+ case 'json':
595
+ return json;
596
+ }
597
+ throw new TypeError(`"${format}" is not a valid Alagarr respondTo() format.`);
598
+ };
599
+ const getBestMatchedFormatBody = (formats, format) => {
600
+ switch (format) {
601
+ case 'html':
602
+ return formats.html;
603
+ case 'json':
604
+ return formats.json;
605
+ }
606
+ throw new TypeError(`"${format}" is not a valid Alagarr respondTo() format.`);
607
+ };
608
+ const respondTo = (responseData, request, formats, statusCode, options) => {
609
+ const { headers: { accept }, } = request;
610
+ const format = getBestMatchedFormat(formats, accept);
611
+ const responseHelper = getBestMatchedResponseHelper(format);
612
+ const body = getBestMatchedFormatBody(formats, format);
613
+ return responseHelper(responseData, request, body, statusCode, options);
614
+ };
615
+
616
+ const text = (responseData, _, body, statusCode, options) => makeResponseObject(responseData, body, statusCode, options, 'text/plain');
617
+
618
+ const middlewareMap = {
619
+ enableCompression: compress,
620
+ enableContentLength: contentLengthHeader,
621
+ enableCspHeaders: cspHeaders,
622
+ enableETagHeader: etagHeader,
623
+ enableEnforcedHeaders: enforcedHeaders,
624
+ };
625
+ var makeResponse = async (request, callback, options) => {
626
+ const responseData = makeResponseObject();
627
+ const responseWithHelpers = [
628
+ text,
629
+ html,
630
+ json,
631
+ redirect,
632
+ respondTo,
633
+ ].reduce((methods, method) => ({
634
+ ...methods,
635
+ [method.name]: async (...arguments_) => callback(null, await applyMiddleware(Object.keys(middlewareMap).reduce((middlewareList, middleware) => options[middleware]
636
+ ? [...middlewareList, middlewareMap[middleware]]
637
+ : middlewareList, [
638
+ ...(options.responseMiddleware || []),
639
+ ...(options.enableLogger ? [logResponse] : []),
640
+ ]), method(responseData, request, ...arguments_), request, options)),
641
+ }), { raw: callback });
642
+ const response = [setHeader].reduce((responseMethods, method) => ({
643
+ ...responseMethods,
644
+ [method.name]: (...arguments_) => method(response, responseData, ...arguments_),
645
+ }), responseWithHelpers);
646
+ return response;
647
+ };
648
+
649
+ const DEFAULT_OPTIONS = {
650
+ cspPolicies: [],
651
+ enableCompression: true,
652
+ enableContentLength: true,
653
+ enableCspHeaders: true,
654
+ enableETagHeader: true,
655
+ enableEnforcedHeaders: true,
656
+ enableLogger: true,
657
+ enableStrictTransportSecurity: true,
658
+ errorHandler: defaultErrorHandler,
659
+ requestMiddleware: [],
660
+ responseMiddleware: [],
661
+ };
662
+ const noopHandler = (_, _1) => {
663
+ throw new ServerError('Misconfiguration in Alagarr setup. No handler function was provided.');
664
+ };
665
+ const alagarr = (handler = noopHandler, options = DEFAULT_OPTIONS) => async (event, context, callback) => {
666
+ const mergedOptions = {
667
+ ...DEFAULT_OPTIONS,
668
+ ...options,
669
+ };
670
+ const request = await makeRequest(event, context, mergedOptions);
671
+ const response = await makeResponse(request, callback, mergedOptions);
672
+ try {
673
+ return await handler(request, response, context);
674
+ }
675
+ catch (handlerError) {
676
+ const errorHandler = typeof mergedOptions.errorHandler === 'function'
677
+ ? mergedOptions.errorHandler
678
+ : defaultErrorHandler;
679
+ try {
680
+ return await errorHandler(request, response, handlerError);
681
+ }
682
+ catch (error) {
683
+ console.error('There was an error in the error handler provided to Alagaar', error, errorHandler.toString());
684
+ return defaultErrorHandler(request, response, error);
685
+ }
686
+ }
687
+ };
688
+
689
+ const DEFAULT_AWS_CONFIGURATION = {
690
+ region: 'eu-central-2',
691
+ };
692
+
693
+ const splitEvery = (every, list) => Array.from({ length: Math.ceil(list.length / every) }).map((_, count) => list.slice(count * every, count * every + every));
694
+ const until = async (predicate, transformer, initialValue, iterationCount = 0) => {
695
+ const transformed = await transformer(initialValue, iterationCount);
696
+ return (await predicate(transformed, iterationCount))
697
+ ? transformed
698
+ : until(predicate, transformer, transformed, iterationCount + 1);
699
+ };
700
+
701
+ const DEFAULT_BATCH_ITEMS_MAX_RETRIES = 50;
702
+ let queue;
703
+ const makeKey = (key) => {
704
+ if (typeof key === 'string') {
705
+ return { id: key };
706
+ }
707
+ return key;
708
+ };
709
+ const deleteItem = async (config, documentClient, table, key, options = {}) => {
710
+ try {
711
+ const { ReturnValues = 'NONE' } = options;
712
+ const command = new libDynamodb.DeleteCommand({
713
+ Key: makeKey(key),
714
+ ReturnValues,
715
+ TableName: config.tableNamePrefix + table,
716
+ });
717
+ const result = await queue.schedule(() => documentClient.send(command));
718
+ return result.Attributes;
719
+ }
720
+ catch (error) {
721
+ if (config.logger) {
722
+ config.logger.error(error);
723
+ }
724
+ return undefined;
725
+ }
726
+ };
727
+ const getItem = async (config, documentClient, table, key, options = {}) => {
728
+ try {
729
+ const { ConsistentRead = false } = options;
730
+ const command = new libDynamodb.GetCommand({
731
+ ConsistentRead,
732
+ Key: makeKey(key),
733
+ TableName: config.tableNamePrefix + table,
734
+ });
735
+ const result = await queue.schedule(() => documentClient.send(command));
736
+ return result.Item;
737
+ }
738
+ catch (error) {
739
+ if (config.logger) {
740
+ config.logger.error(error);
741
+ }
742
+ return undefined;
743
+ }
744
+ };
745
+ const putItem = async (config, documentClient, table, Item) => {
746
+ try {
747
+ const { expires, ...data } = Item;
748
+ const command = new libDynamodb.PutCommand({
749
+ Item: expires === null ? data : Item,
750
+ TableName: config.tableNamePrefix + table,
751
+ });
752
+ return (await queue.schedule(() => documentClient.send(command))) && Item;
753
+ }
754
+ catch (error) {
755
+ if (config.logger) {
756
+ config.logger.error(error);
757
+ }
758
+ return undefined;
759
+ }
760
+ };
761
+ const updateItem = async (config, documentClient, table, key, options = {}) => {
762
+ try {
763
+ const command = new libDynamodb.UpdateCommand({
764
+ Key: makeKey(key),
765
+ ...options,
766
+ ReturnValues: 'ALL_NEW',
767
+ TableName: config.tableNamePrefix + table,
768
+ });
769
+ const result = await queue.schedule(async () => documentClient.send(command));
770
+ return result.Attributes;
771
+ }
772
+ catch (error) {
773
+ if (config.logger) {
774
+ config.logger.error(error);
775
+ }
776
+ return undefined;
777
+ }
778
+ };
779
+ const hasNoUnprocessedItems = ({ UnprocessedItems, }) => !UnprocessedItems || Object.keys(UnprocessedItems).length === 0;
780
+ const makeBatchWriteRequestWithExponentialBackoff = (documentClient, table, batchWriteMaxRetries) => async (batchItems, retries) => {
781
+ if (retries > batchWriteMaxRetries) {
782
+ throw new Error('Reached maximum number of DynamoDB BatchWrite request retries.');
783
+ }
784
+ if (batchItems === undefined) {
785
+ throw new Error('makeBatchWriteRequestWithExponentialBackoff: batchItems must not be undefined.');
786
+ }
787
+ const command = new libDynamodb.BatchWriteCommand({
788
+ RequestItems: batchItems.UnprocessedItems ?? {
789
+ [table]: batchItems.map((Item) => ({
790
+ PutRequest: { Item },
791
+ })),
792
+ },
793
+ ReturnConsumedCapacity: 'TOTAL',
794
+ ReturnItemCollectionMetrics: 'SIZE',
795
+ });
796
+ return documentClient.send(command);
797
+ };
798
+ const batchWriteItems = async (config, documentClient, table, items) => {
799
+ try {
800
+ const batches = splitEvery(25, items);
801
+ const result = await Promise.all(batches.map(async (batch) => queue.schedule(async () => until(hasNoUnprocessedItems, makeBatchWriteRequestWithExponentialBackoff(documentClient, config.tableNamePrefix + table, config.batchWriteMaxRetries ?? DEFAULT_BATCH_ITEMS_MAX_RETRIES), batch))));
802
+ return result && items;
803
+ }
804
+ catch (error) {
805
+ if (config.logger) {
806
+ config.logger.error(error);
807
+ }
808
+ return undefined;
809
+ }
810
+ };
811
+ const scanTable = async (config, documentClient, table, options = {}) => {
812
+ try {
813
+ const { ConsistentRead = false } = options;
814
+ const command = new libDynamodb.ScanCommand({
815
+ ...options,
816
+ ConsistentRead,
817
+ TableName: config.tableNamePrefix + table,
818
+ });
819
+ return await queue.schedule(() => documentClient.send(command));
820
+ }
821
+ catch (error) {
822
+ if (config.logger) {
823
+ config.logger.error(error);
824
+ }
825
+ return undefined;
826
+ }
827
+ };
828
+ const queryTable = async (config, documentClient, table, options = {}) => {
829
+ try {
830
+ const { ConsistentRead = false } = options;
831
+ const command = new libDynamodb.QueryCommand({
832
+ ...options,
833
+ ConsistentRead,
834
+ TableName: config.tableNamePrefix + table,
835
+ });
836
+ return await queue.schedule(() => documentClient.send(command));
837
+ }
838
+ catch (error) {
839
+ if (config.logger) {
840
+ config.logger.error(error);
841
+ }
842
+ return undefined;
843
+ }
844
+ };
845
+ const dynamodb = (userConfig) => {
846
+ const { clientConfig, ...config } = {
847
+ ...DEFAULT_AWS_CONFIGURATION,
848
+ ...userConfig,
849
+ };
850
+ const ddbClient = new clientDynamodb.DynamoDBClient(config.dockerConfig
851
+ ? {
852
+ credentials: {
853
+ accessKeyId: 'foobarkey',
854
+ secretAccessKey: 'foobarsecret',
855
+ },
856
+ endpoint: config.dockerConfig.endpoint,
857
+ region: 'local',
858
+ retryMode: 'standard',
859
+ }
860
+ : { retryMode: 'standard', ...clientConfig });
861
+ const documentClient = libDynamodb.DynamoDBDocumentClient.from(ddbClient);
862
+ queue = new Bottleneck({
863
+ maxConcurrent: config.queueConfig?.queueConcurrency ?? 25,
864
+ minTime: config.queueConfig?.queueDelay ?? undefined,
865
+ });
866
+ return {
867
+ batchWriteItems: (table, items) => batchWriteItems(config, documentClient, table, items),
868
+ deleteItem: (table, key, options) => deleteItem(config, documentClient, table, key, options),
869
+ getItem: (table, key, options) => getItem(config, documentClient, table, key, options),
870
+ putItem: (table, item) => putItem(config, documentClient, table, item),
871
+ queryTable: (table, options) => queryTable(config, documentClient, table, options),
872
+ scanTable: (table, options) => scanTable(config, documentClient, table, options),
873
+ updateItem: (table, key, options) => updateItem(config, documentClient, table, key, options),
874
+ };
875
+ };
876
+
877
+ const invokeLambda = async (lambdaClient, config, invocationType, payload) => {
878
+ try {
879
+ const invokeCommand = new clientLambda.InvokeCommand({
880
+ FunctionName: config.functionName,
881
+ InvocationType: invocationType,
882
+ Payload: Buffer.from(JSON.stringify(payload)),
883
+ });
884
+ const result = await lambdaClient.send(invokeCommand);
885
+ if (config.logger) {
886
+ config.logger.info(JSON.stringify(result));
887
+ }
888
+ return true;
889
+ }
890
+ catch (error) {
891
+ if (config.logger) {
892
+ config.logger.error(error);
893
+ }
894
+ return false;
895
+ }
896
+ };
897
+ const lambda = (userConfig) => {
898
+ const { clientConfig, ...config } = {
899
+ ...DEFAULT_AWS_CONFIGURATION,
900
+ ...userConfig,
901
+ };
902
+ const lambdaClient = new clientLambda.LambdaClient(clientConfig);
903
+ return {
904
+ invokeLambda: (invocationType, payload) => invokeLambda(lambdaClient, config, invocationType, payload),
905
+ };
906
+ };
907
+
908
+ const DEFAULT_CLIENT_CONFIG$1 = {
909
+ clientConfig: DEFAULT_AWS_CONFIGURATION,
910
+ onlyDefault: false,
911
+ prefix: process.env.SSM_PARAM_PATH,
912
+ };
913
+ const getSecrets = async (ssm, config, parameters_, defaultValues) => {
914
+ if (config.onlyDefault) {
915
+ return defaultValues;
916
+ }
917
+ try {
918
+ const command = new clientSsm.GetParametersCommand({
919
+ Names: parameters_.map((parameter) => `${config.prefix ?? ''}${parameter}`),
920
+ WithDecryption: true,
921
+ });
922
+ const parameters = await ssm.send(command);
923
+ return (parameters?.Parameters?.map((parameter) => {
924
+ const defaultIfNoParameter = !parameter.Value && parameter.Name
925
+ ? defaultValues.find((defaultValue) => defaultValue.name === parameter.Name)
926
+ : defaultValues[0];
927
+ return {
928
+ name: parameter.Name ?? defaultIfNoParameter?.name ?? '',
929
+ value: parameter.Value ?? defaultIfNoParameter?.value ?? '',
930
+ };
931
+ }) ?? defaultValues);
932
+ }
933
+ catch (error) {
934
+ if (config.logger) {
935
+ config.logger.error(error);
936
+ }
937
+ return defaultValues;
938
+ }
939
+ };
940
+ const getSecret = async (ssm, config, parameter_, defaultValue) => {
941
+ if (config.onlyDefault) {
942
+ return defaultValue;
943
+ }
944
+ try {
945
+ const parameter = await ssm.send(new clientSsm.GetParameterCommand({
946
+ Name: `${config.prefix ?? ''}${parameter_}`,
947
+ WithDecryption: true,
948
+ }));
949
+ return parameter?.Parameter?.Value ?? defaultValue;
950
+ }
951
+ catch (error) {
952
+ if (config.logger) {
953
+ config.logger.error(error);
954
+ }
955
+ return defaultValue;
956
+ }
957
+ };
958
+ const parameterStore = (userConfig) => {
959
+ const { clientConfig, ...config } = {
960
+ ...DEFAULT_CLIENT_CONFIG$1,
961
+ ...userConfig,
962
+ };
963
+ const ssm = new clientSsm.SSMClient(clientConfig);
964
+ return {
965
+ getSecret: (parameter, defaultValue = '') => getSecret(ssm, config, parameter, defaultValue),
966
+ getSecrets: (parameters, defaultValues = []) => getSecrets(ssm, config, parameters, defaultValues),
967
+ };
968
+ };
969
+
970
+ const DEFAULT_CLIENT_CONFIG = {
971
+ clientConfig: { region: 'eu-west-1' },
972
+ };
973
+ const sendMail = async (config, transport, options, responseCallback) => {
974
+ try {
975
+ if (!options.html && !options.text) {
976
+ if (config.logger) {
977
+ config.logger.error('The option text or html needs to be set.');
978
+ }
979
+ return false;
980
+ }
981
+ if (!options.to || !options.subject) {
982
+ if (config.logger) {
983
+ config.logger.error('The fields to and subject have to be set.');
984
+ }
985
+ return false;
986
+ }
987
+ const transportResponse = await transport.sendMail(options);
988
+ if (responseCallback) {
989
+ await responseCallback(transportResponse);
990
+ }
991
+ if (!transportResponse) {
992
+ if (config.logger) {
993
+ config.logger.error('Sending email failed!');
994
+ }
995
+ return false;
996
+ }
997
+ return true;
998
+ }
999
+ catch (error) {
1000
+ if (config.logger) {
1001
+ config.logger.error(error);
1002
+ }
1003
+ return false;
1004
+ }
1005
+ };
1006
+ const ses = (userConfig) => {
1007
+ const { clientConfig, ...config } = {
1008
+ ...DEFAULT_CLIENT_CONFIG,
1009
+ ...userConfig,
1010
+ };
1011
+ const sesClient = new clientSesv2.SESv2Client(clientConfig);
1012
+ const transport = nodemailer.createTransport(userConfig.customSMTPConfig ?? {
1013
+ SES: {
1014
+ SendEmailCommand: clientSesv2.SendEmailCommand,
1015
+ sesClient,
1016
+ },
1017
+ });
1018
+ return {
1019
+ sendMail: (options, responseCallback) => sendMail(config, transport, options, responseCallback),
1020
+ };
1021
+ };
1022
+
1023
+ const deleteQueueItem = async (sqsClient, config, queueUrl, receiptHandle) => {
1024
+ try {
1025
+ const deleteMessageCommand = new clientSqs.DeleteMessageCommand({
1026
+ QueueUrl: queueUrl,
1027
+ ReceiptHandle: receiptHandle,
1028
+ });
1029
+ return await sqsClient.send(deleteMessageCommand);
1030
+ }
1031
+ catch (error) {
1032
+ if (config.logger) {
1033
+ config.logger.error(error);
1034
+ }
1035
+ return undefined;
1036
+ }
1037
+ };
1038
+ const getQueueItems = async (sqsClient, config, queueUrl, maxNumberOfMessages = 1) => {
1039
+ try {
1040
+ const receiveMessageCommand = new clientSqs.ReceiveMessageCommand({
1041
+ MaxNumberOfMessages: maxNumberOfMessages,
1042
+ QueueUrl: queueUrl,
1043
+ });
1044
+ return await sqsClient.send(receiveMessageCommand);
1045
+ }
1046
+ catch (error) {
1047
+ if (config.logger) {
1048
+ config.logger.error(error);
1049
+ }
1050
+ return undefined;
1051
+ }
1052
+ };
1053
+ const getQueueUrl = async (sqsClient, config, queueName) => {
1054
+ try {
1055
+ const getUrlCommand = new clientSqs.GetQueueUrlCommand({ QueueName: queueName });
1056
+ const result = await sqsClient.send(getUrlCommand);
1057
+ return result.QueueUrl;
1058
+ }
1059
+ catch (error) {
1060
+ if (config.logger) {
1061
+ config.logger.error(error);
1062
+ }
1063
+ return undefined;
1064
+ }
1065
+ };
1066
+ const sendMessage = async (sqsClient, config, queueUrl, message, fifoSettings = {}, messageAttributes, messageDelay = 0) => {
1067
+ try {
1068
+ const sendMessageCommand = new clientSqs.SendMessageCommand({
1069
+ ...fifoSettings,
1070
+ ...(messageAttributes ? { MessageAttributes: messageAttributes } : {}),
1071
+ DelaySeconds: messageDelay,
1072
+ MessageBody: message,
1073
+ QueueUrl: queueUrl,
1074
+ });
1075
+ const result = await sqsClient.send(sendMessageCommand);
1076
+ return result.MessageId;
1077
+ }
1078
+ catch (error) {
1079
+ if (config.logger) {
1080
+ config.logger.error(error);
1081
+ }
1082
+ return undefined;
1083
+ }
1084
+ };
1085
+ const sendBatchMessages = async (sqsClient, config, queueUrl, queueEntries) => {
1086
+ try {
1087
+ const sendMessageBatchCommand = new clientSqs.SendMessageBatchCommand({
1088
+ Entries: queueEntries,
1089
+ QueueUrl: queueUrl,
1090
+ });
1091
+ const result = await sqsClient.send(sendMessageBatchCommand);
1092
+ return { failed: result.Failed, successful: result.Successful };
1093
+ }
1094
+ catch (error) {
1095
+ if (config.logger) {
1096
+ config.logger.error(error);
1097
+ }
1098
+ return { failed: undefined, successful: undefined };
1099
+ }
1100
+ };
1101
+ const sqs = (userConfig) => {
1102
+ const { clientConfig, ...config } = {
1103
+ ...DEFAULT_AWS_CONFIGURATION,
1104
+ ...userConfig,
1105
+ };
1106
+ const sqsClient = new clientSqs.SQSClient(clientConfig);
1107
+ return {
1108
+ deleteQueueItem: (queueUrl, receiptHandle) => deleteQueueItem(sqsClient, config, queueUrl, receiptHandle),
1109
+ getQueueItems: (queueUrl, maxNumberOfMessages) => getQueueItems(sqsClient, config, queueUrl, maxNumberOfMessages),
1110
+ getQueueUrl: (queueName) => getQueueUrl(sqsClient, config, queueName),
1111
+ sendBatchMessages: (queueUrl, queueEntries) => sendBatchMessages(sqsClient, config, queueUrl, queueEntries),
1112
+ sendMessage: (queueUrl, message, fifoSettings, messageAttributes, messageDelay) => sendMessage(sqsClient, config, queueUrl, message, fifoSettings, messageAttributes, messageDelay),
1113
+ };
1114
+ };
1115
+
1116
+ const logger = (config) => {
1117
+ const loggerConfig = {
1118
+ defaultMeta: {
1119
+ ...config.defaultLogInformation,
1120
+ deploymentStage: config.deploymentStage,
1121
+ service: config.service,
1122
+ },
1123
+ format: winston.format.combine(winston.format.timestamp({
1124
+ format: 'DD-MM-YYYY HH:mm:ss',
1125
+ }), winston.format.json()),
1126
+ level: config.level || 'info',
1127
+ };
1128
+ if (config.datadogApiKey) {
1129
+ const httpOptions = {
1130
+ host: 'http-intake.logs.datadoghq.eu',
1131
+ path: `/api/v2/logs?dd-api-key=${config.datadogApiKey}&ddsource=nodejs&service=${config.service}`,
1132
+ port: 443,
1133
+ ssl: true,
1134
+ };
1135
+ return winston.createLogger({
1136
+ ...loggerConfig,
1137
+ transports: [new winston.transports.Http(httpOptions)],
1138
+ });
1139
+ }
1140
+ return winston.createLogger({
1141
+ ...loggerConfig,
1142
+ transports: [new winston.transports.Console({ forceConsole: true })],
1143
+ });
1144
+ };
1145
+
1146
+ Object.defineProperty(exports, "Logger", {
1147
+ enumerable: true,
1148
+ get: function () { return winston.Logger; }
1149
+ });
1150
+ exports.ClientError = ClientError;
1151
+ exports.DEFAULT_PARAMETER_STORE_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG$1;
1152
+ exports.DEFAULT_SES_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG;
1153
+ exports.ServerError = ServerError;
1154
+ exports.alagarr = alagarr;
1155
+ exports.dynamodb = dynamodb;
1156
+ exports.lambda = lambda;
1157
+ exports.logger = logger;
1158
+ exports.parameterStore = parameterStore;
1159
+ exports.ses = ses;
1160
+ exports.sqs = sqs;