@seidor-cloud-produtos/orbit-backend-lib 0.0.95 → 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.
- package/dist/clean-arch/application/cache/cache.d.ts +1 -0
- package/dist/clean-arch/application/cache/cache.js +7 -8
- package/dist/clean-arch/application/cache/client.d.ts +1 -0
- package/dist/clean-arch/application/logger/index.d.ts +11 -0
- package/dist/clean-arch/application/logger/index.js +25 -0
- package/dist/clean-arch/infra/cache/clients/node-cache.d.ts +1 -0
- package/dist/clean-arch/infra/cache/clients/node-cache.js +3 -0
- package/dist/clean-arch/infra/cache/clients/redis.d.ts +1 -0
- package/dist/clean-arch/infra/cache/clients/redis.js +3 -0
- package/dist/clean-arch/infra/environment/env.d.ts +2 -0
- package/dist/clean-arch/infra/environment/env.js +2 -0
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ export declare abstract class Cache {
|
|
|
17
17
|
del(keyCache: string, options?: MethodOptions): Promise<void>;
|
|
18
18
|
getKeys(pattern?: string, options?: MethodOptions): Promise<string[] | null>;
|
|
19
19
|
delBatch(patterns: string[], options?: MethodOptions): Promise<void>;
|
|
20
|
+
flush(): Promise<void>;
|
|
20
21
|
isRunning(options?: MethodOptions): Promise<any>;
|
|
21
22
|
close(options?: MethodOptions): Promise<void>;
|
|
22
23
|
}
|
|
@@ -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
|
-
|
|
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 {
|
|
@@ -85,6 +84,9 @@ class Cache {
|
|
|
85
84
|
return;
|
|
86
85
|
}
|
|
87
86
|
}
|
|
87
|
+
async flush() {
|
|
88
|
+
return await this.client.flush();
|
|
89
|
+
}
|
|
88
90
|
async isRunning(options) {
|
|
89
91
|
try {
|
|
90
92
|
return await this.client.isRunning();
|
|
@@ -97,10 +99,7 @@ class Cache {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
async close(options) {
|
|
100
|
-
|
|
101
|
-
console.log('\n');
|
|
102
|
-
console.log('💾 Cache closed');
|
|
103
|
-
}
|
|
102
|
+
logger_1.default.debug()?.info('💾 Cache closed');
|
|
104
103
|
try {
|
|
105
104
|
return await this.client.close();
|
|
106
105
|
}
|
|
@@ -6,5 +6,6 @@ export declare abstract class CacheClient {
|
|
|
6
6
|
abstract del(keyCache: string): Promise<void>;
|
|
7
7
|
abstract delBatch(keyCache: string[]): Promise<void>;
|
|
8
8
|
abstract getKeys(pattern?: string): Promise<string[] | null>;
|
|
9
|
+
abstract flush(): Promise<void>;
|
|
9
10
|
isRunning(): Promise<any>;
|
|
10
11
|
}
|
|
@@ -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;
|
|
@@ -9,6 +9,7 @@ export declare class NodeCache extends CacheClient {
|
|
|
9
9
|
delBatch(keyCache: string[]): Promise<void>;
|
|
10
10
|
getKeys(pattern?: string | undefined): Promise<string[]>;
|
|
11
11
|
close(): Promise<void>;
|
|
12
|
+
flush(): Promise<void>;
|
|
12
13
|
}
|
|
13
14
|
declare const _default: NodeCache;
|
|
14
15
|
export default _default;
|
|
@@ -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);
|