@duvdu-v1/duvdu 1.1.262 → 1.1.264

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/build/index.d.ts CHANGED
@@ -82,6 +82,7 @@ export * from './models/favourites.model';
82
82
  export * from './models/Bookmark.model';
83
83
  export * from './models/Bookmark-projects.model';
84
84
  export * from './models/contractCancel.model';
85
+ export * from './models/transactions.model';
85
86
  export * from './services/category.service';
86
87
  export * from './services/projectView.service';
87
88
  export * from './services/rank.service';
package/build/index.js CHANGED
@@ -99,6 +99,7 @@ __exportStar(require("./models/favourites.model"), exports);
99
99
  __exportStar(require("./models/Bookmark.model"), exports);
100
100
  __exportStar(require("./models/Bookmark-projects.model"), exports);
101
101
  __exportStar(require("./models/contractCancel.model"), exports);
102
+ __exportStar(require("./models/transactions.model"), exports);
102
103
  __exportStar(require("./services/category.service"), exports);
103
104
  __exportStar(require("./services/projectView.service"), exports);
104
105
  __exportStar(require("./services/rank.service"), exports);
@@ -1,5 +1,5 @@
1
1
  import RedisStore from 'connect-redis';
2
- export declare const redisClient: import("@redis/client").RedisClientType<{
2
+ export declare const getRedisClient: () => import("@redis/client").RedisClientType<{
3
3
  graph: {
4
4
  CONFIG_GET: typeof import("@redis/graph/dist/commands/CONFIG_GET");
5
5
  configGet: typeof import("@redis/graph/dist/commands/CONFIG_GET");
@@ -580,3 +580,4 @@ export declare const redisConnection: (url: string, password: string) => Promise
580
580
  };
581
581
  } & import("redis").RedisModules, import("redis").RedisFunctions, import("redis").RedisScripts>>;
582
582
  export declare const sessionStore: (url: string, password: string) => Promise<RedisStore>;
583
+ export declare const cleanupRedis: () => Promise<void>;
@@ -12,19 +12,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.sessionStore = exports.redisConnection = exports.redisClient = void 0;
15
+ exports.cleanupRedis = exports.sessionStore = exports.redisConnection = exports.getRedisClient = void 0;
16
16
  const connect_redis_1 = __importDefault(require("connect-redis"));
17
17
  const redis_1 = require("redis");
18
18
  const data_base_connections_1 = require("../errors/data-base-connections");
19
- exports.redisClient = (0, redis_1.createClient)({
20
- url: process.env.REDIS_HOST,
21
- password: process.env.REDIS_PASS,
22
- });
19
+ let redisClient = null;
20
+ const getRedisClient = () => {
21
+ if (!redisClient) {
22
+ redisClient = (0, redis_1.createClient)({
23
+ url: process.env.REDIS_HOST,
24
+ password: process.env.REDIS_PASS,
25
+ });
26
+ // Set a higher limit for event listeners
27
+ redisClient.setMaxListeners(20);
28
+ }
29
+ return redisClient;
30
+ };
31
+ exports.getRedisClient = getRedisClient;
23
32
  const redisConnection = (url, password) => __awaiter(void 0, void 0, void 0, function* () {
24
33
  try {
25
- yield exports.redisClient.connect();
34
+ const client = (0, exports.getRedisClient)();
35
+ if (!client.isOpen) {
36
+ yield client.connect();
37
+ }
26
38
  console.log(`Redis connected in : ${url}`);
27
- return exports.redisClient;
39
+ return client;
28
40
  }
29
41
  catch (error) {
30
42
  console.error(`Cannot connect to Redis: ${url}`, error);
@@ -33,6 +45,14 @@ const redisConnection = (url, password) => __awaiter(void 0, void 0, void 0, fun
33
45
  });
34
46
  exports.redisConnection = redisConnection;
35
47
  const sessionStore = (url, password) => __awaiter(void 0, void 0, void 0, function* () {
36
- return new connect_redis_1.default({ client: exports.redisClient });
48
+ const client = (0, exports.getRedisClient)();
49
+ return new connect_redis_1.default({ client });
37
50
  });
38
51
  exports.sessionStore = sessionStore;
52
+ const cleanupRedis = () => __awaiter(void 0, void 0, void 0, function* () {
53
+ if (redisClient) {
54
+ yield redisClient.quit();
55
+ redisClient = null;
56
+ }
57
+ });
58
+ exports.cleanupRedis = cleanupRedis;
@@ -60,7 +60,11 @@ exports.CopyrightContracts = (0, mongoose_1.model)(model_names_1.MODELS.copyrigh
60
60
  paymentLink: { type: String, default: null },
61
61
  requestedDeadline: {
62
62
  deadline: { type: Date, default: null },
63
- status: { type: String, enum: RequestedDeadlineStatus, default: RequestedDeadlineStatus.pending },
63
+ status: {
64
+ type: String,
65
+ enum: RequestedDeadlineStatus,
66
+ default: RequestedDeadlineStatus.pending,
67
+ },
64
68
  user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user, default: null },
65
69
  },
66
70
  }, { collection: model_names_1.MODELS.copyrightContract, timestamps: true }));
@@ -69,7 +69,11 @@ exports.ProjectContract = (0, mongoose_1.model)(model_names_1.MODELS.projectCont
69
69
  ],
