@adaptivestone/framework 5.0.0-beta.4 → 5.0.0-beta.40
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 +1107 -528
- package/LICENCE +1 -1
- package/dist/Cli.d.ts +7 -0
- package/dist/Cli.js +19 -0
- package/dist/Cli.js.map +1 -0
- package/dist/cluster.d.ts +1 -0
- package/dist/cluster.js +18 -0
- package/dist/cluster.js.map +1 -0
- package/dist/commands/CreateUser.d.ts +32 -0
- package/dist/commands/CreateUser.js +83 -0
- package/dist/commands/CreateUser.js.map +1 -0
- package/dist/commands/Documentation.d.ts +5 -0
- package/dist/commands/Documentation.js +15 -0
- package/dist/commands/Documentation.js.map +1 -0
- package/dist/commands/DropIndex.d.ts +16 -0
- package/dist/commands/DropIndex.js +30 -0
- package/dist/commands/DropIndex.js.map +1 -0
- package/dist/commands/GenerateRandomBytes.d.ts +7 -0
- package/dist/commands/GenerateRandomBytes.js +18 -0
- package/dist/commands/GenerateRandomBytes.js.map +1 -0
- package/dist/commands/GenerateTypes.d.ts +11 -0
- package/dist/commands/GenerateTypes.js +52 -0
- package/dist/commands/GenerateTypes.js.map +1 -0
- package/dist/commands/GetOpenApiJson.d.ts +17 -0
- package/dist/commands/GetOpenApiJson.js +272 -0
- package/dist/commands/GetOpenApiJson.js.map +1 -0
- package/dist/commands/SyncIndexes.d.ts +6 -0
- package/dist/commands/SyncIndexes.js +31 -0
- package/dist/commands/SyncIndexes.js.map +1 -0
- package/dist/commands/migration/Create.d.ts +18 -0
- package/dist/commands/migration/Create.js +57 -0
- package/dist/commands/migration/Create.js.map +1 -0
- package/dist/commands/migration/Migrate.d.ts +6 -0
- package/dist/commands/migration/Migrate.js +43 -0
- package/dist/commands/migration/Migrate.js.map +1 -0
- package/dist/config/auth.d.ts +6 -0
- package/dist/config/auth.js +7 -0
- package/dist/config/auth.js.map +1 -0
- package/dist/config/http.d.ts +8 -0
- package/dist/config/http.js +10 -0
- package/dist/config/http.js.map +1 -0
- package/dist/config/i18n.d.ts +13 -0
- package/dist/config/i18n.js +13 -0
- package/dist/config/i18n.js.map +1 -0
- package/dist/config/ipDetector.d.ts +5 -0
- package/dist/config/ipDetector.js +15 -0
- package/dist/config/ipDetector.js.map +1 -0
- package/dist/config/log.d.ts +11 -0
- package/dist/config/log.js +20 -0
- package/dist/config/log.js.map +1 -0
- package/dist/config/mongo.d.ts +4 -0
- package/dist/config/mongo.js +4 -0
- package/dist/config/mongo.js.map +1 -0
- package/dist/config/rateLimiter.d.ts +13 -0
- package/dist/config/rateLimiter.js +17 -0
- package/dist/config/rateLimiter.js.map +1 -0
- package/dist/config/redis.d.ts +5 -0
- package/dist/config/redis.js +5 -0
- package/dist/config/redis.js.map +1 -0
- package/dist/config/validate.d.ts +4 -0
- package/dist/config/validate.js +4 -0
- package/dist/config/validate.js.map +1 -0
- package/dist/controllers/Auth.d.ts +131 -0
- package/dist/controllers/Auth.js +186 -0
- package/dist/controllers/Auth.js.map +1 -0
- package/dist/controllers/Home.d.ts +15 -0
- package/dist/controllers/Home.js +22 -0
- package/dist/controllers/Home.js.map +1 -0
- package/dist/controllers/index.d.ts +16 -0
- package/dist/controllers/index.js +59 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/folderConfig.d.ts +34 -0
- package/dist/folderConfig.js +14 -0
- package/dist/folderConfig.js.map +1 -0
- package/dist/helpers/appInstance.d.ts +3 -0
- package/dist/helpers/appInstance.js +8 -0
- package/dist/helpers/appInstance.js.map +1 -0
- package/dist/helpers/crypto.d.ts +3 -0
- package/dist/helpers/crypto.js +17 -0
- package/dist/helpers/crypto.js.map +1 -0
- package/dist/helpers/files.d.ts +16 -0
- package/dist/helpers/files.js +76 -0
- package/dist/helpers/files.js.map +1 -0
- package/dist/helpers/logger.d.ts +4 -0
- package/dist/helpers/logger.js +20 -0
- package/dist/helpers/logger.js.map +1 -0
- package/dist/helpers/redis/clearNamespace.d.ts +2 -0
- package/dist/helpers/redis/clearNamespace.js +14 -0
- package/dist/helpers/redis/clearNamespace.js.map +1 -0
- package/dist/helpers/yup.d.ts +13 -0
- package/dist/helpers/yup.js +21 -0
- package/dist/helpers/yup.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/models/Lock.d.ts +90 -0
- package/dist/models/Lock.js +97 -0
- package/dist/models/Lock.js.map +1 -0
- package/dist/models/Migration.d.ts +13 -0
- package/dist/models/Migration.js +14 -0
- package/dist/models/Migration.js.map +1 -0
- package/dist/models/Sequence.d.ts +28 -0
- package/dist/models/Sequence.js +19 -0
- package/dist/models/Sequence.js.map +1 -0
- package/dist/models/User.d.ts +656 -0
- package/dist/models/User.js +291 -0
- package/dist/models/User.js.map +1 -0
- package/dist/models/UserOld.d.ts +179 -0
- package/dist/models/UserOld.js +230 -0
- package/dist/models/UserOld.js.map +1 -0
- package/dist/modules/AbstractCommand.d.ts +51 -0
- package/dist/modules/AbstractCommand.js +60 -0
- package/dist/modules/AbstractCommand.js.map +1 -0
- package/dist/modules/AbstractConnector.d.ts +5 -0
- package/dist/modules/AbstractConnector.js +8 -0
- package/dist/modules/AbstractConnector.js.map +1 -0
- package/dist/modules/AbstractController.d.ts +94 -0
- package/dist/modules/AbstractController.js +323 -0
- package/dist/modules/AbstractController.js.map +1 -0
- package/dist/modules/AbstractModel.d.ts +29 -0
- package/dist/modules/AbstractModel.js +42 -0
- package/dist/modules/AbstractModel.js.map +1 -0
- package/dist/modules/Base.d.ts +29 -0
- package/dist/modules/Base.js +58 -0
- package/dist/modules/Base.js.map +1 -0
- package/dist/modules/BaseCli.d.ts +25 -0
- package/dist/modules/BaseCli.js +147 -0
- package/dist/modules/BaseCli.js.map +1 -0
- package/dist/modules/BaseModel.d.ts +55 -0
- package/dist/modules/BaseModel.js +37 -0
- package/dist/modules/BaseModel.js.map +1 -0
- package/dist/server.d.ts +123 -0
- package/dist/server.js +468 -0
- package/dist/server.js.map +1 -0
- package/dist/services/cache/Cache.d.ts +31 -0
- package/dist/services/cache/Cache.js +113 -0
- package/dist/services/cache/Cache.js.map +1 -0
- package/dist/services/documentation/DocumentationGenerator.d.ts +11 -0
- package/dist/services/documentation/DocumentationGenerator.js +130 -0
- package/dist/services/documentation/DocumentationGenerator.js.map +1 -0
- package/dist/services/http/HttpServer.d.ts +35 -0
- package/dist/services/http/HttpServer.js +70 -0
- package/dist/services/http/HttpServer.js.map +1 -0
- package/dist/services/http/middleware/AbstractMiddleware.d.ts +25 -0
- package/dist/services/http/middleware/AbstractMiddleware.js +41 -0
- package/dist/services/http/middleware/AbstractMiddleware.js.map +1 -0
- package/dist/services/http/middleware/Auth.d.ts +9 -0
- package/dist/services/http/middleware/Auth.js +18 -0
- package/dist/services/http/middleware/Auth.js.map +1 -0
- package/dist/services/http/middleware/Cors.d.ts +12 -0
- package/dist/services/http/middleware/Cors.js +36 -0
- package/dist/services/http/middleware/Cors.js.map +1 -0
- package/dist/services/http/middleware/GetUserByToken.d.ts +20 -0
- package/dist/services/http/middleware/GetUserByToken.js +39 -0
- package/dist/services/http/middleware/GetUserByToken.js.map +1 -0
- package/dist/services/http/middleware/I18n.d.ts +23 -0
- package/dist/services/http/middleware/I18n.js +61 -0
- package/dist/services/http/middleware/I18n.js.map +1 -0
- package/dist/services/http/middleware/IpDetector.d.ts +14 -0
- package/dist/services/http/middleware/IpDetector.js +55 -0
- package/dist/services/http/middleware/IpDetector.js.map +1 -0
- package/dist/services/http/middleware/Pagination.d.ts +27 -0
- package/dist/services/http/middleware/Pagination.js +46 -0
- package/dist/services/http/middleware/Pagination.js.map +1 -0
- package/dist/services/http/middleware/PrepareAppInfo.d.ts +8 -0
- package/dist/services/http/middleware/PrepareAppInfo.js +17 -0
- package/dist/services/http/middleware/PrepareAppInfo.js.map +1 -0
- package/dist/services/http/middleware/RateLimiter.d.ts +26 -0
- package/dist/services/http/middleware/RateLimiter.js +118 -0
- package/dist/services/http/middleware/RateLimiter.js.map +1 -0
- package/dist/services/http/middleware/RequestLogger.d.ts +8 -0
- package/dist/services/http/middleware/RequestLogger.js +18 -0
- package/dist/services/http/middleware/RequestLogger.js.map +1 -0
- package/dist/services/http/middleware/RequestParser.d.ts +8 -0
- package/dist/services/http/middleware/RequestParser.js +35 -0
- package/dist/services/http/middleware/RequestParser.js.map +1 -0
- package/dist/services/http/middleware/Role.d.ts +12 -0
- package/dist/services/http/middleware/Role.js +24 -0
- package/dist/services/http/middleware/Role.js.map +1 -0
- package/dist/services/i18n/I18n.d.ts +15 -0
- package/dist/services/i18n/I18n.js +58 -0
- package/dist/services/i18n/I18n.js.map +1 -0
- package/dist/services/logging/SentryTransport.d.ts +14 -0
- package/dist/services/logging/SentryTransport.js +57 -0
- package/dist/services/logging/SentryTransport.js.map +1 -0
- package/dist/services/validate/ValidateService.d.ts +31 -0
- package/dist/services/validate/ValidateService.js +95 -0
- package/dist/services/validate/ValidateService.js.map +1 -0
- package/dist/services/validate/drivers/AbstractValidator.d.ts +14 -0
- package/dist/services/validate/drivers/AbstractValidator.js +29 -0
- package/dist/services/validate/drivers/AbstractValidator.js.map +1 -0
- package/dist/services/validate/drivers/CustomValidator.d.ts +14 -0
- package/dist/services/validate/drivers/CustomValidator.js +48 -0
- package/dist/services/validate/drivers/CustomValidator.js.map +1 -0
- package/dist/services/validate/drivers/YupValidator.d.ts +13 -0
- package/dist/services/validate/drivers/YupValidator.js +86 -0
- package/dist/services/validate/drivers/YupValidator.js.map +1 -0
- package/dist/tests/frameworkVitestSetup.d.ts +1 -0
- package/dist/tests/frameworkVitestSetup.js +9 -0
- package/dist/tests/frameworkVitestSetup.js.map +1 -0
- package/dist/tests/globalSetupVitest.d.ts +3 -0
- package/dist/tests/globalSetupVitest.js +29 -0
- package/dist/tests/globalSetupVitest.js.map +1 -0
- package/dist/tests/setupVitest.d.ts +1 -0
- package/dist/tests/setupVitest.js +91 -0
- package/dist/tests/setupVitest.js.map +1 -0
- package/dist/tests/testHelpers.d.ts +340 -0
- package/dist/tests/testHelpers.js +48 -0
- package/dist/tests/testHelpers.js.map +1 -0
- package/package.json +45 -39
- package/Cli.js +0 -22
- package/cluster.js +0 -27
- package/commands/CreateUser.js +0 -75
- package/commands/Documentation.js +0 -17
- package/commands/DropIndex.js +0 -29
- package/commands/GenerateRandomBytes.js +0 -21
- package/commands/GetOpenApiJson.js +0 -325
- package/commands/SyncIndexes.js +0 -39
- package/commands/migration/Create.js +0 -61
- package/commands/migration/Migrate.js +0 -55
- package/config/auth.js +0 -9
- package/config/http.js +0 -9
- package/config/i18n.js +0 -12
- package/config/ipDetector.js +0 -14
- package/config/log.js +0 -22
- package/config/mail.js +0 -29
- package/config/mongo.js +0 -3
- package/config/rateLimiter.js +0 -16
- package/config/redis.js +0 -4
- package/config/validate.js +0 -3
- package/controllers/Auth.js +0 -210
- package/controllers/Home.js +0 -28
- package/controllers/index.js +0 -60
- package/folderConfig.js +0 -14
- package/helpers/files.js +0 -79
- package/helpers/logger.js +0 -17
- package/helpers/redis/clearNamespace.js +0 -14
- package/helpers/yup.js +0 -24
- package/index.js +0 -8
- package/jsconfig.json +0 -9
- package/locales/en/translation.json +0 -27
- package/locales/ru/translation.json +0 -27
- package/migrations/.gitkeep +0 -0
- package/models/Migration.js +0 -15
- package/models/Sequence.js +0 -22
- package/models/User.js +0 -263
- package/modules/AbstractCommand.js +0 -43
- package/modules/AbstractConnector.js +0 -9
- package/modules/AbstractController.js +0 -413
- package/modules/AbstractModel.d.ts +0 -48
- package/modules/AbstractModel.js +0 -92
- package/modules/Base.d.ts +0 -37
- package/modules/Base.js +0 -63
- package/modules/BaseCli.js +0 -97
- package/server.d.ts +0 -98
- package/server.js +0 -438
- package/services/cache/Cache.d.ts +0 -35
- package/services/cache/Cache.js +0 -124
- package/services/documentation/DocumentationGenerator.js +0 -169
- package/services/http/HttpServer.js +0 -96
- package/services/http/middleware/AbstractMiddleware.js +0 -51
- package/services/http/middleware/Auth.js +0 -20
- package/services/http/middleware/Cors.js +0 -46
- package/services/http/middleware/GetUserByToken.js +0 -47
- package/services/http/middleware/I18n.js +0 -117
- package/services/http/middleware/IpDetector.js +0 -59
- package/services/http/middleware/Pagination.js +0 -57
- package/services/http/middleware/PrepareAppInfo.js +0 -18
- package/services/http/middleware/RateLimiter.js +0 -134
- package/services/http/middleware/RequestLogger.js +0 -22
- package/services/http/middleware/RequestParser.js +0 -40
- package/services/http/middleware/Role.js +0 -29
- package/services/messaging/email/index.js +0 -217
- package/services/messaging/email/resources/.gitkeep +0 -1
- package/services/messaging/email/templates/emptyTemplate/html.pug +0 -9
- package/services/messaging/email/templates/emptyTemplate/subject.pug +0 -1
- package/services/messaging/email/templates/emptyTemplate/text.pug +0 -1
- package/services/messaging/email/templates/recovery/html.pug +0 -8
- package/services/messaging/email/templates/recovery/subject.pug +0 -2
- package/services/messaging/email/templates/recovery/text.pug +0 -3
- package/services/messaging/email/templates/verification/html.pug +0 -10
- package/services/messaging/email/templates/verification/subject.pug +0 -1
- package/services/messaging/email/templates/verification/text.pug +0 -1
- package/services/messaging/index.js +0 -3
- package/services/validate/ValidateService.js +0 -157
- package/services/validate/drivers/AbstractValidator.js +0 -37
- package/services/validate/drivers/CustomValidator.js +0 -51
- package/services/validate/drivers/YupValidator.js +0 -103
- package/tests/globalSetupVitest.js +0 -35
- package/tests/setup.js +0 -118
- package/tests/setupVitest.js +0 -109
- package/types/Expand.d.ts +0 -11
- package/types/TFoldersConfig.d.ts +0 -17
- package/views/404.pug +0 -3
- package/views/home.pug +0 -3
- package/views/layouts/base.pug +0 -39
- package/vitest.config.js +0 -16
- /package/{commands → dist/migrations}/.gitkeep +0 -0
package/commands/DropIndex.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import AbstractCommand from '../modules/AbstractCommand.js';
|
|
2
|
-
|
|
3
|
-
class DropIndex extends AbstractCommand {
|
|
4
|
-
static get description() {
|
|
5
|
-
return 'Drop indexes of model';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
async run() {
|
|
9
|
-
if (!this.args.model) {
|
|
10
|
-
this.logger.error('Please provide model name as "--model=BestUserModel"');
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const Model = this.app.getModel(this.args.model);
|
|
15
|
-
|
|
16
|
-
if (!Model) {
|
|
17
|
-
this.logger.error('Not able to find model');
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
await Model.collection.dropIndexes();
|
|
22
|
-
|
|
23
|
-
this.logger.info('Success');
|
|
24
|
-
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default DropIndex;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import AbstractCommand from '../modules/AbstractCommand.js';
|
|
3
|
-
|
|
4
|
-
class GenerateRandomBytes extends AbstractCommand {
|
|
5
|
-
static get description() {
|
|
6
|
-
return 'Generate random bytes ising randomBytes from node:crypto';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
static isShouldInitModels = false;
|
|
10
|
-
|
|
11
|
-
async run() {
|
|
12
|
-
const sizes = [16, 32, 64, 128, 256];
|
|
13
|
-
for (const size of sizes) {
|
|
14
|
-
const bytes = randomBytes(size).toString('hex');
|
|
15
|
-
this.logger.info(`${size} bytes: ${bytes}`);
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default GenerateRandomBytes;
|
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'node:fs';
|
|
2
|
-
import AbstractCommand from '../modules/AbstractCommand.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Command for generate documentation json file openApi
|
|
6
|
-
*/
|
|
7
|
-
class GetOpenApiJson extends AbstractCommand {
|
|
8
|
-
static get description() {
|
|
9
|
-
return 'Generate documentation (openApi) ';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async run() {
|
|
13
|
-
const { myDomain } = this.app.getConfig('http');
|
|
14
|
-
let jsonFile = process.env.npm_package_json;
|
|
15
|
-
if (!jsonFile) {
|
|
16
|
-
jsonFile = `${process.env.PWD}/package.json`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
jsonFile = JSON.parse(await fs.readFile(jsonFile, 'utf8'));
|
|
21
|
-
} catch (e) {
|
|
22
|
-
this.logger.error(
|
|
23
|
-
'No npm package detected. Please start this command via NPM as it depends on package.json',
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (!jsonFile) {
|
|
28
|
-
jsonFile = {
|
|
29
|
-
name: 'UNDETECTD PROJECT',
|
|
30
|
-
description: 'UNDETECTD PROJECT DECCRIPTION',
|
|
31
|
-
version: '0.0.0-undetrcted',
|
|
32
|
-
author: {
|
|
33
|
-
email: 'none@example.com',
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (!jsonFile.author) {
|
|
39
|
-
jsonFile.author = 'none@example.com';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const openApi = {
|
|
43
|
-
openapi: '3.0.0',
|
|
44
|
-
info: {
|
|
45
|
-
title: jsonFile.name,
|
|
46
|
-
description: jsonFile.description,
|
|
47
|
-
contact: {
|
|
48
|
-
email: jsonFile.author.email,
|
|
49
|
-
},
|
|
50
|
-
version: jsonFile.version,
|
|
51
|
-
},
|
|
52
|
-
servers: [
|
|
53
|
-
{
|
|
54
|
-
url: 'http://localhost:3300',
|
|
55
|
-
description: 'Localhost',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
url: myDomain,
|
|
59
|
-
description: 'Domain from config',
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const baseDocumentation = await this.app.runCliCommand('documentation');
|
|
65
|
-
|
|
66
|
-
if (!baseDocumentation) {
|
|
67
|
-
throw new Error('Problems with basic documenation generation');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
openApi.components = {};
|
|
71
|
-
openApi.components.securitySchemes = {};
|
|
72
|
-
|
|
73
|
-
openApi.tags = [];
|
|
74
|
-
|
|
75
|
-
for (const controller of baseDocumentation) {
|
|
76
|
-
const controllerName = controller.contollerName.split('/')[0];
|
|
77
|
-
if (!openApi.tags.find((tag) => tag.name === controllerName)) {
|
|
78
|
-
openApi.tags.push({
|
|
79
|
-
name: controllerName,
|
|
80
|
-
description: '',
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
openApi.paths = {};
|
|
86
|
-
|
|
87
|
-
const permissionWithRoutes = {};
|
|
88
|
-
for (const controller of baseDocumentation) {
|
|
89
|
-
for (const route of controller.routesInfo) {
|
|
90
|
-
const routeInfo = route[Object.keys(route)?.[0]];
|
|
91
|
-
const middlewares = [
|
|
92
|
-
...routeInfo.controllerMiddlewares,
|
|
93
|
-
...routeInfo.routeMiddlewares,
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
const securitySchemaNames = [];
|
|
97
|
-
|
|
98
|
-
permissionWithRoutes[Object.keys(route)?.[0]] = [];
|
|
99
|
-
|
|
100
|
-
if (middlewares?.length) {
|
|
101
|
-
for (const middleware of middlewares) {
|
|
102
|
-
if (middleware?.authParams?.length) {
|
|
103
|
-
for (const authParam of middleware.authParams) {
|
|
104
|
-
const { permissions, ...mainFields } = authParam;
|
|
105
|
-
const fullName = authParam.name;
|
|
106
|
-
if (permissions) {
|
|
107
|
-
permissionWithRoutes[Object.keys(route)?.[0]].push(
|
|
108
|
-
permissions,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!openApi.components.securitySchemes[fullName]) {
|
|
113
|
-
openApi.components.securitySchemes[fullName] = mainFields;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
securitySchemaNames.push({
|
|
117
|
-
[fullName]: [],
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
let routeName = Object.keys(route)[0];
|
|
125
|
-
if (routeName === '/') {
|
|
126
|
-
// eslint-disable-next-line no-continue
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (routeName.slice(-1) === '/') {
|
|
131
|
-
routeName = routeName.substring(0, routeName.length - 1);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const partsRoute = routeName.split('/');
|
|
135
|
-
|
|
136
|
-
const newRoute = [];
|
|
137
|
-
const routeParameters = [];
|
|
138
|
-
for (const routeDetail of partsRoute) {
|
|
139
|
-
let routeCopy = routeDetail;
|
|
140
|
-
|
|
141
|
-
if (routeDetail.startsWith(':')) {
|
|
142
|
-
const routeChange = routeCopy.split('');
|
|
143
|
-
routeChange[0] = '{';
|
|
144
|
-
routeChange.push('}');
|
|
145
|
-
routeCopy = routeChange.join('');
|
|
146
|
-
routeParameters.push(routeCopy.replace(/^.|.$/g, ''));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
newRoute.push(routeCopy);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
routeName = newRoute.join('/');
|
|
153
|
-
|
|
154
|
-
if (!openApi.paths[routeName]) {
|
|
155
|
-
openApi.paths[routeName] = {};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const routeDescription =
|
|
159
|
-
route[Object.keys(route)[0]]?.description || 'empty description';
|
|
160
|
-
const permissions =
|
|
161
|
-
permissionWithRoutes[Object.keys(route)[0]][
|
|
162
|
-
permissionWithRoutes[Object.keys(route)[0]].length - 1
|
|
163
|
-
];
|
|
164
|
-
const routeDescriptionWithPermissions = `${
|
|
165
|
-
permissions || ''
|
|
166
|
-
} ${routeDescription}`;
|
|
167
|
-
const methodName = route[Object.keys(route)[0]].method.toLowerCase();
|
|
168
|
-
const routeTitle = route[Object.keys(route)[0]].name;
|
|
169
|
-
|
|
170
|
-
const routeFields = route[Object.keys(route)[0]].fields;
|
|
171
|
-
const routeQueryFields = route[Object.keys(route)[0]].queryFields;
|
|
172
|
-
|
|
173
|
-
if (!openApi.paths[routeName][methodName]) {
|
|
174
|
-
openApi.paths[routeName][methodName] = {};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
openApi.paths[routeName][methodName].tags = [];
|
|
178
|
-
|
|
179
|
-
openApi.paths[routeName][methodName].tags.push(
|
|
180
|
-
controller.contollerName.split('/')[0],
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
openApi.paths[routeName][methodName].summary = routeTitle;
|
|
184
|
-
openApi.paths[routeName][methodName].description =
|
|
185
|
-
routeDescriptionWithPermissions;
|
|
186
|
-
openApi.paths[routeName][methodName].parameters = [];
|
|
187
|
-
openApi.paths[routeName][methodName].security = securitySchemaNames;
|
|
188
|
-
|
|
189
|
-
openApi.paths[routeName][methodName].responses = {
|
|
190
|
-
200: {
|
|
191
|
-
description: 'Successfully',
|
|
192
|
-
},
|
|
193
|
-
201: {
|
|
194
|
-
description: 'The resource was created successfully',
|
|
195
|
-
},
|
|
196
|
-
400: {
|
|
197
|
-
description: 'There is a syntax error in the request',
|
|
198
|
-
},
|
|
199
|
-
401: {
|
|
200
|
-
description:
|
|
201
|
-
'Authentication is required to access the requested resource',
|
|
202
|
-
},
|
|
203
|
-
404: {
|
|
204
|
-
description:
|
|
205
|
-
'The server accepted the request, but did not find the corresponding resource at the specified URI',
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
for (const queryField of routeQueryFields) {
|
|
210
|
-
openApi.paths[routeName][methodName].parameters.push({
|
|
211
|
-
name: queryField.name,
|
|
212
|
-
in: 'query',
|
|
213
|
-
required: queryField?.required,
|
|
214
|
-
schema: {
|
|
215
|
-
type: queryField.type,
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
for (const routeField of routeParameters) {
|
|
221
|
-
openApi.paths[routeName][methodName].parameters.push({
|
|
222
|
-
name: routeField,
|
|
223
|
-
in: 'path',
|
|
224
|
-
required: true,
|
|
225
|
-
schema: {
|
|
226
|
-
type: 'string',
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (routeFields.length) {
|
|
232
|
-
const groupBodyFields = {};
|
|
233
|
-
const requiredFields = [];
|
|
234
|
-
let isMultipartFormaData = false;
|
|
235
|
-
for (const field of routeFields) {
|
|
236
|
-
if (field.required) {
|
|
237
|
-
requiredFields.push(field.name);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
switch (field.type) {
|
|
241
|
-
case 'object':
|
|
242
|
-
groupBodyFields[field.name] = {
|
|
243
|
-
properties: {},
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
for (const objField of field.fields) {
|
|
247
|
-
groupBodyFields[field.name].properties[objField.name] = {
|
|
248
|
-
// fields file has mixed type but openApi doesnt have this type
|
|
249
|
-
type: objField.type === 'mixed' ? 'string' : objField.type,
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
break;
|
|
254
|
-
|
|
255
|
-
case 'array':
|
|
256
|
-
groupBodyFields[field.name] = {
|
|
257
|
-
items: {
|
|
258
|
-
type: field.innerType,
|
|
259
|
-
},
|
|
260
|
-
};
|
|
261
|
-
break;
|
|
262
|
-
|
|
263
|
-
case 'lazy':
|
|
264
|
-
groupBodyFields[field.name] = {
|
|
265
|
-
oneOf: [
|
|
266
|
-
{
|
|
267
|
-
type: 'object',
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
type: 'string',
|
|
271
|
-
},
|
|
272
|
-
],
|
|
273
|
-
};
|
|
274
|
-
break;
|
|
275
|
-
|
|
276
|
-
case 'file':
|
|
277
|
-
groupBodyFields[field.name] = {
|
|
278
|
-
type: 'string',
|
|
279
|
-
format: 'binary',
|
|
280
|
-
};
|
|
281
|
-
isMultipartFormaData = true;
|
|
282
|
-
break;
|
|
283
|
-
default:
|
|
284
|
-
groupBodyFields[field.name] = {
|
|
285
|
-
type: field.type,
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const contentType = isMultipartFormaData
|
|
291
|
-
? 'multipart/form-data'
|
|
292
|
-
: 'application/json';
|
|
293
|
-
|
|
294
|
-
openApi.paths[routeName][methodName].requestBody = {
|
|
295
|
-
content: {
|
|
296
|
-
[contentType]: {
|
|
297
|
-
schema: {
|
|
298
|
-
type: 'object',
|
|
299
|
-
properties: groupBodyFields,
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
if (requiredFields.length) {
|
|
306
|
-
openApi.paths[routeName][methodName].requestBody.content[
|
|
307
|
-
contentType
|
|
308
|
-
].schema.required = requiredFields;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
const result = JSON.stringify(openApi);
|
|
315
|
-
|
|
316
|
-
if (this.args.output) {
|
|
317
|
-
await fs.writeFile(this.args.output, result);
|
|
318
|
-
this.logger.info(`Output to: ${this.args.output}`);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return result;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
export default GetOpenApiJson;
|
package/commands/SyncIndexes.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import * as url from 'node:url';
|
|
3
|
-
import AbstractCommand from '../modules/AbstractCommand.js';
|
|
4
|
-
|
|
5
|
-
class SyncIndexes extends AbstractCommand {
|
|
6
|
-
async run() {
|
|
7
|
-
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
8
|
-
const files = await this.getFilesPathWithInheritance(
|
|
9
|
-
path.join(dirname, '/../models'),
|
|
10
|
-
this.app.foldersConfig.models,
|
|
11
|
-
);
|
|
12
|
-
let models = [];
|
|
13
|
-
|
|
14
|
-
for (const file of files) {
|
|
15
|
-
models.push(path.basename(file.file, path.extname(file.file)));
|
|
16
|
-
}
|
|
17
|
-
models = models.sort();
|
|
18
|
-
this.logger.info(`Total found ${models.length} models`);
|
|
19
|
-
|
|
20
|
-
for (const modelName of models) {
|
|
21
|
-
const Model = this.app.getModel(modelName);
|
|
22
|
-
// eslint-disable-next-line no-await-in-loop
|
|
23
|
-
const removedIndexes = await Model.syncIndexes(); // await in loop not a bug. Lets do one by one
|
|
24
|
-
if (removedIndexes.length) {
|
|
25
|
-
this.logger.info(
|
|
26
|
-
`Model - ${modelName} removed indexes: ${removedIndexes}`,
|
|
27
|
-
);
|
|
28
|
-
} else {
|
|
29
|
-
this.logger.info(`Model - ${modelName} NO removed indexes`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static get description() {
|
|
35
|
-
return 'Synchronize indexes defined in models with a real one indexed on the database. Command will remove all indexes from the database that do not exist on model OR have different parameters. Then it will create a new indexes ';
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default SyncIndexes;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { promises as fs } from 'node:fs';
|
|
3
|
-
import AbstractCommand from '../../modules/AbstractCommand.js';
|
|
4
|
-
|
|
5
|
-
class CreateMigration extends AbstractCommand {
|
|
6
|
-
static get description() {
|
|
7
|
-
return 'Create new migration';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run() {
|
|
11
|
-
if (!this.args.name) {
|
|
12
|
-
return this.logger.error(
|
|
13
|
-
'Please provide migration name with key "--name={someName}"',
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
if (this.args.name.match(/^\d/)) {
|
|
17
|
-
return this.logger.error('Command cant start from nubmer');
|
|
18
|
-
}
|
|
19
|
-
const fileName = `${Date.now()}_${this.constructor.camelSentence(
|
|
20
|
-
this.args.name,
|
|
21
|
-
)}.js`;
|
|
22
|
-
|
|
23
|
-
const fileContent = this.constructor.getTemplate(
|
|
24
|
-
this.constructor.camelSentence(this.args.name),
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
await fs.writeFile(
|
|
28
|
-
path.join(this.app.foldersConfig.migrations, fileName),
|
|
29
|
-
fileContent,
|
|
30
|
-
);
|
|
31
|
-
return this.logger.info(`Migration created ${fileName}`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static camelSentence(str) {
|
|
35
|
-
return ` ${str}`
|
|
36
|
-
.toLowerCase()
|
|
37
|
-
.replace(/[^a-zA-Z0-9]+(.)/g, (match, chr) => chr.toUpperCase());
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static getTemplate(name) {
|
|
41
|
-
return `/* eslint-disable class-methods-use-this */
|
|
42
|
-
|
|
43
|
-
import Base from '@adaptivestone/framework/modules/Base.js';
|
|
44
|
-
|
|
45
|
-
class ${name} extends Base {
|
|
46
|
-
async up() {
|
|
47
|
-
// put here your mirgation up logic
|
|
48
|
-
// const YourModel = this.app.getModel('ModelName');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async down() {
|
|
52
|
-
// put here your mirgation down logic
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default ${name};
|
|
57
|
-
`;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default CreateMigration;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as url from 'node:url';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import AbstractCommand from '../../modules/AbstractCommand.js';
|
|
4
|
-
|
|
5
|
-
class Migrate extends AbstractCommand {
|
|
6
|
-
static get description() {
|
|
7
|
-
return 'Run all pending migrations';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run() {
|
|
11
|
-
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
12
|
-
|
|
13
|
-
const files = await this.getFilesPathWithInheritance(
|
|
14
|
-
path.join(dirname, '/../../migrations'),
|
|
15
|
-
this.app.foldersConfig.migrations,
|
|
16
|
-
);
|
|
17
|
-
files.sort(
|
|
18
|
-
(a, b) => Number(a.file.split('_')[0]) - Number(b.file.split('_')[0]),
|
|
19
|
-
);
|
|
20
|
-
const MigrationModel = this.app.getModel('Migration');
|
|
21
|
-
const lastMigration = await MigrationModel.findOne({})
|
|
22
|
-
.sort({ createdAt: -1 })
|
|
23
|
-
.exec();
|
|
24
|
-
|
|
25
|
-
let migrations = files;
|
|
26
|
-
|
|
27
|
-
if (lastMigration) {
|
|
28
|
-
const lastMigrationTime = Number(
|
|
29
|
-
lastMigration.migrationFile.split('_')[0],
|
|
30
|
-
);
|
|
31
|
-
migrations = files.filter(
|
|
32
|
-
(val) => Number(val.file.split('_')[0]) > lastMigrationTime,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
for (const migration of migrations) {
|
|
37
|
-
this.logger.info(`=== Start migration ${migration.file} ===`);
|
|
38
|
-
// eslint-disable-next-line no-await-in-loop
|
|
39
|
-
const { default: MigrationCommand } = await import(migration.path);
|
|
40
|
-
const migrationCommand = new MigrationCommand(this.app);
|
|
41
|
-
// eslint-disable-next-line no-await-in-loop
|
|
42
|
-
await migrationCommand.up();
|
|
43
|
-
// eslint-disable-next-line no-await-in-loop
|
|
44
|
-
await MigrationModel.create({
|
|
45
|
-
migrationFile: migration.file,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this.logger.info(
|
|
50
|
-
`=== Migration Finished. Migrated ${migrations.length} files ===`,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default Migrate;
|
package/config/auth.js
DELETED
package/config/http.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
port: process.env.HTTP_PORT || 3300,
|
|
3
|
-
hostname: process.env.HTTP_HOST || '0.0.0.0',
|
|
4
|
-
// if you want to use 'all' domains please copy this file to your app
|
|
5
|
-
// and set "corsDomains: [/./]
|
|
6
|
-
corsDomains: ['http://localhost:3000'],
|
|
7
|
-
myDomain: process.env.HTTP_DOMAIN || 'http://localhost:3300',
|
|
8
|
-
siteDomain: process.env.FRONT_DOMAIN || 'http://localhost:3000',
|
|
9
|
-
};
|
package/config/i18n.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* You can use any options from https://www.i18next.com/overview/configuration-options
|
|
3
|
-
*/
|
|
4
|
-
export default {
|
|
5
|
-
enabled: true,
|
|
6
|
-
preload: ['en', 'ru'],
|
|
7
|
-
supportedLngs: ['en', 'ru'], // should be at least one supported
|
|
8
|
-
fallbackLng: 'en',
|
|
9
|
-
saveMissing: false,
|
|
10
|
-
debug: false,
|
|
11
|
-
lookupQuerystring: 'lng', // string to detect language on query
|
|
12
|
-
};
|
package/config/ipDetector.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
transports: [
|
|
3
|
-
{
|
|
4
|
-
transport: 'winston-transport-sentry-node',
|
|
5
|
-
transportOptions: {
|
|
6
|
-
sentry: {
|
|
7
|
-
dsn: process.env.LOGGER_SENTRY_DSN || process.env.SENTRY_DSN,
|
|
8
|
-
},
|
|
9
|
-
level: process.env.LOGGER_SENTRY_LEVEL || 'info',
|
|
10
|
-
},
|
|
11
|
-
enable: process.env.LOGGER_SENTRY_ENABLE || false,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
transport: 'console',
|
|
15
|
-
transportOptions: {
|
|
16
|
-
level: process.env.LOGGER_CONSOLE_LEVEL || 'silly',
|
|
17
|
-
timestamp: true,
|
|
18
|
-
},
|
|
19
|
-
enable: process.env.LOGGER_CONSOLE_ENABLE || true,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
};
|
package/config/mail.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
from: 'Localhost <info@localhost>',
|
|
5
|
-
transports: {
|
|
6
|
-
sendMail: {
|
|
7
|
-
// path: "path to the sendmail command (defaults to 'sendmail')"
|
|
8
|
-
// args: 'an array of extra command line options to pass to the sendmail command (ie. ["-f", "foo@blurdybloop.com"]).'
|
|
9
|
-
},
|
|
10
|
-
stub: {},
|
|
11
|
-
smtp: {
|
|
12
|
-
// https://github.com/nodemailer/nodemailer#set-up-smtp
|
|
13
|
-
host: process.env.EMAIL_HOST || 'smtp.mailtrap.io',
|
|
14
|
-
port: process.env.EMAIL_PORT || 2525,
|
|
15
|
-
auth: {
|
|
16
|
-
user: process.env.EMAIL_USER,
|
|
17
|
-
pass: process.env.EMAIL_PASSWORD,
|
|
18
|
-
},
|
|
19
|
-
connectionTimeout: 10000, // timeout to 10 seconds
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
transport: process.env.EMAIL_TRANSPORT || 'smtp',
|
|
23
|
-
webResources: {
|
|
24
|
-
// https://github.com/jrit/web-resource-inliner path to find resources
|
|
25
|
-
relativeTo: path.resolve('src/services/messaging/email/resources'),
|
|
26
|
-
images: false,
|
|
27
|
-
},
|
|
28
|
-
globalVariablesToTemplates: {},
|
|
29
|
-
};
|
package/config/mongo.js
DELETED
package/config/rateLimiter.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
limiterOptions: {
|
|
3
|
-
// https://github.com/animir/node-rate-limiter-flexible
|
|
4
|
-
// https://github.com/animir/node-rate-limiter-flexible/wiki/Options
|
|
5
|
-
points: 10, // 10 points
|
|
6
|
-
duration: 60, // Per 60 seconds
|
|
7
|
-
},
|
|
8
|
-
driver: 'memory', // can be 'mongo', 'redis'
|
|
9
|
-
consumePoints: 1,
|
|
10
|
-
consumeKeyComponents: {
|
|
11
|
-
ip: true, // include ip to key generation
|
|
12
|
-
route: true, // include route to key generation
|
|
13
|
-
user: true, // include user id to key generation (if user exits)
|
|
14
|
-
request: [], // what should be included from request (req.appInfo.request) if it presented
|
|
15
|
-
},
|
|
16
|
-
};
|
package/config/redis.js
DELETED
package/config/validate.js
DELETED