feat: setup env for superset BE

pull/76/head
Firman Ramdhani 2024-08-27 09:44:49 +07:00
parent dc97d5e14a
commit cb9421622d
3 changed files with 15 additions and 9 deletions

4
env/env.development vendored
View File

@ -41,4 +41,6 @@ ASSETS="https://asset.sky.eigen.co.id/"
GOOGLE_CALENDAR_KEY="AIzaSyCSg4P3uC9Z7kD1P4f3rf1BbBaz4Q-M55o" GOOGLE_CALENDAR_KEY="AIzaSyCSg4P3uC9Z7kD1P4f3rf1BbBaz4Q-M55o"
GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec10bd5@group.calendar.google.com" GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec10bd5@group.calendar.google.com"
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
SUPERSET_ADMIN_USERNAME=admin
SUPERSET_ADMIN_PASSWORD=admin

4
env/env.production vendored
View File

@ -38,4 +38,6 @@ ASSETS="https://asset.sky.eigen.co.id/"
GOOGLE_CALENDAR_KEY="AIzaSyCSg4P3uC9Z7kD1P4f3rf1BbBaz4Q-M55o" GOOGLE_CALENDAR_KEY="AIzaSyCSg4P3uC9Z7kD1P4f3rf1BbBaz4Q-M55o"
GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec10bd5@group.calendar.google.com" GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec10bd5@group.calendar.google.com"
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
SUPERSET_ADMIN_USERNAME=admin
SUPERSET_ADMIN_PASSWORD=admin

View File

@ -4,14 +4,16 @@ import { firstValueFrom } from 'rxjs';
@Injectable() @Injectable()
export class SupersetService { export class SupersetService {
private SUPERSET_URL = process.env.SUPERSET_URL + '/api'; private supersetURL = process.env.SUPERSET_URL + '/api';
private adminUsername = process.env.SUPERSET_ADMIN_USERNAME;
private adminPassword = process.env.SUPERSET_ADMIN_PASSWORD;
constructor(private readonly httpService: HttpService) {} constructor(private readonly httpService: HttpService) {}
async getLoginToken() { async getLoginToken() {
const data = { const data = {
username: 'admin', username: this.adminUsername,
password: 'admin', password: this.adminPassword,
provider: 'db', provider: 'db',
refresh: true, refresh: true,
}; };
@ -19,7 +21,7 @@ export class SupersetService {
const response = await firstValueFrom( const response = await firstValueFrom(
this.httpService.request({ this.httpService.request({
method: 'POST', method: 'POST',
url: `${this.SUPERSET_URL}/v1/security/login`, url: `${this.supersetURL}/v1/security/login`,
data: data, data: data,
}), }),
); );
@ -32,7 +34,7 @@ export class SupersetService {
const response = await firstValueFrom( const response = await firstValueFrom(
this.httpService.request({ this.httpService.request({
method: 'GET', method: 'GET',
url: `${this.SUPERSET_URL}/v1/security/csrf_token/`, url: `${this.supersetURL}/v1/security/csrf_token/`,
headers: { Authorization: `Bearer ${loginToken}` }, headers: { Authorization: `Bearer ${loginToken}` },
}), }),
); );
@ -53,13 +55,13 @@ export class SupersetService {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Authorization: `Bearer ${loginToken}`, Authorization: `Bearer ${loginToken}`,
'X-CSRFToken': `${csrfToken}`, 'X-CSRFToken': `${csrfToken}`,
Referer: `${this.SUPERSET_URL}/v1/security/guest_token/`, Referer: `${this.supersetURL}/v1/security/guest_token/`,
}; };
const response = await firstValueFrom( const response = await firstValueFrom(
this.httpService.request({ this.httpService.request({
method: 'POST', method: 'POST',
url: `${this.SUPERSET_URL}/v1/security/guest_token/`, url: `${this.supersetURL}/v1/security/guest_token/`,
data: data, data: data,
headers: headers, headers: headers,
}), }),