fastify-txstate 2.3.2 → 2.4.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.
Files changed (2) hide show
  1. package/lib/index.js +8 -3
  2. package/package.json +2 -8
package/lib/index.js CHANGED
@@ -51,6 +51,11 @@ class Server {
51
51
  await res.status(403).send('Origin check failed. Suspected XSRF attack.');
52
52
  return res;
53
53
  }
54
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
55
+ res.header('Access-Control-Allow-Origin', req.headers.origin);
56
+ });
57
+ this.app.options('*', async (req, res) => {
58
+ await res.send();
54
59
  });
55
60
  }
56
61
  this.app.addHook('onSend', async (req, resp, payload) => {
@@ -102,7 +107,7 @@ class Server {
102
107
  var _a;
103
108
  const customPort = port !== null && port !== void 0 ? port : parseInt((_a = process.env.PORT) !== null && _a !== void 0 ? _a : '0');
104
109
  if (customPort) {
105
- await this.app.listen(customPort, '::');
110
+ await this.app.listen(customPort, '0.0.0.0');
106
111
  }
107
112
  else if (this.https) {
108
113
  // redirect 80 to 443
@@ -111,10 +116,10 @@ class Server {
111
116
  res.writeHead(301, { Location: 'https://' + ((_c = (_b = (_a = req === null || req === void 0 ? void 0 : req.headers) === null || _a === void 0 ? void 0 : _a.host) === null || _b === void 0 ? void 0 : _b.replace(/:\d+$/, '')) !== null && _c !== void 0 ? _c : '') + ((_d = req.url) !== null && _d !== void 0 ? _d : '') });
112
117
  res.end();
113
118
  }).listen(80);
114
- await this.app.listen(443, '::');
119
+ await this.app.listen(443, '0.0.0.0');
115
120
  }
116
121
  else {
117
- await this.app.listen(80, '::');
122
+ await this.app.listen(80, '0.0.0.0');
118
123
  }
119
124
  }
120
125
  addErrorHandler(handler) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify-txstate",
3
- "version": "2.3.2",
3
+ "version": "2.4.1",
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",
@@ -23,15 +23,9 @@
23
23
  "@types/chai": "^4.2.14",
24
24
  "@types/mocha": "^9.0.0",
25
25
  "@types/node": "^16.7.2",
26
- "@typescript-eslint/eslint-plugin": "^4.5.0",
27
- "@typescript-eslint/parser": "^4.5.0",
28
- "axios": "^0.21.1",
26
+ "axios": ">=0.20.0",
29
27
  "chai": "^4.2.0",
30
- "eslint": "^7.11.0",
31
28
  "eslint-config-standard-with-typescript": "^21.0.1",
32
- "eslint-plugin-import": "^2.22.1",
33
- "eslint-plugin-node": "^11.1.0",
34
- "eslint-plugin-promise": "^5.1.0",
35
29
  "mocha": "^9.1.0",
36
30
  "ts-node": "^10.2.1",
37
31
  "typescript": "^4.4.2"