@acuris/eventstore-postgresql
Advanced tools
Comparing version 1.1.2 to 1.1.4
@@ -8,2 +8,3 @@ import * as Pg from "pg"; | ||
export declare function pgConfigForAWSAsync(region: string, hostname: string, port: number, database: string, username: string): Promise<Pg.ClientConfig>; | ||
export declare function pgAsyncConfigForAWS(region: string, hostname: string, port: number, database: string, username: string): Pg.ClientConfig; | ||
export declare function pgConfigForRDS(region: string, clusterIdentifier: string, username: string, readonly?: boolean): Promise<Pg.ClientConfig>; | ||
@@ -10,0 +11,0 @@ export declare class PgEventSource implements EventSource { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PgEventSource = exports.pgConfigForRDS = exports.pgConfigForAWSAsync = exports.pgConfigForAWS = void 0; | ||
exports.PgEventSource = exports.pgConfigForRDS = exports.pgAsyncConfigForAWS = exports.pgConfigForAWSAsync = exports.pgConfigForAWS = void 0; | ||
const PgSchemaManager_1 = require("./PgSchemaManager"); | ||
@@ -31,2 +31,20 @@ const eventstore_api_1 = require("@acuris/eventstore-api"); | ||
exports.pgConfigForAWSAsync = pgConfigForAWSAsync; | ||
function pgAsyncConfigForAWS(region, hostname, port, database, username) { | ||
const AWS = require("aws-sdk"); | ||
const signer = new AWS.RDS.Signer({ hostname, username, port, region }); | ||
return { | ||
host: hostname, user: username, port, database, ssl: { rejectUnauthorized: false }, | ||
password() { | ||
return new Promise((resolve, reject) => { | ||
signer.getAuthToken({}, (err, token) => { | ||
if (err) | ||
reject(err); | ||
else | ||
resolve(token); | ||
}); | ||
}); | ||
} | ||
}; | ||
} | ||
exports.pgAsyncConfigForAWS = pgAsyncConfigForAWS; | ||
async function pgConfigForRDS(region, clusterIdentifier, username, readonly = false) { | ||
@@ -39,3 +57,3 @@ const AWS = require("aws-sdk"); | ||
throw new Error(`Cluster "${clusterIdentifier}" not found`); | ||
return pgConfigForAWSAsync(region, readonly ? clusterInfo.ReaderEndpoint : clusterInfo.Endpoint, clusterInfo.Port, clusterInfo.DatabaseName, username); | ||
return pgAsyncConfigForAWS(region, readonly ? clusterInfo.ReaderEndpoint : clusterInfo.Endpoint, clusterInfo.Port, clusterInfo.DatabaseName, username); | ||
} | ||
@@ -42,0 +60,0 @@ exports.pgConfigForRDS = pgConfigForRDS; |
{ | ||
"name": "@acuris/eventstore-postgresql", | ||
"private": false, | ||
"version": "1.1.2", | ||
"version": "1.1.4", | ||
"description": "Eventstore implementation storing events in Postgresql", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
31281
682