1.2.0 • Published 7 years ago

egg-aws-sdk v1.2.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

egg-aws-sdk

NPM version build status Test coverage David deps Known Vulnerabilities npm download

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.

License

MIT