@adaptivestone/framework 4.11.4 → 5.0.0-alpha.10

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 (83) hide show
  1. package/.eslintrc.cjs +41 -0
  2. package/CHANGELOG.md +52 -0
  3. package/Cli.js +5 -5
  4. package/cluster.js +5 -3
  5. package/commands/CreateUser.js +5 -3
  6. package/commands/Documentation.js +3 -3
  7. package/commands/DropIndex.js +2 -2
  8. package/commands/Generate.js +2 -2
  9. package/commands/GetOpenApiJson.js +3 -3
  10. package/commands/SyncIndexes.js +6 -4
  11. package/commands/migration/Create.js +4 -7
  12. package/commands/migration/Migrate.js +8 -4
  13. package/config/auth.js +3 -2
  14. package/config/http.js +1 -1
  15. package/config/i18n.js +1 -1
  16. package/config/ipDetector.js +14 -0
  17. package/config/log.js +1 -1
  18. package/config/mail.js +2 -2
  19. package/config/mongo.js +1 -1
  20. package/config/rateLimiter.js +1 -1
  21. package/config/redis.js +1 -1
  22. package/config/validate.js +1 -1
  23. package/controllers/Auth.js +5 -5
  24. package/controllers/Home.js +3 -3
  25. package/controllers/index.js +6 -4
  26. package/folderConfig.js +2 -3
  27. package/helpers/files.js +11 -7
  28. package/helpers/logger.js +2 -4
  29. package/helpers/redis/clearNamespace.js +1 -1
  30. package/helpers/yup.js +4 -5
  31. package/index.js +2 -2
  32. package/jsconfig.json +9 -0
  33. package/models/Migration.js +2 -2
  34. package/models/Sequence.js +2 -2
  35. package/models/User.js +5 -6
  36. package/modules/AbstractCommand.js +4 -3
  37. package/modules/AbstractConnector.js +2 -2
  38. package/modules/AbstractController.js +12 -7
  39. package/modules/AbstractModel.js +8 -5
  40. package/modules/Base.d.ts +4 -3
  41. package/modules/Base.js +2 -2
  42. package/modules/BaseCli.js +6 -4
  43. package/modules/Modules.test.js +2 -2
  44. package/package.json +16 -16
  45. package/server.d.ts +7 -5
  46. package/server.js +24 -17
  47. package/services/cache/Cache.d.ts +2 -2
  48. package/services/cache/Cache.js +6 -4
  49. package/services/documentation/DocumentationGenerator.js +3 -3
  50. package/services/http/HttpServer.js +16 -24
  51. package/services/http/middleware/AbstractMiddleware.js +3 -3
  52. package/services/http/middleware/Auth.js +2 -2
  53. package/services/http/middleware/Auth.test.js +1 -1
  54. package/services/http/middleware/Cors.js +2 -2
  55. package/services/http/middleware/Cors.test.js +1 -1
  56. package/services/http/middleware/GetUserByToken.js +3 -3
  57. package/services/http/middleware/GetUserByToken.test.js +1 -1
  58. package/services/http/middleware/I18n.js +5 -6
  59. package/services/http/middleware/I18n.test.js +1 -1
  60. package/services/http/middleware/IpDetector.js +59 -0
  61. package/services/http/middleware/IpDetector.test.js +143 -0
  62. package/services/http/middleware/Pagination.js +3 -3
  63. package/services/http/middleware/PrepareAppInfo.js +2 -2
  64. package/services/http/middleware/PrepareAppInfo.test.js +1 -1
  65. package/services/http/middleware/RateLimiter.js +14 -9
  66. package/services/http/middleware/RateLimiter.test.js +5 -3
  67. package/services/http/middleware/RequestLogger.js +2 -2
  68. package/services/http/middleware/RequestParser.js +7 -5
  69. package/services/http/middleware/RequestParser.test.js +17 -10
  70. package/services/http/middleware/Role.js +2 -2
  71. package/services/http/middleware/Role.test.js +1 -1
  72. package/services/messaging/email/index.js +28 -29
  73. package/services/messaging/index.js +2 -4
  74. package/services/validate/ValidateService.js +5 -5
  75. package/services/validate/ValidateService.test.js +4 -4
  76. package/services/validate/drivers/AbstractValidator.js +2 -2
  77. package/services/validate/drivers/CustomValidator.js +3 -4
  78. package/services/validate/drivers/YupValidator.js +3 -3
  79. package/tests/globalSetupVitest.js +1 -1
  80. package/tests/setup.js +10 -9
  81. package/tests/setupVitest.js +6 -7
  82. package/types/TFoldersConfig.d.ts +0 -2
  83. package/services/http/middleware/StaticFiles.js +0 -60
