test-entity-library-asm 3.9.11 → 3.9.13
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/index.js
CHANGED
|
@@ -31,6 +31,7 @@ function createDataBaseSource() {
|
|
|
31
31
|
(0, dotenv_1.config)({ path: (0, path_1.resolve)(process.cwd(), ".env") });
|
|
32
32
|
connection = new typeorm_1.DataSource({
|
|
33
33
|
type: process.env.DB_TYPE,
|
|
34
|
+
dateStrings: true,
|
|
34
35
|
host: process.env.DB_HOST,
|
|
35
36
|
port: parseInt(process.env.DB_PORT ?? ""),
|
|
36
37
|
username: process.env.DB_USERNAME,
|
|
@@ -100,6 +101,8 @@ function timezoneMiddleware(req, res, next) {
|
|
|
100
101
|
exports.timezoneMiddleware = timezoneMiddleware;
|
|
101
102
|
function getTimeZone() {
|
|
102
103
|
const store = asyncLocalStorage.getStore();
|
|
104
|
+
console.log(store, "store");
|
|
105
|
+
console.log(store?.get("timezone"), "y");
|
|
103
106
|
return store?.get("timezone") ?? "UTC";
|
|
104
107
|
}
|
|
105
108
|
exports.getTimeZone = getTimeZone;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.DateTransformer = void 0;
|
|
4
|
-
const
|
|
7
|
+
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
5
8
|
const __1 = require("..");
|
|
6
9
|
class DateTransformer {
|
|
7
10
|
to(value) {
|
|
8
|
-
const result =
|
|
11
|
+
const result = (0, moment_timezone_1.default)(value).format("YYYY-MM-DD HH:mm:ss");
|
|
9
12
|
return result;
|
|
10
13
|
}
|
|
11
14
|
from(value) {
|
|
12
15
|
if (value === null)
|
|
13
16
|
return null;
|
|
14
|
-
const result =
|
|
17
|
+
const result = moment_timezone_1.default.utc(value).tz((0, __1.getTimeZone)()).toDate();
|
|
15
18
|
return result;
|
|
16
19
|
}
|
|
17
20
|
}
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.JsonEncryptionTransformer = void 0;
|
|
4
|
-
const crypto = require("crypto");
|
|
27
|
+
const crypto = __importStar(require("crypto"));
|
|
5
28
|
const ENCRYPTION_KEY = process.env.SECRET_ENCRYPTION_KEY || "clave-32-bytes-segura";
|
|
6
29
|
const ALGORITHM = "aes-256-cbc";
|
|
7
30
|
// KeyObject de 32 bytes
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export function createDataBaseSource(): DataSource {
|
|
|
19
19
|
config({ path: resolve(process.cwd(), ".env") });
|
|
20
20
|
connection = new DataSource({
|
|
21
21
|
type: process.env.DB_TYPE as unknown as IType,
|
|
22
|
+
dateStrings: true,
|
|
22
23
|
host: process.env.DB_HOST,
|
|
23
24
|
port: parseInt(process.env.DB_PORT ?? ""),
|
|
24
25
|
username: process.env.DB_USERNAME,
|
|
@@ -50,7 +51,7 @@ export function createDataBaseSource(): DataSource {
|
|
|
50
51
|
// DOCUMENTATION: Función para retornar la entidad de una base de datos en específico por medio de un DataSource
|
|
51
52
|
// AUTHOR: jgomezp97@gmail.com
|
|
52
53
|
export async function showEntityNameEntity<T extends ObjectLiteral>(
|
|
53
|
-
entity: EntityTarget<T
|
|
54
|
+
entity: EntityTarget<T>,
|
|
54
55
|
): Promise<Repository<T>> {
|
|
55
56
|
if (!connection || !connection.isInitialized) {
|
|
56
57
|
connection = createDataBaseSource();
|
|
@@ -85,7 +86,7 @@ export async function callStoredProcedure(storedProcedure: any, elements: any) {
|
|
|
85
86
|
export function timezoneMiddleware(
|
|
86
87
|
req: Request,
|
|
87
88
|
res: Response,
|
|
88
|
-
next: NextFunction
|
|
89
|
+
next: NextFunction,
|
|
89
90
|
) {
|
|
90
91
|
let userTimeZone = req.headers["user-timezone"];
|
|
91
92
|
|
|
@@ -102,6 +103,9 @@ export function timezoneMiddleware(
|
|
|
102
103
|
|
|
103
104
|
export function getTimeZone(): string {
|
|
104
105
|
const store = asyncLocalStorage.getStore();
|
|
106
|
+
console.log(store, "store");
|
|
107
|
+
console.log(store?.get("timezone"), "y");
|
|
108
|
+
|
|
105
109
|
return store?.get("timezone") ?? "UTC";
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -112,7 +116,7 @@ export function getTimezoneOffset(timezone: string) {
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
export const getRepositoryByEntity = async <T extends ObjectLiteral>(
|
|
115
|
-
entity: EntityTarget<T
|
|
119
|
+
entity: EntityTarget<T>,
|
|
116
120
|
): Promise<CustomRepository<T>> => {
|
|
117
121
|
if (!connection) {
|
|
118
122
|
connection = createDataBaseSource();
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2020",
|
|
4
|
-
"module": "
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
5
6
|
"lib": ["es2020"],
|
|
6
7
|
"types": ["node"],
|
|
7
|
-
"
|
|
8
|
+
"rootDir": "./src",
|
|
8
9
|
"outDir": "./dist",
|
|
9
10
|
"declaration": true,
|
|
10
11
|
"strict": true,
|
|
11
12
|
"emitDecoratorMetadata": true,
|
|
12
13
|
"experimentalDecorators": true,
|
|
13
14
|
"strictPropertyInitialization": false,
|
|
14
|
-
"skipLibCheck": true
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"allowSyntheticDefaultImports": true
|
|
15
18
|
},
|
|
16
19
|
"include": ["src"]
|
|
17
20
|
}
|