itrm-tools 1.3.5-viio.3 → 1.3.5

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 (204) hide show
  1. package/README.md +2 -2
  2. package/dist/api/APIRequest.js +29 -22
  3. package/dist/api/APIRequest.js.map +1 -1
  4. package/dist/api/APIRouter.js +1 -3
  5. package/dist/api/APIRouter.js.map +1 -1
  6. package/dist/api/APIService.js +17 -11
  7. package/dist/api/APIService.js.map +1 -1
  8. package/dist/api/HttpsAPIService.js +13 -5
  9. package/dist/api/HttpsAPIService.js.map +1 -1
  10. package/dist/api/alegra/AlegraConnectionManager.js +50 -23
  11. package/dist/api/alegra/AlegraConnectionManager.js.map +1 -1
  12. package/dist/api/channel/ServerSentEventsManager.js +1 -2
  13. package/dist/api/channel/ServerSentEventsManager.js.map +1 -1
  14. package/dist/api/check/APIChecker.js +25 -11
  15. package/dist/api/check/APIChecker.js.map +1 -1
  16. package/dist/api/check/CheckableAPIRequest.js +29 -17
  17. package/dist/api/check/CheckableAPIRequest.js.map +1 -1
  18. package/dist/api/check/CheckableAPIRouter.js +29 -17
  19. package/dist/api/check/CheckableAPIRouter.js.map +1 -1
  20. package/dist/api/check/request/CheckableFileUploadingPostRequest.js +0 -2
  21. package/dist/api/check/request/CheckableFileUploadingPostRequest.js.map +1 -1
  22. package/dist/api/check/route/CorsCheckApiRouter.js +13 -2
  23. package/dist/api/check/route/CorsCheckApiRouter.js.map +1 -1
  24. package/dist/api/check/route/SimpleCheckableAPIRouter.js +13 -2
  25. package/dist/api/check/route/SimpleCheckableAPIRouter.js.map +1 -1
  26. package/dist/api/express/ExpressStandardConfiguration.d.ts +1 -1
  27. package/dist/api/express/ExpressStandardConfiguration.js +9 -1
  28. package/dist/api/express/ExpressStandardConfiguration.js.map +1 -1
  29. package/dist/api/external/ExternalApiConnection.d.ts +13 -0
  30. package/dist/api/external/ExternalApiConnection.js +21 -0
  31. package/dist/api/external/ExternalApiConnection.js.map +1 -0
  32. package/dist/api/external/cetus/CetusStrategyApiManager.d.ts +4 -3
  33. package/dist/api/external/cetus/CetusStrategyApiManager.js +22 -10
  34. package/dist/api/external/cetus/CetusStrategyApiManager.js.map +1 -1
  35. package/dist/api/request/RequestAxiosCall.d.ts +4 -4
  36. package/dist/api/request/RequestAxiosCall.js +37 -20
  37. package/dist/api/request/RequestAxiosCall.js.map +1 -1
  38. package/dist/api/request/crud/CrudManager.d.ts +2 -2
  39. package/dist/api/request/crud/CrudServiceManager.d.ts +5 -5
  40. package/dist/api/request/crud/CrudServiceManager.js +17 -6
  41. package/dist/api/request/crud/CrudServiceManager.js.map +1 -1
  42. package/dist/api/request/crud/common/ActivityHistoryManager.d.ts +40 -0
  43. package/dist/api/request/crud/common/ActivityHistoryManager.js +84 -0
  44. package/dist/api/request/crud/common/ActivityHistoryManager.js.map +1 -0
  45. package/dist/api/request/crud/common/ApplicationManager.d.ts +39 -0
  46. package/dist/api/request/crud/common/ApplicationManager.js +72 -0
  47. package/dist/api/request/crud/common/ApplicationManager.js.map +1 -0
  48. package/dist/api/request/crud/common/AvailablePlatformManager.d.ts +39 -0
  49. package/dist/api/request/crud/common/AvailablePlatformManager.js +84 -0
  50. package/dist/api/request/crud/common/AvailablePlatformManager.js.map +1 -0
  51. package/dist/api/request/crud/common/ComponentManager.d.ts +56 -0
  52. package/dist/api/request/crud/common/ComponentManager.js +78 -0
  53. package/dist/api/request/crud/common/ComponentManager.js.map +1 -0
  54. package/dist/api/request/crud/common/KeyManager.d.ts +42 -0
  55. package/dist/api/request/crud/common/KeyManager.js +85 -0
  56. package/dist/api/request/crud/common/KeyManager.js.map +1 -0
  57. package/dist/api/request/crud/common/PlatformManager.d.ts +44 -0
  58. package/dist/api/request/crud/common/PlatformManager.js +75 -0
  59. package/dist/api/request/crud/common/PlatformManager.js.map +1 -0
  60. package/dist/api/request/crud/common/RoleManager.d.ts +51 -0
  61. package/dist/api/request/crud/common/RoleManager.js +72 -0
  62. package/dist/api/request/crud/common/RoleManager.js.map +1 -0
  63. package/dist/api/request/crud/common/StatusManager.d.ts +34 -0
  64. package/dist/api/request/crud/common/StatusManager.js +72 -0
  65. package/dist/api/request/crud/common/StatusManager.js.map +1 -0
  66. package/dist/api/request/crud/common/TypeManager.d.ts +33 -0
  67. package/dist/api/request/crud/common/TypeManager.js +74 -0
  68. package/dist/api/request/crud/common/TypeManager.js.map +1 -0
  69. package/dist/api/request/crud/common/UserCredentialsManager.d.ts +39 -0
  70. package/dist/api/request/crud/common/UserCredentialsManager.js +82 -0
  71. package/dist/api/request/crud/common/UserCredentialsManager.js.map +1 -0
  72. package/dist/api/request/crud/common/UserManager.d.ts +35 -0
  73. package/dist/api/request/crud/common/UserManager.js +78 -0
  74. package/dist/api/request/crud/common/UserManager.js.map +1 -0
  75. package/dist/api/request/docs/DocumentationModels.d.ts +4 -4
  76. package/dist/api/request/docs/DocumentationModels.js.map +1 -1
  77. package/dist/api/request/docs/DocumentationRequest.js +7 -4
  78. package/dist/api/request/docs/DocumentationRequest.js.map +1 -1
  79. package/dist/api/route/SimpleAPIRouter.js +13 -2
  80. package/dist/api/route/SimpleAPIRouter.js.map +1 -1
  81. package/dist/cryptography/CipheringAlgorithm.d.ts +4 -0
  82. package/dist/cryptography/CipheringAlgorithm.js +3 -0
  83. package/dist/cryptography/CipheringAlgorithm.js.map +1 -0
  84. package/dist/cryptography/EncryptionAlgorithm.js.map +1 -0
  85. package/dist/cryptography/KeyGenerator.d.ts +3 -0
  86. package/dist/cryptography/KeyGenerator.js +3 -0
  87. package/dist/cryptography/KeyGenerator.js.map +1 -0
  88. package/dist/cryptography/Signer.d.ts +4 -0
  89. package/dist/cryptography/Signer.js +3 -0
  90. package/dist/cryptography/Signer.js.map +1 -0
  91. package/dist/cryptography/algorithm/AesCipheringAlgorithm.d.ts +6 -0
  92. package/dist/cryptography/algorithm/AesCipheringAlgorithm.js +28 -0
  93. package/dist/cryptography/algorithm/AesCipheringAlgorithm.js.map +1 -0
  94. package/dist/cryptography/generate/StandardApiKeyGenerator.d.ts +9 -0
  95. package/dist/cryptography/generate/StandardApiKeyGenerator.js +18 -0
  96. package/dist/cryptography/generate/StandardApiKeyGenerator.js.map +1 -0
  97. package/dist/cryptography/sign/ApiKeySigner.d.ts +14 -0
  98. package/dist/cryptography/sign/ApiKeySigner.js +35 -0
  99. package/dist/cryptography/sign/ApiKeySigner.js.map +1 -0
  100. package/dist/database/mongoose/MongooseModelManager.d.ts +7 -1
  101. package/dist/database/mongoose/MongooseModelManager.js +14 -5
  102. package/dist/database/mongoose/MongooseModelManager.js.map +1 -1
  103. package/dist/database/redis/RedisConnection.js +0 -1
  104. package/dist/database/redis/RedisConnection.js.map +1 -1
  105. package/dist/database/redis/RedisModelManager.js +0 -1
  106. package/dist/database/redis/RedisModelManager.js.map +1 -1
  107. package/dist/database/sequelize/SequelizeConnection.js +0 -1
  108. package/dist/database/sequelize/SequelizeConnection.js.map +1 -1
  109. package/dist/database/sequelize/SequelizeModelManager.js +15 -6
  110. package/dist/database/sequelize/SequelizeModelManager.js.map +1 -1
  111. package/dist/index.d.ts +17 -2
  112. package/dist/index.js +32 -3
  113. package/dist/index.js.map +1 -1
  114. package/dist/log/Logger.js +0 -2
  115. package/dist/log/Logger.js.map +1 -1
  116. package/dist/log/LoggerManager.js +21 -11
  117. package/dist/log/LoggerManager.js.map +1 -1
  118. package/dist/log/LoggerWebSocket.js +2 -4
  119. package/dist/log/LoggerWebSocket.js.map +1 -1
  120. package/dist/web3/coingecko/CoingeckoPriceFinder.js +36 -24
  121. package/dist/web3/coingecko/CoingeckoPriceFinder.js.map +1 -1
  122. package/package.json +74 -99
  123. package/.github/workflows/node.js.yml +0 -30
  124. package/dist/algorithm/encryption/EncryptionAlgorithm.js.map +0 -1
  125. package/dist/api/external/ExternalApiSigner.d.ts +0 -15
  126. package/dist/api/external/ExternalApiSigner.js +0 -25
  127. package/dist/api/external/ExternalApiSigner.js.map +0 -1
  128. package/jest.config.js +0 -7
  129. package/sequelize.sqlite +0 -0
  130. package/src/algorithm/encryption/EncryptionAlgorithm.ts +0 -4
  131. package/src/api/APIRequest.ts +0 -176
  132. package/src/api/APIRequestBuilder.ts +0 -28
  133. package/src/api/APIRouter.ts +0 -26
  134. package/src/api/APIService.ts +0 -117
  135. package/src/api/ExpressConfiguration.ts +0 -5
  136. package/src/api/HttpsAPIService.ts +0 -35
  137. package/src/api/alegra/AlegraConnectionManager.ts +0 -54
  138. package/src/api/alegra/AlegraTypes.ts +0 -150
  139. package/src/api/builder/StandardGetRequestBuilder.ts +0 -34
  140. package/src/api/channel/ServerSentEventsManager.ts +0 -28
  141. package/src/api/check/APIChecker.ts +0 -50
  142. package/src/api/check/CheckableAPIRequest.ts +0 -33
  143. package/src/api/check/CheckableAPIRouter.ts +0 -39
  144. package/src/api/check/request/CheckableDeleteRequest.ts +0 -17
  145. package/src/api/check/request/CheckableFileUploadingPostRequest.ts +0 -26
  146. package/src/api/check/request/CheckableGetRequest.ts +0 -17
  147. package/src/api/check/request/CheckablePostRequest.ts +0 -17
  148. package/src/api/check/request/CheckablePutRequest.ts +0 -17
  149. package/src/api/check/route/CorsCheckApiRouter.ts +0 -22
  150. package/src/api/check/route/SimpleCheckableAPIRouter.ts +0 -14
  151. package/src/api/express/ExpressFileUploadingConfiguration.ts +0 -22
  152. package/src/api/express/ExpressLogableConfig.ts +0 -11
  153. package/src/api/express/ExpressStandardConfiguration.ts +0 -25
  154. package/src/api/external/ExternalApiSigner.ts +0 -29
  155. package/src/api/external/cetus/CetusStrategyApiManager.ts +0 -48
  156. package/src/api/request/DeleteRequest.ts +0 -16
  157. package/src/api/request/GetRequest.ts +0 -16
  158. package/src/api/request/PostRequest.ts +0 -16
  159. package/src/api/request/PutRequest.ts +0 -16
  160. package/src/api/request/RequestAxiosCall.ts +0 -38
  161. package/src/api/request/crud/CrudManager.ts +0 -11
  162. package/src/api/request/crud/CrudServiceManager.ts +0 -117
  163. package/src/api/request/docs/DocumentationModels.ts +0 -121
  164. package/src/api/request/docs/DocumentationRequest.ts +0 -132
  165. package/src/api/route/SimpleAPIRouter.ts +0 -12
  166. package/src/database/mongoose/MongooseModelManager.ts +0 -65
  167. package/src/database/redis/RedisConnection.ts +0 -18
  168. package/src/database/redis/RedisModelManager.ts +0 -23
  169. package/src/database/sequelize/SequelizeConnection.ts +0 -45
  170. package/src/database/sequelize/SequelizeModelManager.ts +0 -71
  171. package/src/index.ts +0 -51
  172. package/src/log/Logger.ts +0 -27
  173. package/src/log/LoggerManager.ts +0 -50
  174. package/src/log/LoggerWebSocket.ts +0 -13
  175. package/src/math/Utils.ts +0 -4
  176. package/src/types/payments.ts +0 -811
  177. package/src/web3/Coin.ts +0 -18
  178. package/src/web3/coingecko/CoingeckoPriceFinder.ts +0 -75
  179. package/test/api/APIRouter.test.ts +0 -78
  180. package/test/api/APIService.test.ts +0 -50
  181. package/test/api/APITestDefinitions.ts +0 -7
  182. package/test/api/CORS.test.ts +0 -56
  183. package/test/api/alegra/AlegraConnectionManager.test.ts +0 -32
  184. package/test/api/check/CheckDefinitions.ts +0 -47
  185. package/test/api/check/CheckableAPIRouter.test.ts +0 -67
  186. package/test/api/check/CheckableDeleteRequest.test.ts +0 -92
  187. package/test/api/check/CheckableGetRequest.test.ts +0 -99
  188. package/test/api/check/CheckablePostRequest.test.ts +0 -108
  189. package/test/api/check/CheckablePutRequest.test.ts +0 -99
  190. package/test/api/docs/DocumentationRequest.test.ts +0 -192
  191. package/test/api/request/DeleteRequest.test.ts +0 -117
  192. package/test/api/request/GetRequest.test.ts +0 -140
  193. package/test/api/request/PostRequest.test.ts +0 -237
  194. package/test/api/request/PutRequest.test.ts +0 -166
  195. package/test/database/mongoose/MongooseModelManager.test.ts +0 -139
  196. package/test/database/redis/RedisConnection.test.ts +0 -7
  197. package/test/database/sequelize/SequealizeDefinitions.ts +0 -6
  198. package/test/database/sequelize/SequelizeConnection.test.ts +0 -30
  199. package/test/database/sequelize/SequelizeModelManager.test.ts +0 -206
  200. package/test/log/Logger.test.ts +0 -44
  201. package/test/web3/coingecko/CoingeckoPriceFinder.test.ts +0 -72
  202. package/tsconfig.json +0 -23
  203. /package/dist/{algorithm/encryption → cryptography}/EncryptionAlgorithm.d.ts +0 -0
  204. /package/dist/{algorithm/encryption → cryptography}/EncryptionAlgorithm.js +0 -0
