@spytecgps/lambda-utils 1.0.15 → 1.0.17
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/errors/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import BadRequestError from './BadRequestError';
|
|
|
2
2
|
import NotFoundError from './NotFoundError';
|
|
3
3
|
import UnauthorizedError from './UnauthorizedError';
|
|
4
4
|
import ForbiddenError from './ForbiddenError';
|
|
5
|
-
|
|
5
|
+
import ConflictError from './ConflictError';
|
|
6
|
+
export { BadRequestError, NotFoundError, UnauthorizedError, ForbiddenError, ConflictError };
|
package/dist/errors/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ForbiddenError = exports.UnauthorizedError = exports.NotFoundError = exports.BadRequestError = void 0;
|
|
6
|
+
exports.ConflictError = exports.ForbiddenError = exports.UnauthorizedError = exports.NotFoundError = exports.BadRequestError = void 0;
|
|
7
7
|
var BadRequestError_1 = __importDefault(require("./BadRequestError"));
|
|
8
8
|
exports.BadRequestError = BadRequestError_1.default;
|
|
9
9
|
var NotFoundError_1 = __importDefault(require("./NotFoundError"));
|
|
@@ -12,3 +12,5 @@ var UnauthorizedError_1 = __importDefault(require("./UnauthorizedError"));
|
|
|
12
12
|
exports.UnauthorizedError = UnauthorizedError_1.default;
|
|
13
13
|
var ForbiddenError_1 = __importDefault(require("./ForbiddenError"));
|
|
14
14
|
exports.ForbiddenError = ForbiddenError_1.default;
|
|
15
|
+
var ConflictError_1 = __importDefault(require("./ConflictError"));
|
|
16
|
+
exports.ConflictError = ConflictError_1.default;
|
package/dist/types.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface HandlerResponse<R> {
|
|
|
40
40
|
message?: string;
|
|
41
41
|
data?: R;
|
|
42
42
|
rawResult?: boolean;
|
|
43
|
+
stringifyBody?: boolean;
|
|
43
44
|
}
|
|
44
45
|
export declare type BaseRecord = Omit<SQSRecord, 'body' | 'messageAttributes'>;
|
|
45
46
|
export interface MessageEvent<RecordType extends BaseRecord> {
|
|
@@ -5,4 +5,4 @@ export declare const buildResponseBody: <T>(statusCode: number, message: string,
|
|
|
5
5
|
message: string;
|
|
6
6
|
result: T;
|
|
7
7
|
};
|
|
8
|
-
export declare const buildProxyResult: <R>({ statusCode, message, data, headers, rawResult, }: HandlerResponse<R>) => APIGatewayProxyResult;
|
|
8
|
+
export declare const buildProxyResult: <R>({ statusCode, message, data, headers, rawResult, stringifyBody, }: HandlerResponse<R>) => APIGatewayProxyResult;
|
|
@@ -25,11 +25,12 @@ exports.buildResponseBody = function (statusCode, message, data) {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
exports.buildProxyResult = function (_a) {
|
|
28
|
-
var _b = _a.statusCode, statusCode = _b === void 0 ? 200 : _b, _c = _a.message, message = _c === void 0 ? 'ok' : _c, data = _a.data, _d = _a.headers, headers = _d === void 0 ? {} : _d, _e = _a.rawResult, rawResult = _e === void 0 ? false : _e;
|
|
28
|
+
var _b = _a.statusCode, statusCode = _b === void 0 ? 200 : _b, _c = _a.message, message = _c === void 0 ? 'ok' : _c, data = _a.data, _d = _a.headers, headers = _d === void 0 ? {} : _d, _e = _a.rawResult, rawResult = _e === void 0 ? false : _e, _f = _a.stringifyBody, stringifyBody = _f === void 0 ? true : _f;
|
|
29
29
|
var resp = rawResult ? data : exports.buildResponseBody(statusCode, message, data);
|
|
30
|
+
var body = stringifyBody ? resp && JSON.stringify(resp) : data;
|
|
30
31
|
return {
|
|
31
32
|
headers: __assign(__assign({}, baseHeaders), headers),
|
|
32
33
|
statusCode: statusCode,
|
|
33
|
-
body:
|
|
34
|
+
body: body,
|
|
34
35
|
};
|
|
35
36
|
};
|