Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 5596d38

Browse files
refactor: more tenor url to config
1 parent 689e84a commit 5596d38

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

studio/src/app/services/environment/environment-config.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ export interface EnvironmentFirebaseConfig {
77
messagingSenderId: string;
88
}
99

10+
export interface EnvironmentTenorConfig {
11+
url: string;
12+
key: string;
13+
}
14+
1015
export interface EnvironmentConfig {
1116
appUrl: string;
1217
apiUrl: string;
1318
firebase: EnvironmentFirebaseConfig;
14-
tenorKey: string
19+
tenor: EnvironmentTenorConfig;
1520
}
1621

1722
export function setupConfig(config: EnvironmentConfig) {

studio/src/app/services/gif/gif.service.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {EnvironmentConfigService} from '../environment/environment-config.servic
33
import {get, set} from 'idb-keyval';
44

55
import {ErrorService} from '../error/error.service';
6+
import {EnvironmentTenorConfig} from '../environment/environment-config';
67

78
export class GifService {
89

@@ -25,13 +26,14 @@ export class GifService {
2526
// call the trending and category endpoints
2627
getTrending(): Promise<TenorGif[]> {
2728
return new Promise<TenorGif[]>(async (resolve, reject) => {
28-
const apiKey: string = EnvironmentConfigService.getInstance().get('tenorKey');
29+
const config: EnvironmentTenorConfig = EnvironmentConfigService.getInstance().get('tenor');
30+
2931
const searchTerm: string = 'excited';
3032

3133
const anonymousId: string = await this.getAnonymousId();
3234

33-
const searchUrl = 'https://api.tenor.com/v1/search?tag=' + searchTerm + '&key=' +
34-
apiKey + '&ar_range=wide&limit=' + 8 + '&anon_id=' + anonymousId + '&media_filter=minimal';
35+
const searchUrl = config.url + 'search?tag=' + searchTerm + '&key=' +
36+
config.key + '&ar_range=wide&limit=' + 8 + '&anon_id=' + anonymousId + '&media_filter=minimal';
3537

3638
try {
3739
const rawResponse: Response = await fetch(searchUrl);
@@ -59,10 +61,10 @@ export class GifService {
5961
return;
6062
}
6163

62-
const apiKey: string = EnvironmentConfigService.getInstance().get('tenorKey');
64+
const config: EnvironmentTenorConfig = EnvironmentConfigService.getInstance().get('tenor');
6365

6466
try {
65-
const rawResponse: Response = await fetch('https://api.tenor.com/v1/anonid?key=' + apiKey);
67+
const rawResponse: Response = await fetch(config.url + '/anonid?key=' + config.key);
6668

6769
const response: TenorAnonymousResponse = JSON.parse(await rawResponse.text());
6870

studio/src/components.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import '@stencil/core';
99

1010
import '@ionic/core';
11+
import 'ionicons';
1112
import 'deckdeckgo';
1213
import 'deckdeckgo-inline-editor';
13-
import 'ionicons';
1414
import {
1515
EventEmitter,
1616
} from '@stencil/core';

studio/src/global/app-dev.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ setupConfig({
1616
storageBucket: '<@FIREBASE_STORAGE_BUCKET@>',
1717
messagingSenderId: '<@FIREBASE_MESSAGING_SENDER_ID@>'
1818
},
19-
tenorKey: '<@TENOR_KEY@>'
19+
tenor: {
20+
url: 'https://api.tenor.com/v1/',
21+
key: '<@TENOR_KEY@>'
22+
}
2023
});

studio/src/global/app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ setupConfig({
1616
storageBucket: '<@FIREBASE_STORAGE_BUCKET@>',
1717
messagingSenderId: '<@FIREBASE_MESSAGING_SENDER_ID@>'
1818
},
19-
tenorKey: '<@TENOR_KEY@>'
19+
tenor: {
20+
url: 'https://api.tenor.com/v1/',
21+
key: '<@TENOR_KEY@>'
22+
}
2023
});

0 commit comments

Comments
 (0)