package/.eslintrc.cjs ADDED
@@ -0,0 +1,41 @@
1
+ module.exports = {
2
+ env: {
3
+ es2023: true,
4
+ node: true,
5
+ },
6
+ extends: ['airbnb-base', 'prettier'],
7
+ plugins: ['prettier'],
8
+ parserOptions: {
9
+ ecmaVersion: 2023,
10
+ },
11
+ rules: {
12
+ 'no-restricted-syntax': [
13
+ 'error',
14
+ {
15
+ selector: 'ForInStatement',
16
+ message:
17
+ 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
18
+ },
19
+ {
20
+ selector: 'LabeledStatement',
21
+ message:
22
+ 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
23
+ },
24
+ {
25
+ selector: 'WithStatement',
26
+ message:
27
+ '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
28
+ },
29
+ ],
30
+ 'prettier/prettier': 'error',
31
+ 'import/extensions': 'off', // it have a problem with dynamic imports
32
+ 'import/prefer-default-export': 'off', // we want to have signgke default export too
33
+ },
34
+ overrides: [
35
+ {
36
+ files: ['**/*.test.js'],
37
+ extends: ['plugin:vitest/all', 'plugin:vitest/recommended'],
38
+ plugins: ['vitest'],
39
+ },
40
+ ],
41
+ };
package/CHANGELOG.md CHANGED
@@ -1,3 +1,55 @@
1
+ ### 5.0.0-alpha.10
2
+
3
+ [UPDATE] update deps
4
+ [NEW] IpDetector middleware that support detecting proxy and X-Forwarded-For header
5
+ [BREAKING] RateLimiter now need to have IpDetector middleware before
6
+
7
+ ### 5.0.0-alpha.9
8
+
9
+ [UPDATE] update deps
10
+ [BREAKING] removing staticFiles middleware as it not used in projects anymore. Docs with nginx config will be provided
11
+ [BREAKING] remove default AUTH_SALT. It should be provided on a app level now
12
+ [BREAKING] Vitest 2.0.0 https://vitest.dev/guide/migration.html#migrating-to-vitest-2-0
13
+
14
+ ### 5.0.0-alpha.8
15
+
16
+ [UPDATE] replace dotenv with loadEnvFile
17
+ [UPDATE] replace nodemon with node --watch (dev only)
18
+ [BREAKING] Minimum node version is 20.12 as for now (process.loadEnvFile)
19
+
20
+ ### 5.0.0-alpha.7
21
+
22
+ [UPDATE] deps update
23
+
24
+ ### 5.0.0-alpha.6
25
+
26
+ [UPDATE] Update internal documentation (jsdoc, d.ts)
27
+
28
+ ### 5.0.0-alpha.5
29
+
30
+ [UPDATE] More verbose errors for rapsing body request.
31
+ [UPDATE] deps update
32
+
33
+ ### 5.0.0-alpha.4
34
+
35
+ [UPDATE] Update rate-limiter-flexible to v5
36
+ [CHANGE] Cache update redis.setEX to redis.set(..,..,{EX:xx}) as setEX deprecated
37
+
38
+ ### 5.0.0-alpha.3
39
+
40
+ [UPDATE] deps update
41
+ [FIX] Migration commands apply
42
+
43
+ ### 5.0.0-alpha.2
44
+
45
+ [UPDATE] deps update
46
+
47
+ ### 5.0.0-alpha.1
48
+
49
+ [BREAKING] Vitest 1.0.0 https://vitest.dev/guide/migration.html#migrating-from-vitest-0-34-6
50
+ [BREAKING] ESM only. No more commonJS. That help to fix a lot of bugs with tests and provides better development expirience
51
+ [BREAKING] Mongoose v8. https://mongoosejs.com/docs/migrating_to_8.html
52
+
1
53
  ### 4.11.4
