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

2
env/env.development vendored
View File

@ -42,3 +42,5 @@ GOOGLE_CALENDAR_KEY="AIzaSyCSg4P3uC9Z7kD1P4f3rf1BbBaz4Q-M55o"
GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec10bd5@group.calendar.google.com"
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
SUPERSET_ADMIN_USERNAME=admin
SUPERSET_ADMIN_PASSWORD=admin

2
env/env.production vendored
View File

@ -39,3 +39,5 @@ GOOGLE_CALENDAR_KEY="AIzaSyCSg4P3uC9Z7kD1P4f3rf1BbBaz4Q-M55o"
GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec10bd5@group.calendar.google.com"
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()
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) {}
async getLoginToken() {
const data = {
username: 'admin',
password: 'admin',
username: this.adminUsername,
password: this.adminPassword,
provider: 'db',
refresh: true,
};
@ -19,7 +21,7 @@ export class SupersetService {
const response = await firstValueFrom(
this.httpService.request({
method: 'POST',
url: `${this.SUPERSET_URL}/v1/security/login`,
url: `${this.supersetURL}/v1/security/login`,
data: data,
}),
);
@ -32,7 +34,7 @@ export class SupersetService {
const response = await firstValueFrom(
this.httpService.request({
method: 'GET',
url: `${this.SUPERSET_URL}/v1/security/csrf_token/`,
url: `${this.supersetURL}/v1/security/csrf_token/`,
headers: { Authorization: `Bearer ${loginToken}` },
}),
);
@ -53,13 +55,13 @@ export class SupersetService {
'Content-Type': 'application/json',
Authorization: `Bearer ${loginToken}`,
'X-CSRFToken': `${csrfToken}`,
Referer: `${this.SUPERSET_URL}/v1/security/guest_token/`,
Referer: `${this.supersetURL}/v1/security/guest_token/`,
};
const response = await firstValueFrom(
this.httpService.request({
method: 'POST',
url: `${this.SUPERSET_URL}/v1/security/guest_token/`,
url: `${this.supersetURL}/v1/security/guest_token/`,
data: data,
headers: headers,
}),