1.2.0 • Published 7 years ago
egg-aws-sdk v1.2.0
egg-aws-sdk
AWS sdk plugin for eggjs.
Install
$ npm i egg-aws-sdk --save
Usage
config
// {app_root}/config/plugin.js
exports.awsSdk = {
enable: true,
package: 'egg-aws-sdk',
};
mockService
- app.mockAwsService(serviceName, version, methodName, replyBody) mock the service method with the mock replyBody.
- app.restoreAwsServie(serviceName, version, methodName) restore the mocked mehtod.
Example
- Get S3
const DynamoDB = app.AWS.DynamoDB;
const S3 = app.AWS.S3;
- Mock DynamoDB
const mockBody = {
AccountMaxReadCapacityUnits: 200,
AccountMaxWriteCapacityUnits: 200,
TableMaxReadCapacityUnits: 100,
TableMaxWriteCapacityUnits: 100,
};
app.mockAwsService('dynamodb', '2012-08-10', 'describeLimits', {
statusCode: 200,
body: mockBody,
});
const dynamodb = new app.AWS.DynamoDB({});
const res = await dynamodb.describeLimits().promise();
Questions & Suggestions
Please open an issue here.