@spytecgps/lambda-utils 2.3.18 → 2.3.20
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/index.js +21 -8
- package/package.json +2 -2
- package/dist/logger/index.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -5,7 +5,6 @@ var dayjs = require('dayjs');
|
|
|
5
5
|
var timezone = require('dayjs/plugin/timezone');
|
|
6
6
|
var utc = require('dayjs/plugin/utc');
|
|
7
7
|
var Joi = require('joi');
|
|
8
|
-
var qs = require('qs');
|
|
9
8
|
var rawMiddy = require('@middy/core');
|
|
10
9
|
var httpErrorHandler = require('@middy/http-error-handler');
|
|
11
10
|
var httpResponseSerializer = require('@middy/http-response-serializer');
|
|
@@ -32,7 +31,16 @@ function _interopNamespaceDefault(e) {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
var Joi__namespace = /*#__PURE__*/_interopNamespaceDefault(Joi);
|
|
35
|
-
|
|
34
|
+
|
|
35
|
+
var stringify = require('./stringify');
|
|
36
|
+
var parse = require('./parse');
|
|
37
|
+
var formats = require('./formats');
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
formats: formats,
|
|
41
|
+
parse: parse,
|
|
42
|
+
stringify: stringify
|
|
43
|
+
};
|
|
36
44
|
|
|
37
45
|
dayjs.extend(utc);
|
|
38
46
|
dayjs.extend(timezone);
|
|
@@ -64,7 +72,7 @@ const urlEncoded = Joi__namespace.extend((joi) => {
|
|
|
64
72
|
type: 'object',
|
|
65
73
|
base: joi.object(),
|
|
66
74
|
coerce(value) {
|
|
67
|
-
return { value:
|
|
75
|
+
return { value: undefined(value) };
|
|
68
76
|
},
|
|
69
77
|
};
|
|
70
78
|
});
|
|
@@ -86,7 +94,7 @@ const SpytecJoi = Joi__namespace.extend((joi) => ({
|
|
|
86
94
|
type: 'urlEncodedObject',
|
|
87
95
|
base: joi.object(),
|
|
88
96
|
coerce(value) {
|
|
89
|
-
return { value:
|
|
97
|
+
return { value: undefined(value) };
|
|
90
98
|
},
|
|
91
99
|
}), (joi) => ({
|
|
92
100
|
type: 'jsonObject',
|
|
@@ -168,7 +176,8 @@ const SpytecJoi = Joi__namespace.extend((joi) => ({
|
|
|
168
176
|
|
|
169
177
|
const getAuthorizerValidator = (params = {}) => {
|
|
170
178
|
return Joi__namespace.object({
|
|
171
|
-
clientId: Joi__namespace.number(),
|
|
179
|
+
clientId: Joi__namespace.number().greater(0).required(),
|
|
180
|
+
userId: Joi__namespace.string().guid({ version: 'uuidv4' }).required(),
|
|
172
181
|
resources: json.object({}),
|
|
173
182
|
scope: Joi__namespace.string().optional(),
|
|
174
183
|
// .error(() => new UnauthorizedError(`missing scope ${scope}`))
|
|
@@ -530,10 +539,14 @@ const responseWrapperMiddleware = () => {
|
|
|
530
539
|
req.response = buildProxyResult(req.response);
|
|
531
540
|
};
|
|
532
541
|
const responseWrapperMiddlewareError = (req) => {
|
|
533
|
-
|
|
542
|
+
const statusCode = req.error?.code ?? 500;
|
|
543
|
+
const errorMessage = req.error?.message || 'Error';
|
|
544
|
+
if (statusCode >= 500) {
|
|
545
|
+
sdkLogger.logger.error(req.error, 'Request failed');
|
|
546
|
+
}
|
|
534
547
|
req.response = buildProxyResult({
|
|
535
|
-
statusCode
|
|
536
|
-
message:
|
|
548
|
+
statusCode,
|
|
549
|
+
message: errorMessage,
|
|
537
550
|
});
|
|
538
551
|
};
|
|
539
552
|
return {
|
package/package.json
CHANGED
package/dist/logger/index.d.ts
DELETED