Skip to content

Commit

Permalink
feature/upgrade-youtube-search-api (#62)
Browse files Browse the repository at this point in the history
* feature/upgrade-youtube-search-api

* add warm-up server API

* fix lint warnings

* upgrade youtube-sr package to v4.3.4

* bump app version

* add API mocks
  • Loading branch information
vugar005 committed Jun 18, 2023
1 parent 62a6355 commit d1aa8dd
Show file tree
Hide file tree
Showing 16 changed files with 818 additions and 27 deletions.
2 changes: 1 addition & 1 deletion appengines/backend/app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
runtime: nodejs18.16.0
runtime: nodejs18
instance_class: F1
automatic_scaling:
min_idle_instances: 0
Expand Down
7 changes: 4 additions & 3 deletions appengines/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
"version": "0.0.1",
"main": "main.js",
"scripts": {
"start": "node dist/main.js"
"start": "node dist/main.js",
"deploy": "gcloud config set project youtube-webapp-341311 && gcloud app deploy"
},
"dependencies": {
"@nestjs/common": "9.4.2",
"@nestjs/core": "9.4.2",
"@nestjs/platform-express": "9.4.2",
"reflect-metadata": "0.1.13",
"rxjs": "7.5.6",
"youtube-search-without-api-key": "1.0.7",
"youtube-sr": "4.1.15"
"youtube-search-without-api-key": "1.1.0",
"youtube-sr": "4.3.4"
}
}
7 changes: 7 additions & 0 deletions apps/backend/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ export class AppController {
getHello(): string {
return this.appService.getHello();
}

@Get('/manual_warmup')
async manualWarmUp(): Promise<any> {
return {
ok: true,
};
}
}
2 changes: 1 addition & 1 deletion apps/backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function bootstrap(): Promise<void> {
});
app.enableVersioning({
type: VersioningType.URI,
defaultVersion: '1',
defaultVersion: '',
});
const port = process.env.PORT || 3333;
await app.listen(port);
Expand Down
8 changes: 8 additions & 0 deletions apps/shell/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
LocalStorageEnum,
SessionStorageEnum,
NotFoundPageComponent,
IYoutubeService,
YOUTUBE_SERVICE,
} from '@youtube/common-ui';
import { filter, Observable, Subject, takeUntil } from 'rxjs';

Expand Down Expand Up @@ -59,6 +61,7 @@ export class AppComponent implements OnInit, OnDestroy {

constructor(
@Inject(PLATFORM_ID) private platformId: Object, //eslint-disable-line
@Inject(YOUTUBE_SERVICE) private youtubeService: IYoutubeService,
private videoStore: VideoStoreService,
private router: Router,
private eventDispatcher: EventDispatcherService,
Expand All @@ -76,6 +79,7 @@ export class AppComponent implements OnInit, OnDestroy {
this.tryRestoreMiniVideoSetings();
this.tryRestoreTheme();
this.openPolicyTermsDialog();
this.warmUpServer();
}

public ngOnDestroy(): void {
Expand Down Expand Up @@ -177,4 +181,8 @@ export class AppComponent implements OnInit, OnDestroy {
}
});
}

private warmUpServer(): void {
this.youtubeService.warmUp().subscribe();
}
}
4 changes: 2 additions & 2 deletions apps/shell/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { provideRouter } from '@angular/router';
import { provideRouter, withEnabledBlockingInitialNavigation } from '@angular/router';
import { ApplicationConfig, Injector, importProvidersFrom } from '@angular/core';
import { HTTP_INTERCEPTORS, provideHttpClient } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
Expand All @@ -16,7 +16,7 @@ import { provideClientHydration } from '@angular/platform-browser';

export const appConfig: ApplicationConfig = {
providers: [
provideRouter(APP_ROUTES),
provideRouter(APP_ROUTES, withEnabledBlockingInitialNavigation()),
provideHttpClient(),
provideClientHydration(),
{
Expand Down
2 changes: 1 addition & 1 deletion apps/shell/src/app/app.constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ICommonMetaTagConfig } from '@youtube/common-ui';

export const APP_VERSION = '3.3.2';
export const APP_VERSION = '3.3.4';

export const SHELL_META_TAGS: ICommonMetaTagConfig = {
title: 'Youtube Angular Clone',
Expand Down
8 changes: 4 additions & 4 deletions apps/shell/src/app/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import {
} from '@youtube/common-ui';
import { catchError, EMPTY, Subject, take, takeUntil } from 'rxjs';
import { DEFAULT_SEARCH_VALUE } from 'src/app/app.constants';
import { environment } from 'src/environments/environment';
import { SettingsStore } from '../../core/services/settings-store/settings-store.service';
import { AppTheme } from '../../core/services/theme-service/theme.constants';
import { ThemeService } from '../../core/services/theme-service/theme.service';
import { VideoStoreService } from '../../core/services/video-store/video-store.service';
import { environment } from 'src/environments/environment';

@Component({
standalone: true,
Expand Down Expand Up @@ -117,9 +117,9 @@ export class HeaderComponent implements OnInit, OnDestroy {

private getCountryCode(): void {
// load only on production to save api traffic :)
// if (!environment.production || isPlatformServer(this.platformId)) {
// return;
// }
if (!environment.production || isPlatformServer(this.platformId)) {
return;
}
this.countryApiService
.getCountryCode()
.pipe(catchError(() => EMPTY))
Expand Down
Loading

0 comments on commit d1aa8dd

Please sign in to comment.