@triproject/nestjs-core 1.0.46 → 1.0.48

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.
@@ -1,5 +1,6 @@
1
+ import { type Request } from 'express';
1
2
  export declare class AppController {
2
- private req;
3
+ protected req: Request;
3
4
  private appCache;
4
5
  private _cacheKey;
5
6
  cache<T>(callback: () => Promise<T>, ttl?: number): Promise<T>;
@@ -13,7 +13,7 @@ export declare class AppCache {
13
13
  set<T>(key: CacheKey, value: T, ttl?: number): Promise<void>;
14
14
  get<T>(key: CacheKey): Promise<T | undefined>;
15
15
  del(key: CacheKey): Promise<void>;
16
- delAll(key: string): Promise<void>;
16
+ delAll(key: CacheKey): Promise<void>;
17
17
  cache<T>(key: CacheKey, fn: () => Promise<any>, ttl?: number): Promise<T>;
18
18
  cacheWithTimeStamp<T extends object | string | number>(key: CacheKey, value: T, ttl?: number): Promise<CacheWithTimestamp<T>>;
19
19
  cacheWithTimeStamp<T extends object | string | number>(key: CacheKey, value: () => Promise<T>, ttl?: number): Promise<CacheWithTimestamp<T>>;
@@ -18,11 +18,11 @@ let AppCache = class AppCache {
18
18
  constructor(redis){
19
19
  this.connection = redis.getConnection(), this.readConnection = redis.getReadConnection();
20
20
  }
21
- _parseKey(key) {
21
+ _parseKey(key, withPrefix = !0) {
22
22
  if (!key) throw new _common.UnprocessableEntityException('Cache key cannot be null or undefined');
23
- let keys = [
23
+ let keys = withPrefix ? [
24
24
  this.PREFIX
25
- ];
25
+ ] : [];
26
26
  return Array.isArray(key) ? keys.push(...key) : keys.push(key?.toString()), keys.flat().flat().filter((d)=>d).map((d)=>d?.toString()?.toUpperCase()).join('::').replaceAll(/[^a-zA-Z0-9\-:*]/g, '-');
27
27
  }
28
28
  async set(key, value, ttl = 60) {
@@ -44,7 +44,7 @@ let AppCache = class AppCache {
44
44
  await this.connection.del(this._parseKey(key));
45
45
  }
46
46
  async delAll(key) {
47
- for (let k of (await this.connection.keys(this._parseKey('*' + key + '*'))))await this.connection.del(k);
47
+ for (let k of (await this.connection.keys(this._parseKey('*' + this._parseKey(key, !1) + '*'))))await this.connection.del(k);
48
48
  }
49
49
  async cache(key, fn, ttl = 60) {
50
50
  let data = await this.get(key);
@@ -207,7 +207,7 @@ _ts_decorate([
207
207
  type: String
208
208
  }),
209
209
  (0, _classvalidator.IsOptional)(),
210
- (0, _classvalidator.IsString)(),
210
+ (0, _classvalidator.IsEnum)([]),
211
211
  _ts_metadata("design:type", "u" < typeof KeyOfModel ? Object : KeyOfModel)
212
212
  ], BasePaginateRequest.prototype, "orderBy", void 0), _ts_decorate([
213
213
  (0, _swagger.ApiProperty)({
@@ -64,8 +64,8 @@ let RequestLog = class RequestLog {
64
64
  }
65
65
  end(req, res) {
66
66
  let duration = (0, _helpers.dateUtil)().diff('milliseconds', req.requestStartAt), reqData = (0, _helpers.removeEmptyValues)({
67
- body: Object.keys(req?.body).length ? req?.body : void 0,
68
- query: Object.keys(req?.query).length ? req?.query : void 0
67
+ body: Object.keys(req?.body ?? {}).length ? req?.body : void 0,
68
+ query: Object.keys(req?.query ?? {}).length ? req?.query : void 0
69
69
  }), userData = req?.user, user = userData ? (0, _helpers.removeEmptyValues)({
70
70
  id: userData?.id,
71
71
  name: userData?.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triproject/nestjs-core",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "author": "",
5
5
  "license": "ISC",
6
6
  "description": "A collection of NestJS modules and utilities to speed up development.",