@koalarx/nest 3.1.14 → 3.1.16

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.
@@ -1,2 +0,0 @@
1
- import 'dotenv/config';
2
- export declare function dropE2EDatabase(schemaId: string): Promise<void>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dropE2EDatabase = dropE2EDatabase;
4
- require("dotenv/config");
5
- const pg_1 = require("pg");
6
- async function dropE2EDatabase(schemaId) {
7
- await new Promise((resolve) => setTimeout(resolve, 1000));
8
- const baseUrl = new URL(process.env.DATABASE_URL || '');
9
- baseUrl.pathname = '/postgres';
10
- const pool = new pg_1.Pool({
11
- connectionString: baseUrl.toString(),
12
- idleTimeoutMillis: 100,
13
- });
14
- try {
15
- await pool.query(`
16
- SELECT pg_terminate_backend(pg_stat_activity.pid)
17
- FROM pg_stat_activity
18
- WHERE pg_stat_activity.datname = '${schemaId}'
19
- AND pid <> pg_backend_pid()
20
- `);
21
- await new Promise((resolve) => setTimeout(resolve, 500));
22
- await pool.query(`DROP DATABASE IF EXISTS "${schemaId}"`);
23
- }
24
- catch {
25
- }
26
- finally {
27
- try {
28
- await pool.end();
29
- }
30
- catch {
31
- }
32
- }
33
- }