@@ -3,7 +3,7 @@ const _ = require("lodash");
3
3
const BbPromise = require ( "bluebird" ) ;
4
4
const AWS = require ( "aws-sdk" ) ;
5
5
const dynamodbLocal = require ( "dynamodb-localhost" ) ;
6
- const { writeSeeds , locateSeeds } = require ( "./src/seeder" ) ;
6
+ const seeder = require ( "./src/seeder" ) ;
7
7
8
8
class ServerlessDynamodbLocal {
9
9
constructor ( serverless , options ) {
@@ -95,7 +95,7 @@ class ServerlessDynamodbLocal {
95
95
}
96
96
97
97
dynamodbOptions ( ) {
98
- const { config } = this ;
98
+ const config = this . config ;
99
99
const port = _ . get ( config , "start.port" , 8000 ) ;
100
100
const dynamoOptions = {
101
101
endpoint : `http://localhost:${ port } ` ,
@@ -112,19 +112,19 @@ class ServerlessDynamodbLocal {
112
112
113
113
migrateHandler ( ) {
114
114
const dynamodb = this . dynamodbOptions ( ) ;
115
- const { tables } = this ;
115
+ const tables = this . tables ;
116
116
return BbPromise . each ( tables , ( table ) => this . createTable ( dynamodb , table ) ) ;
117
117
}
118
118
119
119
seedHandler ( ) {
120
- const { doc : documentClient } = this . dynamodbOptions ( ) ;
121
- const { seedSources } = this ;
120
+ const documentClient = this . dynamodbOptions ( ) . doc ;
121
+ const seedSources = this . seedSources ;
122
122
return BbPromise . each ( seedSources , ( source ) => {
123
123
if ( ! source . table ) {
124
124
throw new Error ( "seeding source \"table\" property not defined" ) ;
125
125
}
126
- return locateSeeds ( source . sources || [ ] )
127
- . then ( ( seeds ) => writeSeeds ( documentClient , source . table , seeds ) ) ;
126
+ return seeder . locateSeeds ( source . sources || [ ] )
127
+ . then ( ( seeds ) => seeder . writeSeeds ( documentClient , source . table , seeds ) ) ;
128
128
} ) ;
129
129
}
130
130
@@ -133,12 +133,12 @@ class ServerlessDynamodbLocal {
133
133
}
134
134
135
135
installHandler ( ) {
136
- const { options } = this ;
136
+ const options = this . options ;
137
137
return new BbPromise ( ( resolve ) => dynamodbLocal . install ( resolve , options . localPath ) ) ;
138
138
}
139
139
140
140
startHandler ( ) {
141
- const { config } = this ;
141
+ const config = this . config ;
142
142
const options = _ . merge ( {
143
143
sharedDb : this . options . sharedDb || true
144
144
} ,
@@ -172,7 +172,7 @@ class ServerlessDynamodbLocal {
172
172
get seedSources ( ) {
173
173
const config = this . service . custom . dynamodb ;
174
174
const seedConfig = _ . get ( config , "seed" , { } ) ;
175
- const { seed } = this . options ;
175
+ const seed = this . options . seed ;
176
176
if ( ! seed ) {
177
177
console . log ( "No seed option defined. Cannot seed data." ) ;
178
178
return [ ] ;
0 commit comments