Browse Source

feat: Changes for the proxy and API endpoints configuration

master
Konstantinos Kamaropoulos 5 years ago
parent
commit
6e8e018fe1
  1. 5
      package-lock.json
  2. 1
      package.json
  3. 16
      proxy.conf.js
  4. 4
      src/app/home/home.component.spec.ts
  5. 12
      src/app/logs.service.spec.ts
  6. 2
      src/app/logs.service.ts
  7. 7
      src/environments/environment.prod.ts

5
package-lock.json

@ -6904,6 +6904,11 @@
"integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=",
"dev": true
},
"is-docker": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.0.0.tgz",
"integrity": "sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ=="
},
"is-dotfile": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz",

1
package.json

@ -37,6 +37,7 @@
"@types/googlemaps": "^3.39.3",
"@types/mapbox-gl": "^1.8.0",
"bootstrap": "^4.1.1",
"is-docker": "^2.0.0",
"mapbox-gl": "^1.8.1",
"rxjs": "^6.5.2",
"zone.js": "^0.9.1"

16
proxy.conf.js

@ -1,4 +1,5 @@
const HttpsProxyAgent = require('https-proxy-agent');
const isDocker = require('is-docker');
/*
* API proxy configuration.
@ -6,11 +7,24 @@ const HttpsProxyAgent = require('https-proxy-agent');
* This is especially useful during app development to avoid CORS issues while running a local server.
* For more details and options, see https://angular.io/guide/build#using-corporate-proxy
*/
console.log('ISDOCKER? = ' + isDocker());
let hostname;
if (isDocker()) {
hostname = 'backend';
} else {
hostname = 'localhost';
}
console.log(hostname);
const proxyConfig = [
{
context: '/api',
pathRewrite: { '^/api': '' },
target: 'https://api.chucknorris.io',
target: 'http://' + hostname + ':3000',
changeOrigin: true,
secure: false
}

4
src/app/home/home.component.spec.ts

@ -4,7 +4,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CoreModule } from '@app/core';
import { SharedModule } from '@app/shared';
import { HomeComponent } from './home.component';
import { QuoteService } from './quote.service';
describe('HomeComponent', () => {
let component: HomeComponent;
@ -13,8 +12,7 @@ describe('HomeComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [CoreModule, SharedModule, HttpClientTestingModule],
declarations: [HomeComponent],
providers: [QuoteService]
declarations: [HomeComponent]
}).compileComponents();
}));

12
src/app/logs.service.spec.ts

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { LogsService } from './logs.service';
describe('LogsService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: LogsService = TestBed.get(LogsService);
expect(service).toBeTruthy();
});
});

2
src/app/logs.service.ts

@ -13,7 +13,7 @@ export class LogsService {
getLogs(): Promise<Array<Object>> {
return this.httpClient
.get('http://192.168.100.4:3000/logs')
.get('/logs')
.pipe(
map((body: any) => {
return body;

7
src/environments/environment.prod.ts

@ -10,7 +10,10 @@ export const environment = {
production: true,
hmr: false,
version: env.npm_package_version,
serverUrl: 'https://api.chucknorris.io',
serverUrl: 'http://154.57.7.115:3000',
defaultLanguage: 'en-US',
supportedLanguages: ['en-US', 'el-GR']
supportedLanguages: ['en-US', 'el-GR'],
mapbox: {
accessToken: 'pk.eyJ1Ijoia2FtYXJvcG91bG9zIiwiYSI6ImNrNzN0dzBxcjAxbzUza3Bhb2Jnd2c2cWIifQ.7CvFsos8lOlKopFajrf2FA'
}
};

Loading…
Cancel
Save