Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4325d5b

Browse filesBrowse files
committed
Chore: fix self executing scripts
1 parent 7cc384b commit 4325d5b
Copy full SHA for 4325d5b

File tree

Expand file treeCollapse file tree

4 files changed

+22
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+22
-10
lines changed
Open diff view settings
Collapse file

‎packages/core/src/lib/db.ts‎

Copy file name to clipboard
+20-8Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
import { Pool, QueryResultRow, QueryResult } from 'pg'
22
import config from 'config'
33

4-
const pool = new Pool({
5-
host: config.get('database.host'),
6-
user: config.get('database.username'),
7-
database: config.get('database.database'),
8-
password: config.get('database.password'),
9-
port: config.get('database.port'),
10-
})
4+
const poolCreator = () => {
5+
let pool: Pool | null = null;
6+
7+
return () => {
8+
if (!pool) {
9+
pool = new Pool({
10+
host: config.get('database.host'),
11+
user: config.get('database.username'),
12+
database: config.get('database.database'),
13+
password: config.get('database.password'),
14+
port: config.get('database.port'),
15+
})
16+
}
17+
18+
return pool
19+
}
20+
}
21+
22+
const getPool = poolCreator()
1123

1224
//eslint-disable-next-line
1325
export const query = <R extends QueryResultRow = any, I extends any[] = any[]>(text: string, params?: I): Promise<QueryResult<R>> => {
14-
return pool.query(text, params)
26+
return getPool().query(text, params)
1527
}
Collapse file

‎packages/core/src/lib/worker/execution.script.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/lib/worker/execution.script.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ class ExecutionScript {
2525

2626
}
2727

28-
new ExecutionScript()
28+
export default () => new ExecutionScript()
Collapse file

‎packages/core/src/lib/worker/worker.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/lib/worker/worker.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class Worker {
2020

2121
return `
2222
require("ts-node/register/transpile-only");
23-
require("${__dirname}/execution.script");
23+
require("${__dirname}/execution.script").default();
2424
`
2525
}
2626

Collapse file

‎packages/web/src/lib/.gitkeep‎

Copy file name to clipboardExpand all lines: packages/web/src/lib/.gitkeep
Whitespace-only changes.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.