@adaptivestone/framework 5.0.0-alpha.12 → 5.0.0-alpha.13

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,3 +1,9 @@
1
+ ### 5.0.0-alpha.13
2
+
3
+ [UPDATE] update deps
4
+ [UPDATE] update i18n internal implementation
5
+ [CHANGE] disable https server view
6
+
1
7
  ### 5.0.0-alpha.12
2
8
 
3
9
  [UPDATE] update deps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptivestone/framework",
3
- "version": "5.0.0-alpha.12",
3
+ "version": "5.0.0-alpha.13",
4
4
  "description": "Adaptive stone node js framework",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -35,10 +35,8 @@
35
35
  "formidable": "^3.5.1",
36
36
  "html-to-text": "^9.0.3",
37
37
  "i18next": "^23.2.8",
38
- "i18next-chained-backend": "^4.0.0",
39
38
  "i18next-fs-backend": "^2.0.0",
40
39
  "juice": "^11.0.0",
41
- "mime": "^4.0.0",
42
40
  "minimist": "^1.2.5",
43
41
  "mongoose": "^8.0.0",
44
42
  "nodemailer": "^6.6.3",
@@ -43,8 +43,10 @@ class Cache extends Base {
43
43
  }
44
44
  const key = this.getKeyWithNameSpace(keyValue);
45
45
  // 5 mins default
46
- let resolve = null;
47
- let reject = null;
46
+ // eslint-disable-next-line no-unused-vars
47
+ let resolve = (value) => {};
48
+ // eslint-disable-next-line no-unused-vars
49
+ let reject = (value) => {};
48
50
  if (this.promiseMapping.has(key)) {
49
51
  return this.promiseMapping.get(key);
50
52
  }
@@ -71,7 +73,7 @@ class Cache extends Base {
71
73
 
72
74
  this.redisClient.set(
73
75
  key,
74
- JSON.stringify(result, (jsonkey, value) =>
76
+ JSON.stringify(result, (_jsonkey, value) =>
75
77
  typeof value === 'bigint' ? `${value}n` : value,
76
78
  ),
77
79
  {
@@ -86,7 +88,7 @@ class Cache extends Base {
86
88
  )}`,
87
89
  );
88
90
  try {
89
- result = JSON.parse(result, (jsonkey, value) => {
91
+ result = JSON.parse(result, (_jsonkey, value) => {
90
92
  if (typeof value === 'string' && /^\d+n$/.test(value)) {
91
93
  return BigInt(value.slice(0, value.length - 1));
92
94
  }
@@ -1,6 +1,6 @@
1
1
  import http from 'node:http';
2
- import path from 'node:path';
3
- import * as url from 'node:url';
2
+ // import path from 'node:path';
3
+ // import * as url from 'node:url';
4
4
  import express from 'express';
5
5
  import RequestLoggerMiddleware from './middleware/RequestLogger.js';
6
6
  import I18nMiddleware from './middleware/I18n.js';
@@ -18,12 +18,12 @@ class HttpServer extends Base {
18
18
  super(app);
19
19
  this.express = express();
20
20
  this.express.disable('x-powered-by');
21
- const dirname = url.fileURLToPath(new URL('.', import.meta.url));
22
- this.express.set('views', [
23
- this.app.foldersConfig.views,
24
- path.join(dirname, '../../views'),
25
- ]);
26
- this.express.set('view engine', 'pug');
21
+ // const dirname = url.fileURLToPath(new URL('.', import.meta.url));
22
+ // this.express.set('views', [
23
+ // this.app.foldersConfig.views,
24
+ // path.join(dirname, '../../views'),
25
+ // ]);
26
+ // this.express.set('view engine', 'pug');
27
27
 
28
28
  this.express.use(new PrepareAppInfoMiddleware(this.app).getMiddleware());
29
29
  this.express.use(new IpDetector(this.app).getMiddleware());
@@ -1,37 +1,36 @@
1
1
  import i18next from 'i18next';
2
2
  import BackendFS from 'i18next-fs-backend';
3
- import Backend from 'i18next-chained-backend';
4
3
  import AbstractMiddleware from './AbstractMiddleware.js';
5
4
 
6
5
  class I18n extends AbstractMiddleware {
6
+ cache = {};
7
+
8
+ enabled = true;
9
+
10
+ lookupQuerystring = '';
11
+
12
+ supportedLngs = [];
13
+
14
+ fallbackLng = 'en';
15
+
16
+ /** @type {i18next} */
17
+ i18n = {
18
+ // @ts-ignore
19
+ t: (text) => text,
20
+ language: 'en',
21
+ };
22
+
7
23
  constructor(app, params) {
8
24
  super(app, params);
9
25
  const I18NConfig = this.app.getConfig('i18n');
10
- this.i18n = {
11
- t: (text) => text,
12
- language: I18NConfig.fallbackLng,
13
- };
14
- this.cache = {};
15
26
 
16
27
  if (I18NConfig.enabled) {
17
28
  this.logger.info('Enabling i18n support');
18
29
  this.i18n = i18next;
19
- i18next.use(Backend).init({
30
+ i18next.use(BackendFS).init({
20
31
  backend: {
21
- backends: [
22
- BackendFS,
23
- // BackendFS,
24
- ],
25
- backendOptions: [
26
- // {
27
- // loadPath: __dirname + '/../../locales/{{lng}}/{{ns}}.json',
28
- // addPath: __dirname + '/../../locales/{{lng}}/{{ns}}.missing.json'
29
- // },
30
- {
31
- loadPath: `${this.app.foldersConfig.locales}/{{lng}}/{{ns}}.json`,
32
- addPath: `${this.app.foldersConfig.locales}/{{lng}}/{{ns}}.missing.json`,
33
- },
34
- ],
32
+ loadPath: `${this.app.foldersConfig.locales}/{{lng}}/{{ns}}.json`,
33
+ addPath: `${this.app.foldersConfig.locales}/{{lng}}/{{ns}}.missing.json`,
35
34
  },
36
35
  fallbackLng: I18NConfig.fallbackLng,
37
36
  preload: I18NConfig.preload,
@@ -19,8 +19,8 @@ class Pagination extends AbstractMiddleware {
19
19
  async middleware(req, res, next) {
20
20
  let { limit, maxLimit } = this.params;
21
21
 
22
- limit = typeof limit === 'number' ? parseInt(limit, 10) : 10;
23
- maxLimit = typeof maxLimit === 'number' ? parseInt(maxLimit, 10) : 100;
22
+ limit = typeof limit !== 'number' ? parseInt(limit, 10) : 10;
23
+ maxLimit = typeof maxLimit !== 'number' ? parseInt(maxLimit, 10) : 100;
24
24
 
25
25
  req.appInfo.pagination = {};
26
26
  req.appInfo.pagination.page =