2
54
 
3
55
  [UPDATE] deps update
package/Cli.js CHANGED
@@ -1,7 +1,7 @@
1
- const parseArgs = require('minimist');
2
- const mongoose = require('mongoose');
3
- const BaseCli = require('./modules/BaseCli');
4
- const Server = require('./server');
1
+ import parseArgs from 'minimist';
2
+ import mongoose from 'mongoose';
3
+ import BaseCli from './modules/BaseCli.js';
4
+ import Server from './server.js';
5
5
 
6
6
  class Cli extends BaseCli {
7
7
  constructor(serverConfig) {
@@ -19,4 +19,4 @@ class Cli extends BaseCli {
19
19
  }
20
20
  }
21
21
 
22
- module.exports = Cli;
22
+ export default Cli;
package/cluster.js CHANGED
@@ -1,7 +1,9 @@
1
- const cluster = require('node:cluster');
2
- const numCPUs = require('node:os').cpus().length;
1
+ import cluster from 'node:cluster';
2
+ import { cpus } from 'node:os';
3
3
 
4
- if (cluster.isMaster) {
4
+ const numCPUs = cpus().length;
5
+
6
+ if (cluster.isPrimary) {
5
7
  // eslint-disable-next-line no-console
6
8
  console.log(`Master ${process.pid} is running`);
7
9
  // Fork workers.
@@ -1,4 +1,4 @@
1
- const AbstractCommand = require('../modules/AbstractCommand');
1
+ import AbstractCommand from '../modules/AbstractCommand.js';
2
2
 
3
3
  // Example: node src/cli createuser --email=somemail@gmail.com --password=somePassword --roles=user,admin,someOtherRoles
4
4
  class CreateUser extends AbstractCommand {
@@ -60,10 +60,12 @@ class CreateUser extends AbstractCommand {
60
60
 
61
61
  await user.generateToken();
62
62
 
63
- this.logger.info(`User was created/updated ${JSON.stringify(user, 0, 4)}`);
63
+ this.logger.info(
64
+ `User was created/updated ${JSON.stringify(user, null, 4)}`,
65
+ );
64
66
 
65
67
  return user;
66
68
  }
67
69
  }
68
70
 
69
- module.exports = CreateUser;
71
+ export default CreateUser;
@@ -1,5 +1,5 @@
1
- const AbstractCommand = require('../modules/AbstractCommand');
2
- const ControllerManager = require('../controllers/index');
1
+ import AbstractCommand from '../modules/AbstractCommand.js';
2
+ import ControllerManager from '../controllers/index.js';
3
3
 
4
4
  class Documentation extends AbstractCommand {
5
5
  async run() {
@@ -10,4 +10,4 @@ class Documentation extends AbstractCommand {
10
10
  }
11
11
  }
12
12
 
13
- module.exports = Documentation;
13
+ export default Documentation;
@@ -1,4 +1,4 @@
1
- const AbstractCommand = require('../modules/AbstractCommand');
1
+ import AbstractCommand from '../modules/AbstractCommand.js';
2
2
 
3
3
  class DropIndex extends AbstractCommand {
4
4
  static get description() {
@@ -26,4 +26,4 @@ class DropIndex extends AbstractCommand {
26
26
  }
27
27
  }
28
28
 
29
- module.exports = DropIndex;
29
+ export default DropIndex;
@@ -1,4 +1,4 @@
1
- const AbstractCommand = require('../modules/AbstractCommand');
1
+ import AbstractCommand from '../modules/AbstractCommand.js';
2
2
 
3
3
  class Generate extends AbstractCommand {
4
4
  async run() {
@@ -11,4 +11,4 @@ class Generate extends AbstractCommand {
11
11
  }
12
12
  }
13
13
 
14
- module.exports = Generate;
14
+ export default Generate;
@@ -1,5 +1,5 @@
1
- const fs = require('node:fs').promises;
2
- const AbstractCommand = require('../modules/AbstractCommand');
1
+ import { promises as fs } from 'node:fs';
2
+ import AbstractCommand from '../modules/AbstractCommand.js';
3
3
 
4
4
  /**
5
5
  * Command for generate documentation json file openApi
@@ -318,4 +318,4 @@ class GetOpenApiJson extends AbstractCommand {
318
318
  }
319
319
  }
320
320
 
321
- module.exports = GetOpenApiJson;
321
+ export default GetOpenApiJson;
@@ -1,10 +1,12 @@
1
- const path = require('node:path');
2
- const AbstractCommand = require('../modules/AbstractCommand');
1
+ import path from 'node:path';
2
+ import * as url from 'node:url';
3
+ import AbstractCommand from '../modules/AbstractCommand.js';
3
4
 
4
5
  class SyncIndexes extends AbstractCommand {
5
6
  async run() {
7
+ const dirname = url.fileURLToPath(new URL('.', import.meta.url));
6
8
  const files = await this.getFilesPathWithInheritance(
7
- `${__dirname}/../models`,
9
+ path.join(dirname, '/../models'),
8
10
  this.app.foldersConfig.models,
9
11
  );
10
12
  let models = [];
@@ -34,4 +36,4 @@ class SyncIndexes extends AbstractCommand {
34
36
  }
35
37
  }
36
38
 
37
- module.exports = SyncIndexes;
39
+ export default SyncIndexes;
@@ -1,7 +1,6 @@
1
- const path = require('node:path');
2
- const fs = require('node:fs').promises;
3
-
4
- const AbstractCommand = require('../../modules/AbstractCommand');
1
+ import path from 'node:path';
2
+ import { promises as fs } from 'node:fs';
3
+ import AbstractCommand from '../../modules/AbstractCommand.js';
5
4
 
6
5
  class CreateMigration extends AbstractCommand {
7
6
  static get description() {
@@ -41,7 +40,6 @@ class CreateMigration extends AbstractCommand {
41
40
  static getTemplate(name) {
42
41
  return `/* eslint-disable class-methods-use-this */
43
42
 
44
- // const Base = require('@adaptivestone/framework/modules/Base');
45
43
  import Base from '@adaptivestone/framework/modules/Base.js';
46
44
 
47
45
  class ${name} extends Base {
@@ -55,10 +53,9 @@ class ${name} extends Base {
55
53
  }
56
54
  }
57
55
 
58
- // module.exports = ${name};
59
56
  export default ${name};
60
57
  `;
61
58
  }
62
59
  }
63
60
 
64
- module.exports = CreateMigration;
61
+ export default CreateMigration;
@@ -1,4 +1,6 @@
1
- const AbstractCommand = require('../../modules/AbstractCommand');
1
+ import * as url from 'node:url';
2
+ import path from 'node:path';
3
+ import AbstractCommand from '../../modules/AbstractCommand.js';
2
4
 
3
5
  class Migrate extends AbstractCommand {
4
6
  static get description() {
@@ -6,8 +8,10 @@ class Migrate extends AbstractCommand {
6
8
  }
7
9
 
8
10
  async run() {
11
+ const dirname = url.fileURLToPath(new URL('.', import.meta.url));
12
+
9
13
  const files = await this.getFilesPathWithInheritance(
10
- `${__dirname}/../../migrations`,
14
+ path.join(dirname, '/../../migrations'),
11
15
  this.app.foldersConfig.migrations,
12
16
  );
13
17
  files.sort(
@@ -32,7 +36,7 @@ class Migrate extends AbstractCommand {
32
36
  for (const migration of migrations) {
33
37
  this.logger.info(`=== Start migration ${migration.file} ===`);
34
38
  // eslint-disable-next-line no-await-in-loop
35
- const MigrationCommand = await import(migration.path);
39
+ const { default: MigrationCommand } = await import(migration.path);
36
40
  const migrationCommand = new MigrationCommand(this.app);
37
41
  // eslint-disable-next-line no-await-in-loop
38
42
  await migrationCommand.up();
@@ -48,4 +52,4 @@ class Migrate extends AbstractCommand {
48
52
  }
49
53
  }
50
54
 
51
- module.exports = Migrate;
55
+ export default Migrate;
package/config/auth.js CHANGED
@@ -1,5 +1,6 @@
1
- module.exports = {
1
+ export default {
2
2
  hashRounds: 64,
3
- saltSecret: process.env.AUTH_SALT || 'gdfg45667_%%^trterte',
3
+ saltSecret:
4
+ process.env.AUTH_SALT || console.error('AUTH_SALT is not defined'),
4
5
  isAuthWithVefificationFlow: true,
5
6
  };
package/config/http.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  port: process.env.HTTP_PORT || 3300,
3
3
  hostname: process.env.HTTP_HOST || '0.0.0.0',
4
4
  // if you want to use 'all' domains please copy this file to your app
package/config/i18n.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * You can use any options from https://www.i18next.com/overview/configuration-options
3
3
  */
4
- module.exports = {
4
+ export default {
5
5
  enabled: true,
6
6
  preload: ['en', 'ru'],
7
7
  supportedLngs: ['en', 'ru'], // should be at least one supported
@@ -0,0 +1,14 @@
1
+ export default {
2
+ headers: ['X-Forwarded-For'],
3
+ trustedProxy: [
4
+ // list of trusted proxies.
5
+ '169.254.0.0/16', // linklocal
6
+ 'fe80::/10', // linklocal
7
+ '127.0.0.1/8', // loopback
8
+ '::1/128', // loopback
9
+ '10.0.0.0/8', // uniquelocal
10
+ '172.16.0.0/12', // uniquelocal
11
+ '192.168.0.0/16', // uniquelocal
12
+ 'fc00::/7', // uniquelocal
13
+ ],
14
+ };
package/config/log.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  transports: [
3
3
  {
4
4
  transport: 'winston-transport-sentry-node',
package/config/mail.js CHANGED
@@ -1,6 +1,6 @@
1
- const path = require('node:path');
1
+ import path from 'node:path';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  from: 'Localhost <info@localhost>',
5
5
  transports: {
6
6
  sendMail: {
package/config/mongo.js CHANGED
@@ -1,3 +1,3 @@
1
- module.exports = {
1
+ export default {
2
2
  connectionString: process.env.MONGO_DSN,
3
3
  };
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  limiterOptions: {
3
3
  // https://github.com/animir/node-rate-limiter-flexible
4
4
  // https://github.com/animir/node-rate-limiter-flexible/wiki/Options
package/config/redis.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  url: process.env.REDIS_URI || 'redis://localhost',
3
3
  namespace: process.env.REDIS_NAMESPACE || 'main',
4
4
  };
@@ -1,3 +1,3 @@
1
- module.exports = {
1
+ export default {
2
2
  controllerValidationAbortEarly: true, // abort validation on first error and return first error
3
3
  };
@@ -1,7 +1,7 @@
1
- const yup = require('yup');
2
- const AbstractController = require('../modules/AbstractController');
3
- const GetUserByToken = require('../services/http/middleware/GetUserByToken');
4
- const RateLimiter = require('../services/http/middleware/RateLimiter');
1
+ import yup from 'yup';
2
+ import AbstractController from '../modules/AbstractController.js';
3
+ import GetUserByToken from '../services/http/middleware/GetUserByToken.js';
4
+ import RateLimiter from '../services/http/middleware/RateLimiter.js';
5
5
 
6
6
  class Auth extends AbstractController {
7
7
  get routes() {
@@ -207,4 +207,4 @@ class Auth extends AbstractController {
207
207
  }
208
208
  }
209
209
 
210
- module.exports = Auth;
210
+ export default Auth;
@@ -1,5 +1,5 @@
1
- const AbstractController = require('../modules/AbstractController');
2
- const GetUserByToken = require('../services/http/middleware/GetUserByToken');
1
+ import AbstractController from '../modules/AbstractController.js';
2
+ import GetUserByToken from '../services/http/middleware/GetUserByToken.js';
3
3
 
4
4
  class Home extends AbstractController {
5
5
  get routes() {
@@ -25,4 +25,4 @@ class Home extends AbstractController {
25
25
  }
26
26
  }
27
27
 
28
- module.exports = Home;
28
+ export default Home;
@@ -1,5 +1,6 @@
1
- const path = require('node:path');
2
- const Base = require('../modules/Base');
1
+ import path from 'node:path';
2
+ import * as url from 'node:url';
3
+ import Base from '../modules/Base.js';
3
4
 
4
5
  /**
5
6
  * Class do autoloading a http controllers
@@ -14,8 +15,9 @@ class ControllerManager extends Base {
14
15
  * Load controllers
15
16
  */
16
17
  async initControllers() {
18
+ const dirname = url.fileURLToPath(new URL('.', import.meta.url));
17
19
  const controllersToLoad = await this.getFilesPathWithInheritance(
18
- __dirname,
20
+ dirname,
19
21
  this.app.foldersConfig.controllers,
20
22
  );
21
23
 
@@ -55,4 +57,4 @@ class ControllerManager extends Base {
55
57
  }
56
58
  }
57
59
 
58
- module.exports = ControllerManager;
60
+ export default ControllerManager;
package/folderConfig.js CHANGED
@@ -1,12 +1,11 @@
1
- const path = require('node:path');
1
+ import path from 'node:path';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  folders: {
5
5
  config: path.resolve('./config'),
6
6
  models: path.resolve('./models'),
7
7
  controllers: path.resolve('./controllers'),
8
8
  views: path.resolve('./views'),
9
- public: path.resolve('./public'),
10
9
  locales: path.resolve('./locales'),
11
10
  emails: path.resolve('./services/messaging/email/templates'),
12
11
  commands: path.resolve('./commands'),
package/helpers/files.js CHANGED
@@ -1,5 +1,5 @@
1
- const fs = require('node:fs').promises;
2
- const { join } = require('node:path');
1
+ import { promises as fs } from 'node:fs';
2
+ import { join } from 'node:path';
3
3
 
4
4
  const getFilesPathWithInheritance = async ({
5
5
  internalFolder,
@@ -36,12 +36,16 @@ const getFilesPathWithInheritance = async ({
36
36
  internalFiles = internalFiles
37
37
  .filter(filterIndexFile)
38
38
  .map((fileDirent) =>
39
- join(fileDirent.path, fileDirent.name).replace(`${internalFolder}/`, ''),
39
+ join(fileDirent.path, fileDirent.name)
40
+ .replace(`${internalFolder}/`, '')
41
+ .replace(`${internalFolder}`, ''),
40
42
  );
41
43
  externalFiles = externalFiles
42
44
  .filter(filterIndexFile)
43
45
  .map((fileDirent) =>
44
- join(fileDirent.path, fileDirent.name).replace(`${externalFolder}/`, ''),
46
+ join(fileDirent.path, fileDirent.name)
47
+ .replace(`${externalFolder}/`, '')
48
+ .replace(`${externalFolder}`, ''),
45
49
  );
46
50
 
47
51
  const filesToLoad = [];
@@ -54,7 +58,7 @@ const getFilesPathWithInheritance = async ({
54
58
  );
55
59
  } else {
56
60
  filesToLoad.push({
57
- path: `${internalFolder}/${file}`,
61
+ path: join(internalFolder, file),
58
62
  file,
59
63
  });
60
64
  }
@@ -62,14 +66,14 @@ const getFilesPathWithInheritance = async ({
62
66
 
63
67
  for (const file of externalFiles) {
64
68
  filesToLoad.push({
65
- path: `${externalFolder}/${file}`,
69
+ path: join(externalFolder, file),
66
70
  file,
67
71
  });
68
72
  }
69
73
  return filesToLoad;
70
74
  };
71
75
 
72
- module.exports = {
76
+ export {
73
77
  // eslint-disable-next-line import/prefer-default-export
74
78
  getFilesPathWithInheritance,
75
79
  };
package/helpers/logger.js CHANGED
@@ -13,7 +13,5 @@ const consoleLogger = (level, message) => {
13
13
  }
14
14
  }
15
15
  };
16
- module.exports = {
17
- levels,
18
- consoleLogger,
19
- };
16
+
17
+ export { levels, consoleLogger };
@@ -11,4 +11,4 @@ async function clearNamespace(redisClient, namespace) {
11
11
  }
12
12
  }
13
13
 
14
- module.exports = clearNamespace;
14
+ export default clearNamespace;
package/helpers/yup.js CHANGED
@@ -1,5 +1,5 @@
1
- const { Schema } = require('yup');
2
- const formidable = require('formidable');
1
+ import { Schema } from 'yup';
2
+ import { PersistentFile } from 'formidable';
3
3
 
4
4
  /**
5
5
  * Validator for file
@@ -13,13 +13,12 @@ class YupFile extends Schema {
13
13
  constructor() {
14
14
  super({
15
15
  type: 'file',
16
- check: (value) =>
17
- value.every((item) => item instanceof formidable.PersistentFile),
16
+ check: (value) => value.every((item) => item instanceof PersistentFile),
18
17
  });
19
18
  }
20
19
  }
21
20
 
22
- module.exports = {
21
+ export {
23
22
  // eslint-disable-next-line import/prefer-default-export
24
23
  YupFile,
25
24
  };
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- const Server = require('./server');
2
- const folderConfig = require('./folderConfig');
1
+ import Server from './server.js';
2
+ import folderConfig from './folderConfig.js';
3
3
 
4
4
  const server = new Server(folderConfig);
5
5
 
package/jsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "node16",
4
+ "target": "ES2022",
5
+ "moduleResolution": "node16",
6
+ "checkJs": true
7
+ },
8
+ "exclude": ["node_modules"]
9
+ }
@@ -1,4 +1,4 @@
1
- const AbstractModel = require('../modules/AbstractModel');
1
+ import AbstractModel from '../modules/AbstractModel.js';
2
2
 
3
3
  class Migration extends AbstractModel {
4
4
  // eslint-disable-next-line class-methods-use-this
@@ -12,4 +12,4 @@ class Migration extends AbstractModel {
12
12
  }
13
13
  }
14
14
 
15
- module.exports = Migration;
15
+ export default Migration;
@@ -1,4 +1,4 @@
1
- const AbstractModel = require('../modules/AbstractModel');
1
+ import AbstractModel from '../modules/AbstractModel.js';
2
2
 
3
3
  class Sequence extends AbstractModel {
4
4
  // eslint-disable-next-line class-methods-use-this
@@ -19,4 +19,4 @@ class Sequence extends AbstractModel {
19
19
  }
20
20
  }
21
21
 
22
- module.exports = Sequence;
22
+ export default Sequence;
package/models/User.js CHANGED
@@ -1,11 +1,10 @@
1
1
  /* eslint-disable no-param-reassign */
2
2
 
3
- const { scrypt } = require('node:crypto');
4
- const { promisify } = require('node:util');
3
+ import { scrypt } from 'node:crypto';
5
4
 
6
- const AbstractModel = require('../modules/AbstractModel');
7
-
8
- const Mailer = require('../services/messaging').email;
5
+ import { promisify } from 'node:util';
6
+ import AbstractModel from '../modules/AbstractModel.js';
7
+ import Mailer from '../services/messaging/email/index.js';
9
8
 
10
9
  class User extends AbstractModel {
11
10
  constructor(app) {
@@ -255,4 +254,4 @@ class User extends AbstractModel {
255
254
  }
256
255
  }
257
256
 
258
- module.exports = User;
257
+ export default User;
@@ -1,4 +1,4 @@
1
- const Base = require('./Base');
1
+ import Base from './Base.js';
2
2
 
3
3
  class AbstractCommand extends Base {
4
4
  constructor(app, commands, args) {
@@ -13,10 +13,11 @@ class AbstractCommand extends Base {
13
13
 
14
14
  /**
15
15
  * Entry point to every command. This method should be overridden
16
- * @override
16
+ * @return {Promise<boolean>} resut
17
17
  */
18
18
  async run() {
19
19
  this.logger.error('You should implement run method');
20
+ return false;
20
21
  }
21
22
 
22
23
  static get loggerGroup() {
@@ -24,4 +25,4 @@ class AbstractCommand extends Base {
24
25
  }
25
26
  }
26
27
 
27
- module.exports = AbstractCommand;
28
+ export default AbstractCommand;