test-entity-library-asm 1.2.4 → 1.2.6
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/README.md +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -11
- package/ormconfig.json +12 -0
- package/package.json +2 -1
- package/src/index.ts +17 -20
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm';
|
|
2
|
-
import {
|
|
3
|
-
export declare function createDataBaseSource(
|
|
2
|
+
import { IShowEntity } from './interfaces';
|
|
3
|
+
export declare function createDataBaseSource(): DataSource;
|
|
4
4
|
export declare function showEntity({ entityName, connection }: IShowEntity): any;
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.showEntity = exports.createDataBaseSource = void 0;
|
|
4
|
+
var dotenv_1 = require("dotenv");
|
|
5
|
+
var path_1 = require("path");
|
|
4
6
|
var typeorm_1 = require("typeorm");
|
|
5
7
|
// DOCUMENTATION: Función para crear la conexión de la base de datos
|
|
6
8
|
// AUTHOR: jgomezp97@gmail.com
|
|
7
|
-
function createDataBaseSource(
|
|
8
|
-
var
|
|
9
|
+
function createDataBaseSource() {
|
|
10
|
+
var _a;
|
|
11
|
+
(0, dotenv_1.config)({ path: (0, path_1.resolve)(process.cwd(), '.env') });
|
|
9
12
|
return new typeorm_1.DataSource({
|
|
10
|
-
type:
|
|
11
|
-
host:
|
|
12
|
-
port:
|
|
13
|
-
username:
|
|
14
|
-
password:
|
|
15
|
-
database:
|
|
16
|
-
synchronize:
|
|
17
|
-
// logging: true,
|
|
13
|
+
type: process.env.DB_TYPE,
|
|
14
|
+
host: process.env.DB_HOST,
|
|
15
|
+
port: parseInt((_a = process.env.DB_PORT) !== null && _a !== void 0 ? _a : ''),
|
|
16
|
+
username: process.env.DB_USERNAME,
|
|
17
|
+
password: process.env.DB_PASSWORD,
|
|
18
|
+
database: process.env.DB_DATABASE,
|
|
19
|
+
synchronize: process.env.DB_SYNCHRONIZE === 'true',
|
|
18
20
|
entities: [
|
|
19
21
|
__dirname +
|
|
20
|
-
"/entities".concat(
|
|
22
|
+
"/entities".concat(process.env.DB_ENTITIES_ROUTE
|
|
23
|
+
? "/".concat(process.env.DB_ENTITIES_ROUTE)
|
|
24
|
+
: '', "/*{.js,.ts}"),
|
|
21
25
|
],
|
|
22
26
|
subscribers: [],
|
|
23
27
|
migrations: [],
|
package/ormconfig.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-entity-library-asm",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Entidades de ejemplo para una base de datos",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"dotenv": "^16.4.5",
|
|
14
15
|
"typeorm": "^0.3.20"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
|
+
import { config } from 'dotenv'
|
|
2
|
+
import { resolve } from 'path'
|
|
1
3
|
import { DataSource } from 'typeorm'
|
|
2
|
-
import {
|
|
4
|
+
import { IShowEntity, IType } from './interfaces'
|
|
3
5
|
|
|
4
6
|
// DOCUMENTATION: Función para crear la conexión de la base de datos
|
|
5
7
|
// AUTHOR: jgomezp97@gmail.com
|
|
6
|
-
export function createDataBaseSource({
|
|
7
|
-
|
|
8
|
-
host,
|
|
9
|
-
port,
|
|
10
|
-
username,
|
|
11
|
-
password,
|
|
12
|
-
database,
|
|
13
|
-
synchronize,
|
|
14
|
-
entitiesRoute,
|
|
15
|
-
}: IDataBaseSource): DataSource {
|
|
8
|
+
export function createDataBaseSource(): DataSource {
|
|
9
|
+
config({ path: resolve(process.cwd(), '.env') })
|
|
16
10
|
return new DataSource({
|
|
17
|
-
type:
|
|
18
|
-
host:
|
|
19
|
-
port:
|
|
20
|
-
username:
|
|
21
|
-
password:
|
|
22
|
-
database:
|
|
23
|
-
synchronize:
|
|
24
|
-
// logging: true,
|
|
11
|
+
type: process.env.DB_TYPE as unknown as IType,
|
|
12
|
+
host: process.env.DB_HOST,
|
|
13
|
+
port: parseInt(process.env.DB_PORT ?? ''),
|
|
14
|
+
username: process.env.DB_USERNAME,
|
|
15
|
+
password: process.env.DB_PASSWORD!,
|
|
16
|
+
database: process.env.DB_DATABASE,
|
|
17
|
+
synchronize: process.env.DB_SYNCHRONIZE === 'true',
|
|
25
18
|
entities: [
|
|
26
19
|
__dirname +
|
|
27
|
-
`/entities${
|
|
20
|
+
`/entities${
|
|
21
|
+
process.env.DB_ENTITIES_ROUTE
|
|
22
|
+
? `/${process.env.DB_ENTITIES_ROUTE}`
|
|
23
|
+
: ''
|
|
24
|
+
}/*{.js,.ts}`,
|
|
28
25
|
],
|
|
29
26
|
subscribers: [],
|
|
30
27
|
migrations: [],
|