@tstdl/base 0.92.71 → 0.92.73

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.
@@ -2,7 +2,7 @@ import { NodePgDatabase } from 'drizzle-orm/node-postgres';
2
2
  import { migrate } from 'drizzle-orm/node-postgres/migrator';
3
3
  import type { PoolConfig } from 'pg';
4
4
  import type { Resolvable, resolveArgumentType } from '../../injector/interfaces.js';
5
- export type DatabaseArgument = string | PoolConfig;
5
+ export type DatabaseArgument = PoolConfig;
6
6
  export declare class Database extends NodePgDatabase<any> implements Resolvable<DatabaseArgument> {
7
7
  readonly [resolveArgumentType]?: DatabaseArgument;
8
8
  }
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { drizzle, NodePgDatabase } from 'drizzle-orm/node-postgres';
8
8
  import { migrate } from 'drizzle-orm/node-postgres/migrator';
9
+ import pg from 'pg';
9
10
  import { inject, Injector, ReplaceClass } from '../../injector/index.js';
10
11
  import { isUndefined } from '../../utils/type-guards.js';
11
12
  import { DatabaseConfig } from './module.js';
@@ -16,12 +17,14 @@ Database = __decorate([
16
17
  ], Database);
17
18
  export { Database };
18
19
  Injector.registerSingleton(Database, {
19
- useFactory: (argument) => {
20
+ useFactory: (argument, context) => {
20
21
  const connection = argument ?? inject(DatabaseConfig, undefined, { optional: true })?.connection;
21
22
  if (isUndefined(connection)) {
22
23
  throw new Error('Missing postgres connection. Provide it either via injection argument or provider.');
23
24
  }
24
- return drizzle({ connection });
25
+ const pool = new pg.Pool(connection);
26
+ context.addDisposeHandler(async () => pool.end());
27
+ return drizzle(pool);
25
28
  }
26
29
  });
27
30
  export { migrate };
@@ -1,10 +1,10 @@
1
1
  import type { PoolConfig } from 'pg';
2
2
  import { EntityRepositoryConfig } from './repository.js';
3
3
  export declare class DatabaseConfig {
4
- connection?: string | PoolConfig;
4
+ connection?: PoolConfig;
5
5
  }
6
6
  export type OrmModuleOptions = {
7
- connection?: string | PoolConfig;
7
+ connection?: PoolConfig;
8
8
  repositoryConfig?: EntityRepositoryConfig;
9
9
  };
10
10
  export declare function configureOrm(options: OrmModuleOptions & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.71",
3
+ "version": "0.92.73",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"