@apilogic/migration-tool-api
Version:
Universal sql/no-sql database serverless migration tool
41 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DynamoClient = void 0;
const dynamodb_service_1 = require("@travelhubx/aws/src/services/dynamodb/dynamodb.service");
class DynamoClient extends dynamodb_service_1.DynamodbService {
constructor({ config, options }) {
super();
const tableName = config.config.tableName;
if (!tableName) {
throw new Error(`Invalid DynamoDBConfig ${JSON.stringify(config, null, 4)}`);
}
this.table = tableName;
}
async load(payload) {
try {
switch (payload.operation) {
case 'GetItem':
return await this.getItemById(payload);
case 'PutItem':
return await this.putItem(payload.item);
case 'UpdateItem':
return await this.updateItem(payload);
case 'Scan':
return await this.scan();
default:
throw new Error(`Unknown operation name: ${payload.operation}`);
}
}
catch (e) {
if (e.code) {
console.log('Error while executing Local DynamoDB');
console.log(JSON.stringify(payload, null, 4));
console.log(e);
e.extensions = { errorType: 'DynamoDB:' + e.code };
}
throw e;
}
}
}
exports.DynamoClient = DynamoClient;
//# sourceMappingURL=DynamoClient.js.map