From 852bd9b42e8dac71b0c9ffdef23128c91cf41c9a Mon Sep 17 00:00:00 2001 From: Shane Earley Date: Mon, 3 Jul 2023 15:54:30 -0400 Subject: [PATCH] Move postgres pool client to users service --- common/data/src/index.ts | 2 +- services/users/src/providers/db.ts | 2 +- {common/data => services/users}/src/providers/postgres.ts | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) rename {common/data => services/users}/src/providers/postgres.ts (96%) diff --git a/common/data/src/index.ts b/common/data/src/index.ts index 643362036..d86044025 100644 --- a/common/data/src/index.ts +++ b/common/data/src/index.ts @@ -9,7 +9,7 @@ import operatorStore from './mock/operator.store.json' import validatorStore from './mock/validator.store.json' import accountStore from './mock/account.store.json' import userStore from './mock/user.store.json' -import { Postgres } from './providers/postgres' +import { Postgres } from '../../../services/users/src/providers/postgres' import { JsonType, GlueType, PostgresType, Schema } from './providers/schema' import { JsonSchema } from './interfaces/JsonSchema' diff --git a/services/users/src/providers/db.ts b/services/users/src/providers/db.ts index 47e68eb8d..945c68d9f 100644 --- a/services/users/src/providers/db.ts +++ b/services/users/src/providers/db.ts @@ -1,4 +1,4 @@ -import { Postgres } from '@casimir/data' +import { Postgres } from './postgres' import { camelCase } from '@casimir/helpers' import { Account, RemoveAccountOptions, User, UserAddedSuccess } from '@casimir/types' import useEthers from './ethers' diff --git a/common/data/src/providers/postgres.ts b/services/users/src/providers/postgres.ts similarity index 96% rename from common/data/src/providers/postgres.ts rename to services/users/src/providers/postgres.ts index 7375d9287..d85f74f78 100644 --- a/common/data/src/providers/postgres.ts +++ b/services/users/src/providers/postgres.ts @@ -17,7 +17,6 @@ export class Postgres { */ constructor(config?: PoolConfig) { this.pool = new Pool(config) - process.on('SIGINT', () => this.close()) } /** @@ -35,8 +34,8 @@ export class Postgres { async query(text: string, params: any[] = []) { // Todo - use union of stricter @casimir/types for params const client = await this.pool.connect() const res = await client.query(text, params) - const { rows } = res client.release() + const { rows } = res return rows }