@vulkano/core 1.17.2 → 1.17.4

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.
@@ -1,3 +1,5 @@
1
+ const path = require('path');
2
+
1
3
  const merge = require('../libs/Merge');
2
4
 
3
5
  module.exports = function getExpressConfiguration() {
@@ -49,7 +51,7 @@ module.exports = function getExpressConfiguration() {
49
51
  sockets: {},
50
52
  redis: {},
51
53
  multer: {
52
- dest: 'public/files'
54
+ dest: global.PUBLIC_PATH ? path.join(global.PUBLIC_PATH, 'files') : 'public/files'
53
55
  },
54
56
  morgan: {
55
57
  format: 'dev',
@@ -190,9 +190,11 @@ module.exports = function loadServer() {
190
190
  vulkano.use(timeout( expressConfig.timeout || 120000 ));
191
191
 
192
192
  vulkano.use( (req, res, next) => {
193
- if (!req.timedout) {
194
- next();
193
+ if (req.timedout) {
194
+ res.status(503).json({ success: false, statusCode: 503, error: { detail: 'Request timeout' } });
195
+ return;
195
196
  }
197
+ next();
196
198
  });
197
199
 
198
200
  // ---------------
@@ -660,6 +662,12 @@ module.exports = function loadServer() {
660
662
  return;
661
663
  }
662
664
 
665
+ // Timeout — always respond with JSON regardless of request type
666
+ if (req.timedout || (err && err.timeout)) {
667
+ res.status(503).json({ success: false, statusCode: 503, error: { detail: 'Request timeout' } });
668
+ return;
669
+ }
670
+
663
671
  const status = err ? (err.status || 500) : (res.statusCode || 500);
664
672
 
665
673
  res.status(status);
@@ -871,6 +879,9 @@ module.exports = function loadServer() {
871
879
  (pubClient ? pubClient.connect() : null),
872
880
  (subClient ? subClient.connect() : null)
873
881
  ])
882
+ .catch((err) => {
883
+ throw new Error(`Socket Redis adapter failed to connect: ${err.message}`);
884
+ })
874
885
  .then(() => {
875
886
 
876
887
  io.on('connection', (socket) => {
@@ -97,10 +97,12 @@ module.exports = {
97
97
  });
98
98
  }
99
99
 
100
+ // Two queries by design: fetch the full document first so subdocument arrays
101
+ // and nested fields are preserved in the write — a bare $set would drop
102
+ // any subdoc entries not included in the incoming payload.
100
103
  return this.getByField(_id)
101
104
  .then( (record) => {
102
105
 
103
- // Merge current info with incoming values
104
106
  const merged = {
105
107
  ...record,
106
108
  ...filtered,
package/libs/Jwt.js CHANGED
@@ -122,12 +122,16 @@ module.exports = {
122
122
  */
123
123
  decode(token, customKey) {
124
124
 
125
+ if (!token) {
126
+ return null;
127
+ }
128
+
125
129
  const {
126
130
  key,
127
131
  expiration: allowExpiration
128
132
  } = this.getConfig();
129
133
 
130
- let data = {};
134
+ let data = null;
131
135
 
132
136
  try {
133
137
 
@@ -135,12 +139,16 @@ module.exports = {
135
139
  data = this.decrypt(payload);
136
140
 
137
141
  } catch (e) {
138
- console.log('Invalid Token');
142
+ // invalid token
143
+ }
144
+
145
+ if (!data) {
146
+ return null;
139
147
  }
140
148
 
141
149
  const {
142
150
  expiration
143
- } = data || {};
151
+ } = data;
144
152
 
145
153
  const now = String(Date.now());
146
154
 
@@ -149,14 +157,13 @@ module.exports = {
149
157
  return null;
150
158
  }
151
159
 
152
- // Ignore expiration field
160
+ // Ignore expiration requirement
153
161
  if (allowExpiration === false) {
154
162
  return data;
155
163
  }
156
164
 
157
- // Expiration must be required
165
+ // Expiration field is required
158
166
  if (!expiration) {
159
- console.log('JWT Without expiration date');
160
167
  return null;
161
168
  }
162
169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulkano/core",
3
- "version": "1.17.2",
3
+ "version": "1.17.4",
4
4
  "description": "A MVC framework using Express 4",
5
5
  "license": "MIT",
6
6
  "author": "Vulkano Team",