nodester 0.4.9 → 0.5.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.
@@ -478,17 +478,26 @@ module.exports = class NodesterApplication extends Emitter {
478
478
  /**
479
479
  * Stops server
480
480
  *
481
+ * @param {Function} callback
482
+ *
481
483
  * @access public
482
484
  */
483
- stop() {
485
+ stop(callback) {
484
486
  if (this._isListening !== true) {
485
- console.warn('Nothing to stop. Server is not listening.');
487
+ consl.warn('nothing to stop. Server is not listening.');
486
488
  return;
487
489
  }
488
490
 
489
- this.server.close();
490
- this._isListening = false;
491
+ this.server.close(() => {
492
+ this._isListening = false;
493
+ this._router.unlock();
491
494
 
492
- this._router.unlock();
495
+ if (typeof callback === 'function') {
496
+ callback();
497
+ }
498
+ else if (!!callback) {
499
+ consl.warn(`argument 'callback' in stop() must be of type: function.`);
500
+ }
501
+ });
493
502
  }
494
503
  }
@@ -8,11 +8,8 @@
8
8
  const { IncomingMessage } = require('http');
9
9
 
10
10
  const isIP = require('net').isIP;
11
- const typeis = require('type-is');
12
11
  const fresh = require('fresh');
13
- const parseRange = require('range-parser');
14
12
  const parse = require('parseurl');
15
- const proxyaddr = require('proxy-addr');
16
13
 
17
14
  const { defineGetter } = require('./utils');
18
15
 
@@ -7,7 +7,8 @@
7
7
 
8
8
 
9
9
  exports = module.exports = {
10
- error: _error
10
+ error: _error,
11
+ warn: _warn
11
12
  }
12
13
 
13
14
  /**
@@ -19,5 +20,19 @@ exports = module.exports = {
19
20
  * @access public
20
21
  */
21
22
  function _error(err) {
22
- console.error(err.stack || err.toString());
23
+ console.error(err.stack || err.toString());
24
+ }
25
+
26
+
27
+ /**
28
+ * Log warning with nodester prefix using console.warning.
29
+ *
30
+ * @param {Error} err
31
+ *
32
+ * @alias error
33
+ * @access public
34
+ */
35
+ function _warn(...args) {
36
+ const prefix = '[nodester] warning:';
37
+ console.warn(prefix, ...args);
23
38
  }
@@ -11,6 +11,9 @@ const CLAUSES = require('../constants/Clauses');
11
11
  const { isModel } = require('../utils/models');
12
12
  const { ensure } = require('nodester/validators/arguments');
13
13
 
14
+ // Console:
15
+ const consl = require('nodester/loggers/console');
16
+
14
17
 
15
18
  /**
16
19
  * @class
@@ -107,12 +110,13 @@ module.exports = class NodesterFilter {
107
110
  // Empty bounds:
108
111
  if (!!includeFilter.statics.clauses.limit) {
109
112
  const msg = [
110
- `(nodester) warning: include "${ includeName }" has`,
111
- `association type of "${ associationType }", but has a filter clause "limit",`,
113
+ `include "${ includeName }" has association type of`,
114
+ `"${ associationType }", but has a filter clause "limit",`,
112
115
  `which is forbidden on any association type except for "HasMany".`,
113
- `It was automatically removed from clauses.`
116
+ `It was automatically removed from clauses.`,
117
+ `Consider also removing it from your code.`
114
118
  ].join(' ');
115
- console.warn(msg);
119
+ consl.warn(msg);
116
120
  }
117
121
  delete includeFilter.statics.clauses.limit;
118
122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodester",
3
- "version": "0.4.9",
3
+ "version": "0.5.0",
4
4
  "description": "A versatile REST framework for Node.js",
5
5
  "directories": {
6
6
  "docs": "docs",
@@ -79,7 +79,7 @@
79
79
  "@js-temporal/polyfill": "^0.4.3",
80
80
  "body-parser": "^1.20.2",
81
81
  "common-js-file-extensions": "^1.0.4",
82
- "cookie": "^0.5.0",
82
+ "cookie": "^1.0.0",
83
83
  "cookie-signature": "^1.2.0",
84
84
  "debug": "^4.3.4",
85
85
  "etag": "^1.8.1",
@@ -92,17 +92,13 @@
92
92
  "mysql2": "^3.6.0",
93
93
  "pg": "^8.11.3",
94
94
  "pg-hstore": "^2.3.4",
95
- "proxy-addr": "^2.0.7",
96
95
  "qs": "^6.11.0",
97
- "range-parser": "^1.2.1",
98
- "sequelize": "^6.6.5",
99
- "type-is": "^1.6.18",
100
- "vary": "^1.1.2"
96
+ "sequelize": "^6.6.5"
101
97
  },
102
98
  "devDependencies": {
103
99
  "eslint": "^8.55.0",
104
100
  "eslint-plugin-jsdoc": "^46.9.0",
105
- "jest": "^29.4.2"
101
+ "jest": "^29.7.0"
106
102
  },
107
103
  "engines": {
108
104
  "node": ">= 12.17.0"
@@ -31,10 +31,10 @@ describe('nodester application', () => {
31
31
  expect(app.isListening).toBe(true);
32
32
  expect(app.middlewaresStack.length).toBe(4);
33
33
 
34
- app.stop();
35
-
36
- expect(app.isLocked).toBe(false);
37
- expect(app.isListening).toBe(false);
34
+ app.stop(() => {
35
+ expect(app.isLocked).toBe(false);
36
+ expect(app.isListening).toBe(false);
37
+ });
38
38
  });
39
39
  });
40
40
  });