@8ms/helpers 3.0.14 → 3.0.15
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.
|
@@ -6,38 +6,38 @@ var Drizzle = class extends require__class_BaseNamespace.BaseNamespace {
|
|
|
6
6
|
init = async (config) => {
|
|
7
7
|
if (!this.client) {
|
|
8
8
|
let logger = void 0;
|
|
9
|
-
if (
|
|
9
|
+
if (true === config?.isDebug) {
|
|
10
10
|
const { DefaultLogger } = await import("drizzle-orm/logger");
|
|
11
11
|
logger = new DefaultLogger();
|
|
12
12
|
}
|
|
13
13
|
let casing = void 0;
|
|
14
|
-
if ("snake" ===
|
|
15
|
-
else if ("camel" ===
|
|
16
|
-
if (
|
|
14
|
+
if ("snake" === config?.casing) casing = "snake_case";
|
|
15
|
+
else if ("camel" === config?.casing) casing = "camelCase";
|
|
16
|
+
if (true === config?.isPlanetScale) try {
|
|
17
17
|
const { drizzle } = await import("drizzle-orm/planetscale-serverless");
|
|
18
18
|
this.client = drizzle({
|
|
19
19
|
casing,
|
|
20
|
-
connection: { url:
|
|
21
|
-
relations:
|
|
22
|
-
schema:
|
|
20
|
+
connection: { url: config?.url },
|
|
21
|
+
relations: config?.relations,
|
|
22
|
+
schema: config?.schema,
|
|
23
23
|
logger
|
|
24
24
|
});
|
|
25
25
|
} catch (e) {
|
|
26
26
|
throw new Error(`PlanetScale driver not installed - ${require_util_getError.getError(e)}`);
|
|
27
27
|
}
|
|
28
|
-
else if (
|
|
28
|
+
else if (true === config?.isMysql) try {
|
|
29
29
|
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
30
30
|
const pool = (await import("mysql2/promise")).createPool({
|
|
31
|
-
uri:
|
|
32
|
-
connectionLimit:
|
|
33
|
-
idleTimeout:
|
|
34
|
-
connectTimeout:
|
|
31
|
+
uri: config.url,
|
|
32
|
+
connectionLimit: config.pool?.max ?? 10,
|
|
33
|
+
idleTimeout: config.pool?.idleTimeoutMs ?? 3e4,
|
|
34
|
+
connectTimeout: config.pool?.connectTimeoutMs ?? 5e3,
|
|
35
35
|
waitForConnections: true,
|
|
36
36
|
queueLimit: 0
|
|
37
37
|
});
|
|
38
38
|
this.client = drizzle(pool, {
|
|
39
|
-
schema:
|
|
40
|
-
relations:
|
|
39
|
+
schema: config.schema,
|
|
40
|
+
relations: config.relations,
|
|
41
41
|
casing,
|
|
42
42
|
logger,
|
|
43
43
|
mode: "default"
|
|
@@ -45,18 +45,18 @@ var Drizzle = class extends require__class_BaseNamespace.BaseNamespace {
|
|
|
45
45
|
} catch (e) {
|
|
46
46
|
throw new Error(`MySQL2 driver not installed - ${require_util_getError.getError(e)}`);
|
|
47
47
|
}
|
|
48
|
-
else if (
|
|
48
|
+
else if (true === config?.isPostgres) try {
|
|
49
49
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
50
50
|
const { Pool } = await import("pg");
|
|
51
51
|
const pool = new Pool({
|
|
52
|
-
connectionString:
|
|
53
|
-
max:
|
|
54
|
-
idleTimeoutMillis:
|
|
55
|
-
connectionTimeoutMillis:
|
|
52
|
+
connectionString: config.url,
|
|
53
|
+
max: config.pool?.max ?? 10,
|
|
54
|
+
idleTimeoutMillis: config.pool?.idleTimeoutMs ?? 3e4,
|
|
55
|
+
connectionTimeoutMillis: config.pool?.connectTimeoutMs ?? 5e3
|
|
56
56
|
});
|
|
57
57
|
this.client = drizzle(pool, {
|
|
58
|
-
schema:
|
|
59
|
-
relations:
|
|
58
|
+
schema: config.schema,
|
|
59
|
+
relations: config.relations,
|
|
60
60
|
casing,
|
|
61
61
|
logger
|
|
62
62
|
});
|
|
@@ -64,6 +64,7 @@ var Drizzle = class extends require__class_BaseNamespace.BaseNamespace {
|
|
|
64
64
|
throw new Error(`Postgres (pg) driver not installed - ${require_util_getError.getError(e)}`);
|
|
65
65
|
}
|
|
66
66
|
else throw new Error(`No database type configured`);
|
|
67
|
+
this.config = config;
|
|
67
68
|
}
|
|
68
69
|
return this;
|
|
69
70
|
};
|
|
@@ -5,38 +5,38 @@ var Drizzle = class extends BaseNamespace {
|
|
|
5
5
|
init = async (config) => {
|
|
6
6
|
if (!this.client) {
|
|
7
7
|
let logger = void 0;
|
|
8
|
-
if (
|
|
8
|
+
if (true === config?.isDebug) {
|
|
9
9
|
const { DefaultLogger } = await import("drizzle-orm/logger");
|
|
10
10
|
logger = new DefaultLogger();
|
|
11
11
|
}
|
|
12
12
|
let casing = void 0;
|
|
13
|
-
if ("snake" ===
|
|
14
|
-
else if ("camel" ===
|
|
15
|
-
if (
|
|
13
|
+
if ("snake" === config?.casing) casing = "snake_case";
|
|
14
|
+
else if ("camel" === config?.casing) casing = "camelCase";
|
|
15
|
+
if (true === config?.isPlanetScale) try {
|
|
16
16
|
const { drizzle } = await import("drizzle-orm/planetscale-serverless");
|
|
17
17
|
this.client = drizzle({
|
|
18
18
|
casing,
|
|
19
|
-
connection: { url:
|
|
20
|
-
relations:
|
|
21
|
-
schema:
|
|
19
|
+
connection: { url: config?.url },
|
|
20
|
+
relations: config?.relations,
|
|
21
|
+
schema: config?.schema,
|
|
22
22
|
logger
|
|
23
23
|
});
|
|
24
24
|
} catch (e) {
|
|
25
25
|
throw new Error(`PlanetScale driver not installed - ${getError(e)}`);
|
|
26
26
|
}
|
|
27
|
-
else if (
|
|
27
|
+
else if (true === config?.isMysql) try {
|
|
28
28
|
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
29
29
|
const pool = (await import("mysql2/promise")).createPool({
|
|
30
|
-
uri:
|
|
31
|
-
connectionLimit:
|
|
32
|
-
idleTimeout:
|
|
33
|
-
connectTimeout:
|
|
30
|
+
uri: config.url,
|
|
31
|
+
connectionLimit: config.pool?.max ?? 10,
|
|
32
|
+
idleTimeout: config.pool?.idleTimeoutMs ?? 3e4,
|
|
33
|
+
connectTimeout: config.pool?.connectTimeoutMs ?? 5e3,
|
|
34
34
|
waitForConnections: true,
|
|
35
35
|
queueLimit: 0
|
|
36
36
|
});
|
|
37
37
|
this.client = drizzle(pool, {
|
|
38
|
-
schema:
|
|
39
|
-
relations:
|
|
38
|
+
schema: config.schema,
|
|
39
|
+
relations: config.relations,
|
|
40
40
|
casing,
|
|
41
41
|
logger,
|
|
42
42
|
mode: "default"
|
|
@@ -44,18 +44,18 @@ var Drizzle = class extends BaseNamespace {
|
|
|
44
44
|
} catch (e) {
|
|
45
45
|
throw new Error(`MySQL2 driver not installed - ${getError(e)}`);
|
|
46
46
|
}
|
|
47
|
-
else if (
|
|
47
|
+
else if (true === config?.isPostgres) try {
|
|
48
48
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
49
49
|
const { Pool } = await import("pg");
|
|
50
50
|
const pool = new Pool({
|
|
51
|
-
connectionString:
|
|
52
|
-
max:
|
|
53
|
-
idleTimeoutMillis:
|
|
54
|
-
connectionTimeoutMillis:
|
|
51
|
+
connectionString: config.url,
|
|
52
|
+
max: config.pool?.max ?? 10,
|
|
53
|
+
idleTimeoutMillis: config.pool?.idleTimeoutMs ?? 3e4,
|
|
54
|
+
connectionTimeoutMillis: config.pool?.connectTimeoutMs ?? 5e3
|
|
55
55
|
});
|
|
56
56
|
this.client = drizzle(pool, {
|
|
57
|
-
schema:
|
|
58
|
-
relations:
|
|
57
|
+
schema: config.schema,
|
|
58
|
+
relations: config.relations,
|
|
59
59
|
casing,
|
|
60
60
|
logger
|
|
61
61
|
});
|
|
@@ -63,6 +63,7 @@ var Drizzle = class extends BaseNamespace {
|
|
|
63
63
|
throw new Error(`Postgres (pg) driver not installed - ${getError(e)}`);
|
|
64
64
|
}
|
|
65
65
|
else throw new Error(`No database type configured`);
|
|
66
|
+
this.config = config;
|
|
66
67
|
}
|
|
67
68
|
return this;
|
|
68
69
|
};
|