impulse-api 2.2.0 → 3.0.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/.nvmrc +1 -0
- package/package.json +23 -22
- package/src/server.js +9 -8
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v22.14.0
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"author:": "Dan
|
|
2
|
+
"author:": "Dan Lampman <dan.lampman@gmail.com>",
|
|
3
3
|
"main": "./src/api.js",
|
|
4
4
|
"name": "impulse-api",
|
|
5
|
-
"description": "A
|
|
5
|
+
"description": "A efficient and powerful API with Express under the hood.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"pre-commit": [
|
|
8
|
-
"lint",
|
|
9
8
|
"test"
|
|
10
9
|
],
|
|
11
10
|
"scripts": {
|
|
@@ -13,31 +12,33 @@
|
|
|
13
12
|
"test": "nyc --reporter=lcov --reporter=text-summary mocha",
|
|
14
13
|
"test-server": "node ./test/integration/test-server.js"
|
|
15
14
|
},
|
|
16
|
-
"version": "
|
|
15
|
+
"version": "3.0.0",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22"
|
|
18
|
+
},
|
|
17
19
|
"dependencies": {
|
|
18
|
-
"async": "
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"express": "
|
|
22
|
-
"
|
|
23
|
-
"express-xml-bodyparser": "0.3.0",
|
|
24
|
-
"http-errors": "1.7.2",
|
|
20
|
+
"async": "2.6.4",
|
|
21
|
+
"cors": "2.8.5",
|
|
22
|
+
"express": "4.21.2",
|
|
23
|
+
"express-fileupload": "1.5.1",
|
|
24
|
+
"http-errors": "2.0.0",
|
|
25
25
|
"jsonwebtoken": "8.5.1",
|
|
26
|
-
"lodash": "
|
|
27
|
-
"morgan": "1.
|
|
28
|
-
"multer": "1.4.
|
|
29
|
-
"path-to-regexp": "0.1.
|
|
30
|
-
"restify": "^8.5.1"
|
|
26
|
+
"lodash": "4.17.21",
|
|
27
|
+
"morgan": "1.10.0",
|
|
28
|
+
"multer": "1.4.5-lts.2",
|
|
29
|
+
"path-to-regexp": "0.1.12"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"eslint": "
|
|
34
|
-
"eslint-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"nyc": "15.1.0",
|
|
38
|
-
"pre-commit": "1.1.3",
|
|
32
|
+
"eslint": "^9.23.0",
|
|
33
|
+
"eslint-plugin-import": "^2.31.0",
|
|
34
|
+
"nyc": "^17.1.0",
|
|
35
|
+
"pre-commit": "^1.2.2",
|
|
39
36
|
"sinon": "4.4.6"
|
|
40
37
|
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"http",
|
|
40
|
+
"web-server"
|
|
41
|
+
],
|
|
41
42
|
"repository": {
|
|
42
43
|
"type": "git",
|
|
43
44
|
"url": "https://github.com/dan-lampman/impulse-api.git"
|
package/src/server.js
CHANGED
|
@@ -3,14 +3,14 @@ const express = require('express');
|
|
|
3
3
|
const multer = require('multer');
|
|
4
4
|
const cors = require('cors');
|
|
5
5
|
const morgan = require('morgan');
|
|
6
|
-
const
|
|
6
|
+
const pathToRegexp = require('path-to-regexp');
|
|
7
7
|
const fileUpload = require('express-fileupload');
|
|
8
|
-
const xmlparser = require('express-xml-bodyparser');
|
|
9
8
|
|
|
10
9
|
const Auth = require('./auth');
|
|
11
10
|
const Errors = require('./errors');
|
|
12
11
|
const Container = require('./container');
|
|
13
12
|
|
|
13
|
+
|
|
14
14
|
class Server {
|
|
15
15
|
constructor(config) {
|
|
16
16
|
if (!config) {
|
|
@@ -94,7 +94,6 @@ class Server {
|
|
|
94
94
|
this.http.use(express.json({
|
|
95
95
|
extended: true,
|
|
96
96
|
}));
|
|
97
|
-
this.http.use(xmlparser())
|
|
98
97
|
this.http.use(fileUpload({
|
|
99
98
|
preserveExtension: 10
|
|
100
99
|
}));
|
|
@@ -358,13 +357,15 @@ class Server {
|
|
|
358
357
|
|
|
359
358
|
checkConflictingRoutes(routes, callback) {
|
|
360
359
|
routes.forEach((route1) => {
|
|
361
|
-
const route1Regexp =
|
|
360
|
+
const route1Regexp = pathToRegexp(route1.endpoint);
|
|
362
361
|
|
|
363
362
|
routes.forEach((route2) => {
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
363
|
+
if (
|
|
364
|
+
route1.method === route2.method &&
|
|
365
|
+
route1.endpoint !== route2.endpoint &&
|
|
366
|
+
route1Regexp.test(route2.endpoint)
|
|
367
|
+
) {
|
|
368
|
+
callback(route1, route2);
|
|
368
369
|
}
|
|
369
370
|
});
|
|
370
371
|
});
|