@seidor-cloud-produtos/orbit-backend-lib 0.0.96 → 0.0.97

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,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cache = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const env_1 = require("../../infra/environment/env");
6
+ const logger_1 = tslib_1.__importDefault(require("../logger"));
5
7
  class Cache {
6
8
  constructor(options) {
7
9
  this.DEFAULT_EXPIRATION_SECONDS = env_1.env.DEFAULT_CACHE_EXPIRATION;
@@ -24,10 +26,7 @@ class Cache {
24
26
  }
25
27
  return;
26
28
  }
27
- if (process.env.NODE_ENV !== 'test') {
28
- console.log('\n');
29
- console.log('💾 Cache Connected');
30
- }
29
+ logger_1.default.debug()?.info('💾 Cache Connected');
31
30
  }
32
31
  async get(keyCache, options) {
33
32
  try {
@@ -100,10 +99,7 @@ class Cache {
100
99
  }
101
100
  }
102
101
  async close(options) {
103
- if (process.env.NODE_ENV !== 'test') {
104
- console.log('\n');
105
- console.log('💾 Cache closed');
106
- }
102
+ logger_1.default.debug()?.info('💾 Cache closed');
107
103
  try {
108
104
  return await this.client.close();
109
105
  }
@@ -0,0 +1,11 @@
1
+ export declare enum LOG_LEVEL {
2
+ debug = "DEBUG",
3
+ info = "INFO"
4
+ }
5
+ export declare class Logger {
6
+ debug(): this | undefined;
7
+ info(info: any): void;
8
+ error(error: any): void;
9
+ }
10
+ declare const logger: Logger;
11
+ export default logger;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = exports.LOG_LEVEL = void 0;
4
+ const env_1 = require("../../infra/environment/env");
5
+ var LOG_LEVEL;
6
+ (function (LOG_LEVEL) {
7
+ LOG_LEVEL["debug"] = "DEBUG";
8
+ LOG_LEVEL["info"] = "INFO";
9
+ })(LOG_LEVEL || (exports.LOG_LEVEL = LOG_LEVEL = {}));
10
+ class Logger {
11
+ debug() {
12
+ if (env_1.env.LOG_LEVEL === LOG_LEVEL.debug)
13
+ return this;
14
+ return undefined;
15
+ }
16
+ info(info) {
17
+ console.info(info);
18
+ }
19
+ error(error) {
20
+ console.error(error);
21
+ }
22
+ }
23
+ exports.Logger = Logger;
24
+ const logger = new Logger();
25
+ exports.default = logger;
@@ -1,7 +1,9 @@
1
1
  import 'dotenv/config';
2
2
  import { ENVIRONMENT_TYPES } from './environment';
3
+ import { LOG_LEVEL } from '../../application/logger';
3
4
  export declare const env: {
4
5
  NODE_ENV: "test" | "production";
5
6
  CURRENT_ENVIRONMENT: ENVIRONMENT_TYPES;
7
+ LOG_LEVEL: LOG_LEVEL;
6
8
  DEFAULT_CACHE_EXPIRATION: number;
7
9
  };
@@ -4,6 +4,7 @@ exports.env = void 0;
4
4
  require("dotenv/config");
5
5
  const zod_1 = require("zod");
6
6
  const environment_1 = require("./environment");
7
+ const logger_1 = require("../../application/logger");
7
8
  const envSchema = zod_1.z.object({
8
9
  NODE_ENV: zod_1.z.enum(['test', 'production']).default('production'),
9
10
  CURRENT_ENVIRONMENT: zod_1.z
@@ -15,6 +16,7 @@ const envSchema = zod_1.z.object({
15
16
  environment_1.ENVIRONMENT_TYPES.PRODUCTION,
16
17
  ])
17
18
  .default(environment_1.ENVIRONMENT_TYPES.LOCAL),
19
+ LOG_LEVEL: zod_1.z.enum([logger_1.LOG_LEVEL.debug, logger_1.LOG_LEVEL.info]).default(logger_1.LOG_LEVEL.info),
18
20
  DEFAULT_CACHE_EXPIRATION: zod_1.z.number().default(360),
19
21
  });
20
22
  const _env = envSchema.safeParse(process.env);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seidor-cloud-produtos/orbit-backend-lib",
3
- "version": "0.0.96",
3
+ "version": "0.0.97",
4
4
  "description": "Internal lib for backend components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",