Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6deda45

Browse files
committedDec 14, 2020
Fix Lint Errors
1 parent 5c7fd98 commit 6deda45

File tree

5 files changed

+38
-22
lines changed

5 files changed

+38
-22
lines changed
 

‎src/serverless.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ const { mergeDeepRight, pick } = require('ramda');
55
const AWS = require('aws-sdk');
66
// eslint-disable-next-line import/no-unresolved
77
const { Component } = require('@serverless/core');
8-
const { log, createTable, deleteTable, describeTable, updateTable, updateTimeToLive } = require('./utils');
8+
const {
9+
log,
10+
createTable,
11+
deleteTable,
12+
describeTable,
13+
updateTable,
14+
updateTimeToLive,
15+
} = require('./utils');
916

1017
const outputsList = ['name', 'arn', 'region'];
1118

@@ -27,7 +34,7 @@ const defaults = {
2734
name: null,
2835
region: 'us-east-1',
2936
deletionPolicy: 'delete',
30-
timeToLiveSpecification: undefined
37+
timeToLiveSpecification: undefined,
3138
};
3239

3340
class AwsDynamoDb extends Component {
@@ -90,8 +97,7 @@ class AwsDynamoDb extends Component {
9097
}
9198

9299
if (config.timeToLiveSpecification) {
93-
await updateTimeToLive({dynamodb, ...config})
94-
100+
await updateTimeToLive({ dynamodb, ...config });
95101
}
96102

97103
log(`Table ${config.name} was successfully deployed to the ${config.region} region.`);

‎src/utils.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,21 @@ async function deleteTable({ dynamodb, name }) {
119119
return !!res;
120120
}
121121

122-
async function updateTimeToLive({dynamodb, name, timeToLiveSpecification= {}}) {
123-
return await dynamodb.waitFor('tableExists', { TableName: name}, async function(err, data) {
124-
if (err) throw err;
125-
return await dynamodb
126-
.updateTimeToLive({
127-
TableName: name,
128-
TimeToLiveSpecification: {
129-
AttributeName: timeToLiveSpecification.AttributeName,
130-
Enabled: timeToLiveSpecification.Enabled,
131-
}
132-
}).promise();
133-
}).promise();
122+
async function updateTimeToLive({ dynamodb, name, timeToLiveSpecification = {} }) {
123+
return await dynamodb
124+
.waitFor('tableExists', { TableName: name }, async (err) => {
125+
if (err) throw err;
126+
return await dynamodb
127+
.updateTimeToLive({
128+
TableName: name,
129+
TimeToLiveSpecification: {
130+
AttributeName: timeToLiveSpecification.AttributeName,
131+
Enabled: timeToLiveSpecification.Enabled,
132+
},
133+
})
134+
.promise();
135+
})
136+
.promise();
134137
}
135138

136139
module.exports = {

‎templates/aws-dynamodb-starter/serverless.template.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ org: serverlessinc
33
description: Deploys a serverless NoSQL database powered by AWS DynamoDB
44
keywords: aws, serverless, nosql, database
55
repo: https://github.com/serverless-components/aws-dynamodb
6-
license: MIT
6+
license: MIT

‎test/integration.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { sleep, generateId, getCredentials, getServerlessSdk, getTable, getTableTimeToLive } = require('./utils');
3+
const { sleep, generateId, getCredentials, getServerlessSdk, getTable } = require('./utils');
44

55
// set enough timeout for deployment to finish
66
jest.setTimeout(30000);
@@ -17,8 +17,8 @@ const instanceYaml = {
1717
inputs: {
1818
deletionPolicy: 'delete',
1919
timeToLiveSpecification: {
20-
AttributeName : 'expires',
21-
Enabled: true
20+
AttributeName: 'expires',
21+
Enabled: true,
2222
},
2323
attributeDefinitions: [
2424
{
@@ -79,7 +79,7 @@ it('should successfully deploy dynamodb table and local index', async () => {
7979

8080
const res = await getTable(credentials, name);
8181

82-
//const resTTL = await getTableTimeToLive(credentials, name);
82+
// const resTTL = await getTableTimeToLive(credentials, name);
8383

8484
expect(instance.outputs.name).toBeDefined();
8585
expect(instance.outputs.arn).toBeDefined();

‎test/utils.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,11 @@ const getTableTimeToLive = async (credentials, tableName) => {
8686
.promise();
8787
};
8888

89-
module.exports = { sleep, generateId, getCredentials, getServerlessSdk, getTable, getTableTimeToLive };
89+
module.exports = {
90+
sleep,
91+
generateId,
92+
getCredentials,
93+
getServerlessSdk,
94+
getTable,
95+
getTableTimeToLive,
96+
};

0 commit comments

Comments
 (0)
Please sign in to comment.