@@ -1,17 +0,0 @@
1
- import { Express, Router } from "express";
2
- import { APIRequestConfig, RequestMethod } from "../../APIRequest";
3
- import { CheckableAPIRequest } from "../CheckableAPIRequest";
4
-
5
- export abstract class CheckablePostRequest extends CheckableAPIRequest {
6
- constructor(config: APIRequestConfig) {
7
- super(RequestMethod.POST, config);
8
- }
9
-
10
- public addToApp(app: Express): void {
11
- app.post(this.path, this.check, this.process);
12
- }
13
-
14
- public addToRouter(router: Router): void {
15
- router.post(this.path, this.check, this.process);
16
- }
17
- }
@@ -1,17 +0,0 @@
1
- import { Express, Router } from "express";
2
- import { APIRequestConfig, RequestMethod } from "../../APIRequest";
3
- import { CheckableAPIRequest } from "../CheckableAPIRequest";
4
-
5
- export abstract class CheckablePutRequest extends CheckableAPIRequest {
6
- constructor(config: APIRequestConfig) {
7
- super(RequestMethod.PUT, config);
8
- }
9
-
10
- public addToApp(app: Express): void {
11
- app.put(this.path, this.check, this.process);
12
- }
13
-
14
- public addToRouter(router: Router): void {
15
- router.put(this.path, this.check, this.process);
16
- }
17
- }
@@ -1,22 +0,0 @@
1
- import { NextFunction, Request, Response, RouterOptions } from "express";
2
- import { CheckableAPIRouter } from "../CheckableAPIRouter";
3
-
4
- export class CorsCheckApiRouter extends CheckableAPIRouter {
5
- constructor(path: string, options?: RouterOptions) {
6
- super(path, options);
7
- }
8
-
9
- protected setHeaders(res: Response<any, Record<string, any>>): void {
10
- res.setHeader("Access-Control-Allow-Origin", "*");
11
- res.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
12
- res.setHeader("Access-Control-Allow-Headers", "Content-Type,Authorization,platform");
13
- }
14
-
15
- protected async runMiddleware(
16
- req: Request,
17
- res: Response,
18
- next: NextFunction
19
- ): Promise<void | Response> {
20
- return next();
21
- }
22
- }
@@ -1,14 +0,0 @@
1
- import { NextFunction, Request, Response, RouterOptions } from "express";
2
- import { CheckableAPIRouter } from "../CheckableAPIRouter";
3
-
4
- export class SimpleCheckableAPIRouter extends CheckableAPIRouter {
5
- constructor(path: string, options?: RouterOptions) {
6
- super(path, options);
7
- }
8
-
9
- protected setHeaders(res: Response<any, Record<string, any>>): void { }
10
-
11
- protected async runMiddleware(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
12
- return next();
13
- }
14
- }
@@ -1,22 +0,0 @@
1
- import { ExpressStandardConfiguration } from "./ExpressStandardConfiguration";
2
- import { ITRMAPIServiceGlobal } from "../APIService";
3
- import { Express } from "express";
4
- import multer from "multer";
5
-
6
- export function initializeFileUploadingGlobalVars() {
7
- if (!ITRMAPIServiceGlobal.tools.file) {
8
- const storage = multer.memoryStorage();
9
- ITRMAPIServiceGlobal.tools.file = {
10
- storage: storage,
11
- upload: multer({ storage })
12
- };
13
- }
14
- }
15
-
16
- export class ExpressFileUploadingConfiguration extends ExpressStandardConfiguration {
17
- public apply(app: Express): void {
18
- super.apply(app);
19
- initializeFileUploadingGlobalVars();
20
- app.use(ITRMAPIServiceGlobal.tools.file.upload.array('file'));
21
- }
22
- }
@@ -1,11 +0,0 @@
1
- import { Express } from "express";
2
- import morgan from "morgan";
3
- import { ExpressStandardConfiguration } from "./ExpressStandardConfiguration";
4
-
5
- export class ExpressLogableConfig extends ExpressStandardConfiguration {
6
- apply(app: Express): void {
7
- super.apply(app);
8
-
9
- app.use(morgan(':remote-addr - :remote-user [:date[web]] ":method :url HTTP/:http-version" :status :res[content-length]'));
10
- }
11
- }
@@ -1,25 +0,0 @@
1
- import express, { Express } from "express";
2
- import { ExpressConfiguration } from "../ExpressConfiguration";
3
- import { ITRMAPIServiceGlobal } from "../APIService";
4
- import cors from 'cors';
5
-
6
- export class ExpressStandardConfiguration implements ExpressConfiguration {
7
- public apply(app: Express): void {
8
- app.use(ExpressStandardConfiguration.getCorsConfiguration());
9
- app.use(express.json({ limit: '50mb' }));
10
- app.use(express.urlencoded({ limit: '50mb', extended: true }));
11
- //app.use(urlencoded({ extended: true }));
12
- }
13
-
14
- public static getCorsConfiguration() {
15
- return cors({
16
- origin: function (origin: any, callback: any) {
17
- let whitelist = ITRMAPIServiceGlobal.whitelist;
18
- if (whitelist.length == 0 || (origin && whitelist.indexOf(origin) !== -1))
19
- callback(null, true);
20
- else
21
- callback(new Error('Not allowed by CORS'), false);
22
- }
23
- });
24
- }
25
- }
@@ -1,29 +0,0 @@
1
- import { RequestMethod } from "../APIRequest";
2
- import { HmacSHA256, enc } from 'crypto-js';
3
-
4
- export interface ApiKeyPair {
5
- publicKey: string;
6
- secretKey: string;
7
- }
8
-
9
- export class ExternalApiSigner {
10
- private keys: ApiKeyPair;
11
- private service: string;
12
-
13
- constructor(service: string, keys: ApiKeyPair) {
14
- this.service = service;
15
- this.keys = keys;
16
- }
17
-
18
- public sign(method: RequestMethod, path: string, body?: any) {
19
- let nonce = Date.now();
20
- let message = nonce + method + path.replace(/ /g, '%20') + (body ? JSON.stringify(body) : "{}");
21
- const hash = HmacSHA256(message, this.keys.secretKey);
22
- let signature = enc.Hex.stringify(hash);
23
- return {
24
- headers: {
25
- Authorization: `${this.service} ${this.keys.publicKey}:${nonce}:${signature}`
26
- }
27
- };
28
- }
29
- }
@@ -1,48 +0,0 @@
1
- import { AxiosRequestConfig } from "axios";
2
- import { ApiKeyPair, ExternalApiSigner } from "../ExternalApiSigner";
3
- import { RequestMethod } from "../../APIRequest";
4
- import { RequestAxiosCall } from "../../request/RequestAxiosCall";
5
-
6
- export interface CetusRate {
7
- symbol: string;
8
- source: string;
9
- bid?: number;
10
- ask?: number;
11
- spot?: number;
12
- prevDayClose?: number;
13
- };
14
-
15
- export enum CetusPair {
16
- USDCOP = "USDCOP"
17
- }
18
-
19
- export interface CetusStrategy {
20
- id: number;
21
- name: string;
22
- settings: any;
23
- memory: any;
24
- account: string;
25
- pair: string;
26
- intermediary: string;
27
- status: string;
28
- }
29
-
30
- export class CetusStrategyApiManager extends ExternalApiSigner {
31
- private apiUrl: string;
32
-
33
- constructor(keys: ApiKeyPair, apiUrl: string) {
34
- super('cetus', keys);
35
- this.apiUrl = apiUrl;
36
- }
37
-
38
- public async getRates() {
39
- let signature: AxiosRequestConfig = this.sign(RequestMethod.GET, '/v1/rates');
40
- return ((await RequestAxiosCall.get(`${this.apiUrl}/v1/rates`, signature)) as { status: string; rates: CetusRate[]; }).rates;
41
- }
42
-
43
- public async getStrategies(name: string, pair: CetusPair, account: string) {
44
- let url = `/v1/strategies?name=${name}&pair=${pair}&account=${account}`;
45
- let signature: AxiosRequestConfig = this.sign(RequestMethod.GET, url);
46
- return (((await RequestAxiosCall.get(`${this.apiUrl}${url}`, signature)) as any).result) as CetusStrategy[];
47
- }
48
- }
@@ -1,16 +0,0 @@
1
- import { Express, Router } from "express";
2
- import { APIRequest, APIRequestConfig, RequestMethod } from "../APIRequest";
3
-
4
- export abstract class DeleteRequest extends APIRequest {
5
- constructor(config: APIRequestConfig) {
6
- super(RequestMethod.DELETE, config);
7
- }
8
-
9
- public addToApp(app: Express): void {
10
- app.delete(this.path, this.process);
11
- }
12
-
13
- public addToRouter(router: Router): void {
14
- router.delete(this.path, this.process);
15
- }
16
- }
@@ -1,16 +0,0 @@
1
- import { Express, Router } from "express";
2
- import { APIRequest, APIRequestConfig, RequestMethod } from "../APIRequest";
3
-
4
- export abstract class GetRequest extends APIRequest {
5
- constructor(config: APIRequestConfig) {
6
- super(RequestMethod.GET, config);
7
- }
8
-
9
- public addToApp(app: Express): void {
10
- app.get(this.path, this.process);
11
- }
12
-
13
- public addToRouter(router: Router): void {
14
- router.get(this.path, this.process);
15
- }
16
- }
@@ -1,16 +0,0 @@
1
- import { Express, Router } from "express";
2
- import { APIRequest, APIRequestConfig, RequestMethod } from "../APIRequest";
3
-
4
- export abstract class PostRequest extends APIRequest {
5
- constructor(config: APIRequestConfig) {
6
- super(RequestMethod.POST, config);
7
- }
8
-
9
- public addToApp(app: Express): void {
10
- app.post(this.path, this.process);
11
- }
12
-
13
- public addToRouter(router: Router): void {
14
- router.post(this.path, this.process);
15
- }
16
- }
@@ -1,16 +0,0 @@
1
- import { Express, Router } from "express";
2
- import { APIRequest, APIRequestConfig, RequestMethod } from "../APIRequest";
3
-
4
- export abstract class PutRequest extends APIRequest {
5
- constructor(config: APIRequestConfig) {
6
- super(RequestMethod.PUT, config);
7
- }
8
-
9
- public addToApp(app: Express): void {
10
- app.put(this.path, this.process);
11
- }
12
-
13
- public addToRouter(router: Router): void {
14
- router.put(this.path, this.process);
15
- }
16
- }
@@ -1,38 +0,0 @@
1
- import axios, { AxiosRequestConfig } from "axios";
2
- import axiosRetry from 'axios-retry';
3
-
4
- axiosRetry(axios, { retries: 3, retryDelay: (retryCount) => { return 2000; } });
5
-
6
- export class RequestAxiosCall {
7
- public static async get(url: string, config?: AxiosRequestConfig<any>) {
8
- return new Promise((resolve, reject) => {
9
- axios.get(url, config ?? { headers: { 'Content-Type': 'application/json' } })
10
- .then(response => { resolve(response.data) })
11
- .catch(err => { reject(err) });
12
- });
13
- }
14
-
15
- public static async post(url: string, body: any, config?: AxiosRequestConfig) {
16
- return new Promise((resolve, reject) => {
17
- axios.post(url, body, config ?? { headers: { 'Content-Type': 'application/json' } })
18
- .then(response => { resolve(response.data) })
19
- .catch(err => { reject(err) });
20
- });
21
- }
22
-
23
- public static async put(url: string, body: any, config?: AxiosRequestConfig) {
24
- return new Promise((resolve, reject) => {
25
- axios.put(url, body, config ?? { headers: { 'Content-Type': 'application/json' } })
26
- .then(response => { resolve(response.data) })
27
- .catch(err => { reject(err) });
28
- });
29
- }
30
-
31
- public static async delete(url: string, config?: AxiosRequestConfig) {
32
- return new Promise((resolve, reject) => {
33
- axios.delete(url, config ?? { headers: { 'Content-Type': 'application/json' } })
34
- .then(response => { resolve(response.data) })
35
- .catch(err => { reject(err) });
36
- });
37
- }
38
- }
@@ -1,11 +0,0 @@
1
- export interface CrudManager<A, D, I> {
2
- find(details: D): Promise<I | undefined>;
3
- findAll(details: D): Promise<I[] | undefined>;
4
- findById(id: A): Promise<I | undefined>;
5
- findOrCreate(details: D): Promise<I | undefined>;
6
- create(details: D): Promise<I | undefined>;
7
- createMany(details: D): Promise<I[] | undefined>;
8
- count(details: D):Promise<{ result: number }>;
9
- modify(item: I): Promise<any>;
10
- destroy(item: I): Promise<any>;
11
- }
@@ -1,117 +0,0 @@
1
- import { AxiosRequestConfig } from "axios";
2
- import { CrudManager } from "./CrudManager";
3
- import { RequestAxiosCall } from "../RequestAxiosCall";
4
-
5
- export interface StandardIdRequestDefinition {
6
- id: number,
7
- config?: AxiosRequestConfig
8
- }
9
-
10
- export abstract class CrudServiceManager<D, I> implements CrudManager<StandardIdRequestDefinition, D, I> {
11
- public async findOrCreate(details: D): Promise<I | undefined> {
12
- let item: any = await this.find(details);
13
- if (!item)
14
- item = await this.create(details);
15
- return item;
16
- }
17
-
18
- protected extractItem(response: any, key: string) {
19
- if (response[key] && response[key].length > 0)
20
- return response[key][0];
21
- return undefined;
22
- }
23
-
24
- protected extractItems(response: any, key: string) {
25
- let result = [];
26
- if (response[key] && response[key].length > 0)
27
- for (let item of response[key])
28
- result.push(item);
29
- return result;
30
- }
31
-
32
- protected sendFinding(url: string, config?: AxiosRequestConfig) {
33
- return new Promise<I | undefined>((resolve, reject) => {
34
- RequestAxiosCall.get(url, config)
35
- .then((response: any) => {
36
- resolve(this.extractItem(response, 'result'));
37
- }).catch((err: any) => {
38
- reject(err);
39
- });
40
- });
41
- }
42
-
43
- protected sendAllFinding(url: string, config?: AxiosRequestConfig) {
44
- return new Promise<I[] | undefined>((resolve, reject) => {
45
- RequestAxiosCall.get(url, config)
46
- .then((response: any) => {
47
- resolve(this.extractItems(response, 'result'));
48
- }).catch((err: any) => {
49
- reject(err);
50
- });
51
- });
52
- }
53
-
54
- protected sendCreation(url: string, body: any, config?: AxiosRequestConfig) {
55
- return new Promise<I | undefined>((resolve, reject) => {
56
- RequestAxiosCall.post(url, body, config)
57
- .then((response: any) => {
58
- resolve(this.extractItem(response, 'items'));
59
- }).catch((err: any) => {
60
- reject(err);
61
- });
62
- });
63
- }
64
-
65
- protected sendCreationMany(url: string, values: any[], config?: AxiosRequestConfig) {
66
- return new Promise<I[] | undefined>((resolve, reject) => {
67
- RequestAxiosCall.post(url, { values: values }, config)
68
- .then((response: any) => {
69
- resolve(this.extractItems(response, 'items'));
70
- }).catch((err: any) => {
71
- reject(err);
72
- });
73
- });
74
- }
75
-
76
- protected sendCounting(url: string, config?: AxiosRequestConfig) {
77
- return new Promise<{ result: number; } | undefined >((resolve, reject) => {
78
- RequestAxiosCall.get(`${url}${url.indexOf('?') !== -1 ? '&' : '?'}count=true`, config)
79
- .then((response: any) => {
80
- resolve(response);
81
- }).catch((err: any) => {
82
- reject(err);
83
- });
84
- });
85
- }
86
-
87
- protected sendModification(url: string, modification: I, config?: AxiosRequestConfig) {
88
- return new Promise<any>((resolve, reject) => {
89
- RequestAxiosCall.put(url, { ...modification }, config)
90
- .then((response: any) => {
91
- resolve(response);
92
- }).catch((err: any) => {
93
- reject(err);
94
- });
95
- });
96
- }
97
-
98
- protected sendDestruction(url: string, config?: AxiosRequestConfig) {
99
- return new Promise<any>((resolve, reject) => {
100
- RequestAxiosCall.delete(url, config)
101
- .then((response: any) => {
102
- resolve(response);
103
- }).catch((err: any) => {
104
- reject(err);
105
- });
106
- });
107
- }
108
-
109
- public abstract find(details: D): Promise<I | undefined>;
110
- public abstract findAll(details: D): Promise<I[] | undefined>;
111
- public abstract findById(id: StandardIdRequestDefinition): Promise<I | undefined>;
112
- public abstract create(details: D): Promise<I | undefined>;
113
- public abstract createMany(details: D): Promise<I[] | undefined>;
114
- public abstract count(details: D): Promise<{ result: number }>;
115
- public abstract modify(item: I): Promise<any>;
116
- public abstract destroy(item: I): Promise<any>;
117
- }
@@ -1,121 +0,0 @@
1
- export let defaultDocumentationSchema = {
2
- openapi: "3.0.0",
3
- info: {
4
- title: "Documentation",
5
- version: "1.0.0",
6
- description: "Documentation",
7
- contact: {}
8
- },
9
- servers: [
10
- {
11
- url: "http://localhost:3000"
12
- }
13
- ],
14
- paths: {},
15
- tags: [] as { name: string }[],
16
- components: {},
17
- security: [] as any
18
- };
19
-
20
- export let defaultBodySchema = {
21
- content: {
22
- "application/json": {
23
- schema: {
24
- type: "object",
25
- properties: {} as any
26
- }
27
- }
28
- }
29
- };
30
-
31
- export let securitySchema = {
32
- "components": {
33
- "securitySchemes": {
34
- "bearerAuth": {
35
- "type": "http",
36
- "scheme": "bearer",
37
- "bearerFormat": "JWT"
38
- }
39
- }
40
- }
41
- };
42
-
43
- export let securityDeclaration = {
44
- "security": [
45
- {
46
- "bearerAuth": []
47
- }
48
- ]
49
- }
50
-
51
- export const httpStatusCodes: { [key: number]: string } = {
52
- 100: 'Continue',
53
- 101: 'Switching Protocols',
54
- 102: 'Processing',
55
- 103: 'Early Hints',
56
- 200: 'OK',
57
- 201: 'Created',
58
- 202: 'Accepted',
59
- 203: 'Non-Authoritative Information',
60
- 204: 'No Content',
61
- 205: 'Reset Content',
62
- 206: 'Partial Content',
63
- 207: 'Multi-Status',
64
- 208: 'Already Reported',
65
- 226: 'IM Used',
66
- 300: 'Multiple Choices',
67
- 301: 'Moved Permanently',
68
- 302: 'Found',
69
- 303: 'See Other',
70
- 304: 'Not Modified',
71
- 305: 'Use Proxy',
72
- 306: 'Switch Proxy',
73
- 307: 'Temporary Redirect',
74
- 308: 'Permanent Redirect',
75
- 400: 'Bad Request',
76
- 401: 'Unauthorized',
77
- 402: 'Payment Required',
78
- 403: 'Forbidden',
79
- 404: 'Not Found',
80
- 405: 'Method Not Allowed',
81
- 406: 'Not Acceptable',
82
- 407: 'Proxy Authentication Required',
83
- 408: 'Request Timeout',
84
- 409: 'Conflict',
85
- 410: 'Gone',
86
- 411: 'Length Required',
87
- 412: 'Precondition Failed',
88
- 413: 'Payload Too Large',
89
- 414: 'URI Too Long',
90
- 415: 'Unsupported Media Type',
91
- 416: 'Range Not Satisfiable',
92
- 417: 'Expectation Failed',
93
- 418: 'I\'m a Teapot',
94
- 421: 'Misdirected Request',
95
- 422: 'Unprocessable Entity',
96
- 423: 'Locked',
97
- 424: 'Failed Dependency',
98
- 425: 'Too Early',
99
- 426: 'Upgrade Required',
100
- 428: 'Precondition Required',
101
- 429: 'Too Many Requests',
102
- 431: 'Request Header Fields Too Large',
103
- 451: 'Unavailable For Legal Reasons',
104
- 500: 'Internal Server Error',
105
- 501: 'Not Implemented',
106
- 502: 'Bad Gateway',
107
- 503: 'Service Unavailable',
108
- 504: 'Gateway Timeout',
109
- 505: 'HTTP Version Not Supported',
110
- 506: 'Variant Also Negotiates',
111
- 507: 'Insufficient Storage',
112
- 508: 'Loop Detected',
113
- 510: 'Not Extended',
114
- 511: 'Network Authentication Required'
115
- };
116
-
117
-
118
-
119
-
120
-
121
-