-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed so ui shows correct package name and other stuff + small bug
- Loading branch information
1 parent
d32a509
commit 2e37d08
Showing
2 changed files
with
51 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,50 @@ | ||
// import dotenv from 'dotenv' | ||
import pg from 'pg' | ||
const { Pool } = pg | ||
|
||
// dotenv.config({ path: '../../.env' }) | ||
|
||
// const { DB_PASSWORD } = process.env | ||
// if (!DB_PASSWORD) { | ||
// throw new Error("Missing DB_PASSWORD env variable.") | ||
// } | ||
|
||
const pool = new Pool({ | ||
user: "osvuser", | ||
host: "lsm_database", | ||
database: "osvdb", | ||
password: 'osvpassword', | ||
// password: DB_PASSWORD, | ||
port: 5432, | ||
max: 20, | ||
idleTimeoutMillis: 5000, | ||
connectionTimeoutMillis: 3000 | ||
}) | ||
|
||
export default async function run(query: string, params: string[]) { | ||
const client = await pool.connect() | ||
try { | ||
return await client.query(query, params) | ||
} catch (error) { | ||
client.release() | ||
throw error | ||
} finally { | ||
client.release() | ||
} | ||
} | ||
|
||
export async function runInTransaction<T>( | ||
callback: (client: pg.PoolClient) => Promise<T> | ||
): Promise<T> { | ||
const client = await pool.connect() | ||
try { | ||
await client.query("BEGIN") | ||
const result = await callback(client) | ||
await client.query("COMMIT") | ||
return result | ||
} catch (error) { | ||
await client.query("ROLLBACK") | ||
throw error | ||
} finally { | ||
client.release() | ||
} | ||
} | ||
// import dotenv from 'dotenv' | ||
import pg from 'pg' | ||
const { Pool } = pg | ||
|
||
// dotenv.config({ path: '../../.env' }) | ||
|
||
// const { DB_PASSWORD } = process.env | ||
// if (!DB_PASSWORD) { | ||
// throw new Error("Missing DB_PASSWORD env variable.") | ||
// } | ||
|
||
const pool = new Pool({ | ||
user: "osvuser", | ||
host: "lsm_database", | ||
database: "osvdb", | ||
password: 'osvpassword', | ||
// password: DB_PASSWORD, | ||
port: 5432, | ||
max: 20, | ||
idleTimeoutMillis: 5000, | ||
connectionTimeoutMillis: 3000 | ||
}) | ||
|
||
export default async function run(query: string, params: string[]) { | ||
const client = await pool.connect() | ||
try { | ||
return await client.query(query, params) | ||
} catch (error) { | ||
throw error | ||
} finally { | ||
client.release() | ||
} | ||
} | ||
|
||
export async function runInTransaction<T>( | ||
callback: (client: pg.PoolClient) => Promise<T> | ||
): Promise<T> { | ||
const client = await pool.connect() | ||
try { | ||
await client.query("BEGIN") | ||
const result = await callback(client) | ||
await client.query("COMMIT") | ||
return result | ||
} catch (error) { | ||
await client.query("ROLLBACK") | ||
throw error | ||
} finally { | ||
client.release() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters