@adaptivestone/framework 5.0.0-alpha.18 → 5.0.0-alpha.19

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/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ ### 5.0.0-alpha.19
2
+
3
+ [NEW] added modelSchemaOptions for models
4
+
1
5
  ### 5.0.0-alpha.18
2
6
 
3
- [BREAKING] default aut responce changed to be unified. {token, user} = > {data:{token, user}}
7
+ [BREAKING] default auth responce changed to be unified. {token, user} = > {data:{token, user}}
4
8
  [UPDATE] RateLimiter updae key generation
5
9
 
6
10
  ### 5.0.0-alpha.17
@@ -1,6 +1,6 @@
1
- import Base from './Base.js';
1
+ import type Base from './Base.js';
2
2
  import { Model, Schema } from 'mongoose';
3
- import Server from '../server.js';
3
+ import type Server from '../server.js';
4
4
 
5
5
  interface AbstractModel<T extends Document> extends Model, Base {
6
6
  constructor(app: Server['app'], callback?: () => void);
@@ -12,7 +12,10 @@ class AbstractModel extends Base {
12
12
  */
13
13
  constructor(app, callback = () => {}) {
14
14
  super(app);
15
- this.mongooseSchema = new mongoose.Schema(this.modelSchema);
15
+ this.mongooseSchema = new mongoose.Schema(
16
+ this.modelSchema,
17
+ this.modelSchemaOptions,
18
+ );
16
19
  mongoose.set('strictQuery', true);
17
20
  this.mongooseSchema.set('timestamps', true);
18
21
  this.mongooseSchema.set('minimize', false);
@@ -58,6 +61,14 @@ class AbstractModel extends Base {
58
61
  return {};
59
62
  }
60
63
 
64
+ /**
65
+ * Mongoose schema options
66
+ */
67
+ // eslint-disable-next-line class-methods-use-this
68
+ get modelSchemaOptions() {
69
+ return {};
70
+ }
71
+
61
72
  static get loggerGroup() {
62
73
  return 'model';
63
74
  }
package/modules/Base.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import winston from 'winston';
2
- import Server from '../server.js';
3
- import type { Dirent } from 'fs';
1
+ import type winston from 'winston';
2
+ import type Server from '../server.js';
3
+ import type { Dirent } from 'node.fs';
4
4
 
5
5
  declare class Base {
6
6
  app: Server['app'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptivestone/framework",
3
- "version": "5.0.0-alpha.18",
3
+ "version": "5.0.0-alpha.19",
4
4
  "description": "Adaptive stone node js framework",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -87,7 +87,7 @@ class RateLimiter extends AbstractMiddleware {
87
87
  }
88
88
  }
89
89
  if (route) {
90
- key.push(req.baseUrl + req.path); // to avoid quesry params
90
+ key.push(`${req.baseUrl ?? ''}${req.path ?? ''}`); // to avoid quesry params
91
91
  }
92
92
  if (user && req.appInfo?.user) {
93
93
  key.push(req.appInfo?.user.id);