anote-server-libs 0.1.2 → 0.2.1
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/package.json +5 -5
- package/services/utils.js +3 -3
- package/services/utils.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anote-server-libs",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Helpers for express-TS servers",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
"author": "Mathonet Gregoire",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@types/memcached": "2.2.7",
|
|
20
|
+
"@types/mssql": "7.1.4",
|
|
21
|
+
"@types/pg": "8.6.4",
|
|
22
|
+
"memcached": "2.2.2",
|
|
19
23
|
"mssql": "8.0.2",
|
|
20
24
|
"pg": "8.7.3"
|
|
21
25
|
},
|
|
22
26
|
"peerDependencies": {
|
|
23
27
|
"express": "4.17.2",
|
|
24
28
|
"jsonschema": "1.4.0",
|
|
25
|
-
"memcached": "2.2.2",
|
|
26
29
|
"node-forge": "1.2.1",
|
|
27
30
|
"winston": "3.5.1"
|
|
28
31
|
},
|
|
29
32
|
"devDependencies": {
|
|
30
33
|
"@types/express": "4.17.13",
|
|
31
|
-
"@types/memcached": "2.2.7",
|
|
32
|
-
"@types/mssql": "7.1.4",
|
|
33
34
|
"@types/node": "14.18.2",
|
|
34
35
|
"@types/node-forge": "1.0.0",
|
|
35
|
-
"@types/pg": "8.6.4",
|
|
36
36
|
"typescript": "4.5.5"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/services/utils.js
CHANGED
|
@@ -99,11 +99,11 @@ function idempotent(repo, debug, logger) {
|
|
|
99
99
|
jsonTerminator(obj);
|
|
100
100
|
});
|
|
101
101
|
}).bind(res);
|
|
102
|
-
res.end = (function () {
|
|
102
|
+
res.end = (function (buf) {
|
|
103
103
|
repo.ApiCall.create({
|
|
104
104
|
id: idempotenceKey,
|
|
105
105
|
responseCode: res.statusCode,
|
|
106
|
-
responseJson:
|
|
106
|
+
responseJson: buf && buf.toString(),
|
|
107
107
|
expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000)
|
|
108
108
|
}).then(() => endTerminator(), err => {
|
|
109
109
|
if (err)
|
|
@@ -116,7 +116,7 @@ function idempotent(repo, debug, logger) {
|
|
|
116
116
|
else
|
|
117
117
|
res.status(417).json({
|
|
118
118
|
responseCode: call.responseCode,
|
|
119
|
-
responseBody:
|
|
119
|
+
responseBody: call.responseJson
|
|
120
120
|
});
|
|
121
121
|
}, err => res.status(500).json({
|
|
122
122
|
error: {
|
package/services/utils.ts
CHANGED
|
@@ -97,11 +97,11 @@ export function idempotent(repo: BaseModelRepository, debug: boolean, logger: Lo
|
|
|
97
97
|
jsonTerminator(obj);
|
|
98
98
|
});
|
|
99
99
|
}).bind(res);
|
|
100
|
-
res.end = (function() {
|
|
100
|
+
res.end = (function(buf: string) {
|
|
101
101
|
repo.ApiCall.create({
|
|
102
102
|
id: idempotenceKey,
|
|
103
103
|
responseCode: res.statusCode,
|
|
104
|
-
responseJson:
|
|
104
|
+
responseJson: buf && buf.toString(),
|
|
105
105
|
expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000)
|
|
106
106
|
}).then(() => endTerminator(), err => {
|
|
107
107
|
if(err) logger.warn('Cannot save idempotent key: %j', err);
|
|
@@ -111,7 +111,7 @@ export function idempotent(repo: BaseModelRepository, debug: boolean, logger: Lo
|
|
|
111
111
|
next();
|
|
112
112
|
} else res.status(417).json({
|
|
113
113
|
responseCode: call.responseCode,
|
|
114
|
-
responseBody:
|
|
114
|
+
responseBody: call.responseJson
|
|
115
115
|
});
|
|
116
116
|
}, err => res.status(500).json({
|
|
117
117
|
error: {
|