Skip to content

Commit fac4d5f

Browse files
committed
Cleanup
1 parent e3a7cb6 commit fac4d5f

File tree

83 files changed

+119
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+119
-293
lines changed

.babelrc

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"plugins": [
3+
[
4+
"module-resolver",
5+
{
6+
"root": [
7+
"./src",
8+
"./test"
9+
]
10+
}
11+
]
12+
],
13+
"presets": [
14+
[
15+
"@babel/preset-env",
16+
{
17+
"targets": {
18+
"node": "current"
19+
}
20+
}
21+
]
22+
]
23+
}

.eslintrc.json

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
{
2+
"parser": "babel-eslint",
23
"extends": [
3-
"plugin:prettier/recommended"
4+
"standard"
45
],
56
"env": {
67
"jest": true,
78
"node": true
89
},
10+
"plugins": [],
911
"parserOptions": {
10-
"ecmaVersion": 2018
12+
"ecmaVersion": 2018,
13+
"allowImportExportEverywhere": true
1114
},
1215
"rules": {
16+
"template-curly-spacing": "off",
17+
"indent": [
18+
"warn",
19+
2,
20+
{
21+
"ignoredNodes": [
22+
"TemplateLiteral"
23+
],
24+
"SwitchCase": 1
25+
}
26+
],
1327
"no-unused-vars": 1
1428
}
1529
}

.npmignore

-1
This file was deleted.

.prettierrc

-5
This file was deleted.

__tests__/lambdaRunnerGo.test.js

-59
This file was deleted.

__tests__/lambdaRunnerPython.test.js

-46
This file was deleted.

__tests__/lambdaRunnerRuby.test.js

-72
This file was deleted.

index.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require('path')
44
const createServer = require('./lib/server')
55

66
class ServerlessAppSyncPlugin {
7-
constructor(serverless, options) {
7+
constructor (serverless, options) {
88
this.serverless = serverless
99
this.servicePath = serverless.config.servicePath
1010
this.serverlessLog = serverless.cli.log.bind(serverless.cli)
@@ -82,19 +82,18 @@ class ServerlessAppSyncPlugin {
8282
}
8383
}
8484

85-
get port() {
85+
get port () {
8686
const config = (this.service.custom && this.service.custom.dynamodb) || {}
8787
const port = _.get(config, 'start.port', null)
8888
return port
8989
}
9090

91-
async startHandler(isStandalone = false) {
91+
async startHandler (isStandalone = false) {
9292
this._setOptions()
9393
let dynamodb = null
9494

9595
try {
96-
if (!this.options.dynamodb.client.endpoint)
97-
throw new Error('Provide a DynamoDB endpoint')
96+
if (!this.options.dynamodb.client.endpoint) { throw new Error('Provide a DynamoDB endpoint') }
9897

9998
const { DynamoDB } = require('aws-sdk')
10099
dynamodb = new DynamoDB(this.options.dynamodb.client)
@@ -133,14 +132,14 @@ class ServerlessAppSyncPlugin {
133132
}
134133
}
135134

136-
async startStandaloneHandler() {
135+
async startStandaloneHandler () {
137136
this.serverlessLog('AppSync Standalone')
138137
return Promise.resolve(this.startHandler(true)).then(() =>
139138
this._listenForTermination()
140139
)
141140
}
142141

143-
endHandler() {
142+
endHandler () {
144143
if (this.emulator) {
145144
// DynamoDB only needs stopping if we actually started it. If an external
146145
// connection was specified then this.emulator will be undefined.
@@ -154,10 +153,10 @@ class ServerlessAppSyncPlugin {
154153
}
155154
}
156155

157-
_setOptions() {
156+
_setOptions () {
158157
// Merge the different sources of values for this.options
159158
// Precedence is: command line options, YAML options, defaults.
160-
//this.serverlessLog(JSON.stringify(this.options));
159+
// this.serverlessLog(JSON.stringify(this.options));
161160
const defaultOpts = {
162161
port: null,
163162
elastic: {
@@ -177,9 +176,7 @@ class ServerlessAppSyncPlugin {
177176
}
178177
}
179178

180-
let appSyncOfflineOptions = (this.serverless.service.custom || {})[
181-
'appSyncOffline'
182-
]
179+
const appSyncOfflineOptions = (this.serverless.service.custom || {}).appSyncOffline
183180

184181
this.options = _.merge(
185182
{},
@@ -211,7 +208,7 @@ class ServerlessAppSyncPlugin {
211208
)
212209
}
213210

214-
_listenForTermination() {
211+
_listenForTermination () {
215212
// SIGINT will be usually sent when user presses ctrl+c
216213
const waitForSigInt = new Promise(resolve => {
217214
process.on('SIGINT', () => resolve('SIGINT'))

lib/lambdaSource.js

+1-32
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,6 @@ const lambdaSource = async (
4343
)
4444
let child = null
4545

46-
if (fnConfig.runtime && !fnConfig.runtime.includes('node')) {
47-
let extHandlerMethod = ''
48-
let runner = null
49-
if (fnConfig.runtime.indexOf('python') >= 0) {
50-
extHandlerMethod = fn
51-
runner = PythonRunner
52-
} else if (fnConfig.runtime.indexOf('ruby') >= 0) {
53-
extHandlerMethod = fn
54-
runner = RubyRunner
55-
} else if (fnConfig.runtime.indexOf('go') >= 0) {
56-
extHandlerMethod = fnConfig.handler.split('/').pop()
57-
runner = GoRunner
58-
}
59-
60-
child = fork(runner, [], {
61-
env: {
62-
...process.env,
63-
...dynamodbTableAliases,
64-
DYNAMODB_ENDPOINT: dynamodbEndpoint,
65-
...provider.environment,
66-
...fnConfig.environment
67-
},
68-
stdio: [0, 1, 2, 'ipc']
69-
})
70-
71-
child.send({
72-
serverlessDirectory,
73-
handlerMethod: extHandlerMethod,
74-
payload
75-
})
76-
} else {
7746
const childOptions = {
7847
env: {
7948
...process.env,
@@ -93,7 +62,7 @@ const lambdaSource = async (
9362
handlerMethod,
9463
payload
9564
})
96-
}
65+
9766

9867
const response = await e2p(child, 'message')
9968

lib/log.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
process.env.CONSOLA_LEVEL = process.env.DEBUG_LEVEL
2-
? process.env.DEBUG_LEVEL
3-
: 'silent'
1+
process.env.CONSOLA_LEVEL = process.env.DEBUG ? 'debug' : 'silent'
2+
43
module.exports = require('consola')

0 commit comments

Comments
 (0)