70
70
  requestedDeadline: {
71
71
  deadline: { type: Date, default: null },
72
- status: { type: String, enum: copyright_contract_model_1.RequestedDeadlineStatus, default: copyright_contract_model_1.RequestedDeadlineStatus.pending },
72
+ status: {
73
+ type: String,
74
+ enum: copyright_contract_model_1.RequestedDeadlineStatus,
75
+ default: copyright_contract_model_1.RequestedDeadlineStatus.pending,
76
+ },
73
77
  user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user, default: null },
74
78
  },
75
79
  }, { timestamps: true, collection: model_names_1.MODELS.projectContract }));
@@ -11,7 +11,12 @@ exports.TeamProject = (0, mongoose_1.model)(model_names_1.MODELS.teamProject, ne
11
11
  desc: { type: String, default: null },
12
12
  location: { lat: { type: Number, default: null }, lng: { type: Number, default: null } },
13
13
  address: { type: String, default: null },
14
- relatedContracts: [{ category: { type: mongoose_1.Types.ObjectId, ref: model_names_1.MODELS.category }, contracts: [{ contract: { type: mongoose_1.Types.ObjectId, ref: model_names_1.MODELS.projectContract } }] }],
14
+ relatedContracts: [
15
+ {
16
+ category: { type: mongoose_1.Types.ObjectId, ref: model_names_1.MODELS.category },
17
+ contracts: [{ contract: { type: mongoose_1.Types.ObjectId, ref: model_names_1.MODELS.projectContract } }],
18
+ },
19
+ ],
15
20
  isDeleted: { type: Boolean, default: false },
16
21
  cycle: { type: String, default: cycles_1.CYCLES.teamProject },
17
22
  }, {
@@ -0,0 +1,42 @@
1
+ /// <reference types="mongoose/types/types" />
2
+ /// <reference types="mongoose/types/document" />
3
+ /// <reference types="mongoose/types/aggregate" />
4
+ /// <reference types="mongoose/types/callback" />
5
+ /// <reference types="mongoose/types/collection" />
6
+ /// <reference types="mongoose/types/connection" />
7
+ /// <reference types="mongoose/types/cursor" />
8
+ /// <reference types="mongoose/types/error" />
9
+ /// <reference types="mongoose/types/expressions" />
10
+ /// <reference types="mongoose/types/helpers" />
11
+ /// <reference types="mongoose/types/middlewares" />
12
+ /// <reference types="mongoose/types/indexes" />
13
+ /// <reference types="mongoose/types/models" />
14
+ /// <reference types="mongoose/types/mongooseoptions" />
15
+ /// <reference types="mongoose/types/pipelinestage" />
16
+ /// <reference types="mongoose/types/populate" />
17
+ /// <reference types="mongoose/types/query" />
18
+ /// <reference types="mongoose/types/schemaoptions" />
19
+ /// <reference types="mongoose/types/schematypes" />
20
+ /// <reference types="mongoose/types/session" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import { Types } from 'mongoose';
26
+ export declare enum TransactionStatus {
27
+ PENDING = "pending",
28
+ SUCCESS = "success",
29
+ FAILED = "failed"
30
+ }
31
+ export interface ITransaction {
32
+ currency: string;
33
+ amount: number;
34
+ user: Types.ObjectId;
35
+ contract: Types.ObjectId;
36
+ status: string;
37
+ timeStamp: Date;
38
+ model: string;
39
+ }
40
+ export declare const Transaction: import("mongoose").Model<ITransaction, {}, {}, {}, import("mongoose").Document<unknown, {}, ITransaction> & ITransaction & {
41
+ _id: Types.ObjectId;
42
+ }, any>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Transaction = exports.TransactionStatus = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const model_names_1 = require("../types/model-names");
6
+ var TransactionStatus;
7
+ (function (TransactionStatus) {
8
+ TransactionStatus["PENDING"] = "pending";
9
+ TransactionStatus["SUCCESS"] = "success";
10
+ TransactionStatus["FAILED"] = "failed";
11
+ })(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
12
+ exports.Transaction = (0, mongoose_1.model)(model_names_1.MODELS.transaction, new mongoose_1.Schema({
13
+ currency: { type: String, default: 'EGP' },
14
+ amount: { type: Number, default: 0 },
15
+ user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
16
+ contract: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.contracts },
17
+ status: { type: String, default: TransactionStatus.PENDING },
18
+ timeStamp: { type: Date, default: Date.now },
19
+ model: { type: String, default: null },
20
+ }));
@@ -38,5 +38,6 @@ export declare enum MODELS {
38
38
  teamContract = "team_contracts",
39
39
  favourites = "favourites",
40
40
  contractCancel = "contract_cancel",
41
- withdrawMethod = "withdraw-methods"
41
+ withdrawMethod = "withdraw-methods",
42
+ transaction = "transactions"
42
43
  }
@@ -43,4 +43,5 @@ var MODELS;
43
43
  MODELS["favourites"] = "favourites";
44
44
  MODELS["contractCancel"] = "contract_cancel";
45
45
  MODELS["withdrawMethod"] = "withdraw-methods";
46
+ MODELS["transaction"] = "transactions";
46
47
  })(MODELS || (exports.MODELS = MODELS = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duvdu-v1/duvdu",
3
- "version": "1.1.262",
3
+ "version": "1.1.264",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [