@liberation-data/drivine
Version:
Best and fastest graph database client for TypeScript / Node.js. Provides a level of abstraction for building highly scalable applications, without compromising architectural integrity
37 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NeptuneConnectionProvider = void 0;
const Neo4jConnection_1 = require("./Neo4jConnection");
const Neo4jResultMapper_1 = require("../mapper/Neo4jResultMapper");
const neo = require("neo4j-driver");
const short_unique_id_1 = require("short-unique-id");
const shortId = new short_unique_id_1.default({ length: 7 });
class NeptuneConnectionProvider {
constructor(name, type, host, port, protocol = 'bolt', config) {
this.name = name;
this.type = type;
this.host = host;
this.port = port;
this.protocol = protocol;
this.config = config;
const url = `${this.protocol}://${this.host}:${this.port}`;
const authToken = { scheme: "basic", realm: "realm", principal: "username", credentials: "" };
this.driver = neo.driver(url, authToken, {
...this.config,
encrypted: "ENCRYPTION_ON",
trust: "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES",
maxConnectionPoolSize: 1,
});
}
async connect() {
const session = this.driver.session();
session['sessionId'] = shortId.rnd();
const connection = new Neo4jConnection_1.Neo4jConnection(session, new Neo4jResultMapper_1.Neo4jResultMapper());
return Promise.resolve(connection);
}
async end() {
return this.driver.close();
}
}
exports.NeptuneConnectionProvider = NeptuneConnectionProvider;
//# sourceMappingURL=NeptuneConnectionProvider.js.map