impulse-api 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +9 -0
- package/package.json +8 -10
- package/test/integration/routes/sample.js +19 -0
- package/test/server-test.js +8 -51
package/.eslintrc.json
ADDED
package/package.json
CHANGED
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"lint": "eslint --ignore-path .gitignore .",
|
|
13
13
|
"test": "nyc --reporter=lcov --reporter=text-summary mocha",
|
|
14
|
-
"
|
|
14
|
+
"test-server": "node ./test/integration/test-server.js"
|
|
15
15
|
},
|
|
16
|
-
"version": "2.
|
|
16
|
+
"version": "2.1.0",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"async": "
|
|
19
|
-
"aws-sdk": "2.
|
|
18
|
+
"async": "*2.6.4",
|
|
19
|
+
"aws-sdk": "^2.1141.0",
|
|
20
20
|
"cors": "2.8.4",
|
|
21
21
|
"express": "4.16.4",
|
|
22
22
|
"express-fileupload": "^1.1.9",
|
|
@@ -30,13 +30,11 @@
|
|
|
30
30
|
"restify": "^8.5.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"eslint": "
|
|
35
|
-
"eslint-
|
|
36
|
-
"eslint-plugin-import": "2.2.0",
|
|
37
|
-
"istanbul": "0.4.5",
|
|
33
|
+
"eslint": "8.16.0",
|
|
34
|
+
"eslint-config-airbnb-base": "15.0.0",
|
|
35
|
+
"eslint-plugin-import": "2.26.0",
|
|
38
36
|
"mocha": "7.1.1",
|
|
39
|
-
"nyc": "
|
|
37
|
+
"nyc": "15.1.0",
|
|
40
38
|
"pre-commit": "1.1.3",
|
|
41
39
|
"sinon": "4.4.6"
|
|
42
40
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
exports.test = {
|
|
2
|
+
name: 'test-get-person',
|
|
3
|
+
description: 'retrieve a person by name and age',
|
|
4
|
+
method: 'GET',
|
|
5
|
+
endpoint: '/test-get-person',
|
|
6
|
+
version: 'v1',
|
|
7
|
+
inputs: {
|
|
8
|
+
name: {
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
age: {
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
requestBodyOverride: true,
|
|
16
|
+
run: (services, inputs, next) => {
|
|
17
|
+
next(inputs);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/test/server-test.js
CHANGED
|
@@ -116,12 +116,15 @@ describe('server-test', () => {
|
|
|
116
116
|
env: 'test',
|
|
117
117
|
});
|
|
118
118
|
try {
|
|
119
|
-
Api.buildParameters({
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
Api.buildParameters({
|
|
120
|
+
'test-param': {
|
|
121
|
+
required: true
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{}
|
|
125
|
+
);
|
|
124
126
|
} catch (e) {
|
|
127
|
+
console.log(e)
|
|
125
128
|
assert.contains(e.message, 'Missing parameter [test-param]');
|
|
126
129
|
}
|
|
127
130
|
});
|
|
@@ -221,52 +224,6 @@ describe('server-test', () => {
|
|
|
221
224
|
assert.ifError(e);
|
|
222
225
|
}
|
|
223
226
|
});
|
|
224
|
-
it('should not run the formatter if the param is not required and not provided', () => {
|
|
225
|
-
const Api = new Server({
|
|
226
|
-
name: 'test-Server',
|
|
227
|
-
routeDir: './test-routes',
|
|
228
|
-
port: 4000,
|
|
229
|
-
env: 'test',
|
|
230
|
-
});
|
|
231
|
-
try {
|
|
232
|
-
Api.buildParameters({
|
|
233
|
-
param1: undefined
|
|
234
|
-
}, {
|
|
235
|
-
param1: {
|
|
236
|
-
required: false,
|
|
237
|
-
formatter: () => {
|
|
238
|
-
// The formatter should not run, so this error should not be thrown.
|
|
239
|
-
throw new Error('param was formatted');
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
} catch (e) {
|
|
244
|
-
assert.ifError(e);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
it('should not run the validator if the parameter is not required and not provided', () => {
|
|
248
|
-
const Api = new Server({
|
|
249
|
-
name: 'test-Server',
|
|
250
|
-
routeDir: './test-routes',
|
|
251
|
-
port: 4000,
|
|
252
|
-
env: 'test',
|
|
253
|
-
});
|
|
254
|
-
try {
|
|
255
|
-
Api.buildParameters({
|
|
256
|
-
param1: undefined
|
|
257
|
-
}, {
|
|
258
|
-
param1: {
|
|
259
|
-
required: false,
|
|
260
|
-
validate: () => {
|
|
261
|
-
// The validator should not run, so this error should not be thrown.
|
|
262
|
-
throw new Error('param was validated');
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
} catch (e) {
|
|
267
|
-
assert.ifError(e);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
227
|
});
|
|
271
228
|
|
|
272
229
|
describe('#loadRoutes', () => {
|