UNPKG

@studyportals/sp-r2d2

Version:

A framework that contains various components used when developing projects that will be deployed via AWS λ.

31 lines 1.8 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SingleRecordSqsEventTranslator = void 0; const application_1 = require("../../../../application"); const event_translation_error_class_1 = require("../../../core/errors/event-translation-error.class"); class SingleRecordSqsEventTranslator { translate(event) { return __awaiter(this, void 0, void 0, function* () { if (0 === event.Records.length) { throw new event_translation_error_class_1.EventTranslationError('No records were found in the event'); } if (event.Records.length > 1) { throw new event_translation_error_class_1.EventTranslationError('Multiple records were found in the event'); } const recordBody = event.Records[0].body; const parsedRecordBody = JSON.parse(recordBody); return new application_1.BaseRequest(parsedRecordBody); }); } } exports.SingleRecordSqsEventTranslator = SingleRecordSqsEventTranslator; //# sourceMappingURL=single-record-sqs-event-translator.class.js.map