Skip to content

Commit d69db4a

Browse files
authored
Merge pull request #12 from hsrm-lume/hostname-mapper
neo4j url with mapper
2 parents b7a2722 + 270937f commit d69db4a

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/app/services/neo4j-service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Injectable, OnDestroy } from '@angular/core';
1+
import { DOCUMENT } from '@angular/common';
2+
import { Inject, Injectable, OnDestroy } from '@angular/core';
23
import * as neo4j from 'neo4j-driver';
34
import { tap } from 'rxjs/operators';
45
import { environment } from 'src/environments/environment';
@@ -8,9 +9,9 @@ import { environment } from 'src/environments/environment';
89
})
910
export default class Neo4jService implements OnDestroy {
1011
driver: neo4j.Driver;
11-
constructor() {
12+
constructor(@Inject(DOCUMENT) private document: { location: any}) {
1213
this.driver = neo4j.driver(
13-
environment.neo4j.url,
14+
environment.neo4j.url(this.document.location),
1415
neo4j.auth.basic(
1516
environment.neo4j.username,
1617
environment.neo4j.password

src/environments/environment.prod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export const environment = {
22
neo4j: {
3-
url: 'neo4j://neo4j.lume.m-ptr.de:7687',
3+
url: (location: any) => {
4+
if(location.hostname === 'localhost') return "neo4j://localhost";
5+
else return `neo4j://neo4j.${location.hostname}:7687`
6+
},
47
username: 'readonly',
58
password: 'well-known',
69
},

src/environments/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
export const environment = {
66
neo4j: {
7-
url: 'neo4j://localhost',
7+
url: (location: any) => 'neo4j://localhost',
88
username: 'neo4j',
99
password: 's3cr3t4',
1010
},

0 commit comments

Comments
 (0)