close pool connections

deepsource-autofix-76c6eb20
Dan Gowans 2023-01-18 14:00:17 -05:00
parent 9d6346388f
commit 82c7f047cf
2 changed files with 10 additions and 0 deletions

View File

@ -1,6 +1,10 @@
import { Pool } from 'better-sqlite-pool';
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js';
import exitHook from 'exit-hook';
const pool = new Pool(databasePath);
export async function acquireConnection() {
return await pool.acquire();
}
exitHook(() => {
pool.close();
});

View File

@ -2,8 +2,14 @@ import { Pool, PoolConnection } from 'better-sqlite-pool'
import { lotOccupancyDB as databasePath } from '../../data/databasePaths.js'
import exitHook from 'exit-hook'
const pool = new Pool(databasePath)
export async function acquireConnection(): Promise<PoolConnection> {
return await pool.acquire()
}
exitHook(() => {
pool.close()
})