fastify-txstate 2.4.2 → 2.4.3
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/lib/index.js +12 -11
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FailedValidationError = exports.HttpError = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
8
7
|
const fastify_1 = require("fastify");
|
|
9
8
|
const fs_1 = __importDefault(require("fs"));
|
|
10
9
|
const http_1 = __importDefault(require("http"));
|
|
@@ -52,21 +51,23 @@ class Server {
|
|
|
52
51
|
await res.status(403).send('Origin check failed. Suspected XSRF attack.');
|
|
53
52
|
return res;
|
|
54
53
|
}
|
|
55
|
-
res.header('Access-Control-Allow-Origin', req.headers.origin);
|
|
56
|
-
|
|
54
|
+
void res.header('Access-Control-Allow-Origin', req.headers.origin);
|
|
55
|
+
if (req.headers['access-control-request-headers'])
|
|
56
|
+
void res.header('Access-Control-Allow-Headers', req.headers['access-control-request-headers']);
|
|
57
57
|
});
|
|
58
58
|
this.app.options('*', async (req, res) => {
|
|
59
59
|
await res.send();
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
this.app.addHook('onSend',
|
|
63
|
-
resp
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
this.app.addHook('onSend', this.https && process.env.NODE_ENV !== 'development'
|
|
63
|
+
? async (_, resp) => {
|
|
64
|
+
resp.removeHeader('X-Powered-By');
|
|
65
|
+
void resp.header('Strict-Transport-Security', 'max-age=31536000');
|
|
66
|
+
}
|
|
67
|
+
: async (_, resp) => {
|
|
68
|
+
resp.removeHeader('X-Powered-By');
|
|
69
|
+
});
|
|
70
|
+
this.app.setNotFoundHandler((req, res) => { void res.status(404).send('Not Found.'); });
|
|
70
71
|
this.app.setErrorHandler(async (err, req, res) => {
|
|
71
72
|
req.log.warn(err);
|
|
72
73
|
for (const errorHandler of this.errorHandlers) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastify-txstate",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "A small wrapper for fastify providing a set of common conventions & utility functions we use.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"require": "./lib/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/node": "^16.7.2",
|
|
26
26
|
"axios": ">=0.20.0",
|
|
27
27
|
"chai": "^4.2.0",
|
|
28
|
-
"eslint-config-standard-with-typescript": "^
|
|
28
|
+
"eslint-config-standard-with-typescript": "^22.0.0",
|
|
29
29
|
"mocha": "^9.1.0",
|
|
30
30
|
"ts-node": "^10.2.1",
|
|
31
31
|
"typescript": "^4.4.2"
|