diff --git a/.gitignore b/.gitignore index 22f55ad..6a7d6d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,130 @@ -# compiled output -/dist -/node_modules - # Logs logs *.log npm-debug.log* -pnpm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test -# OS -.DS_Store - -# Tests -/coverage -/.nyc_output - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json \ No newline at end of file +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* \ No newline at end of file diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index c253482..4307327 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/package.json b/package.json index 8c36aac..c9fc6c2 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,14 @@ "@nestjs/apollo": "^12.1.0", "@nestjs/axios": "^3.0.2", "@nestjs/common": "^10.0.0", + "@nestjs/config": "^3.2.3", "@nestjs/core": "^10.0.0", "@nestjs/graphql": "^12.1.1", "@nestjs/mapped-types": "*", "@nestjs/platform-express": "^10.0.0", "axios": "^1.7.2", "graphql": "^16.8.1", + "joi": "^17.13.3", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", "ts-morph": "^22.0.0" diff --git a/src/app.module.ts b/src/app.module.ts index d6b504f..4fd77de 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,6 +1,8 @@ import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo'; import { Module } from '@nestjs/common'; +import { ConfigModule } from '@nestjs/config'; import { GraphQLModule } from '@nestjs/graphql'; +import joi from 'joi'; import { MovieModule } from './movie/movie.module'; import { PersonModule } from './person/person.module'; @@ -8,6 +10,12 @@ import { ShowModule } from './show/show.module'; @Module({ imports: [ + ConfigModule.forRoot({ + isGlobal: true, + validationSchema: joi.object({ + THE_OPEN_MOVIE_DATABASE_API_KEY: joi.string().required() + }) + }), GraphQLModule.forRoot({ driver: ApolloDriver, playground: true, diff --git a/src/entertainment/entertainment.service.ts b/src/entertainment/entertainment.service.ts index fe4fbc8..a803fbe 100644 --- a/src/entertainment/entertainment.service.ts +++ b/src/entertainment/entertainment.service.ts @@ -1,6 +1,7 @@ /* eslint-disable import/extensions */ import { HttpService } from '@nestjs/axios'; import { Injectable } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; import { firstValueFrom } from 'rxjs'; import { @@ -37,7 +38,8 @@ export class EntertainmentService { constructor( private readonly httpService: HttpService, private readonly utilService: UtilsService, - private readonly socialsService: SocialsService + private readonly socialsService: SocialsService, + private readonly configService: ConfigService ) {} async getReview({ @@ -50,9 +52,7 @@ export class EntertainmentService { { headers: { Accept: 'application/json', - Authorization: - // eslint-disable-next-line max-len - 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI1NDMwNWQxNmE1ZThkN2E3ZWMwZmM2NTk5MzZiY2EzMCIsInN1YiI6IjViMzE0MjQ1OTI1MTQxM2M5MTAwNTIwNCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.iqdLKFCSgeWG3SYso7Rqj297FORviPf9hDdn2kKygTA' + Authorization: `Bearer ${this.configService.get('THE_OPEN_MOVIE_DATABASE_API_KEY')}` } } ) @@ -92,9 +92,7 @@ export class EntertainmentService { { headers: { Accept: 'application/json', - Authorization: - // eslint-disable-next-line max-len - 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI1NDMwNWQxNmE1ZThkN2E3ZWMwZmM2NTk5MzZiY2EzMCIsInN1YiI6IjViMzE0MjQ1OTI1MTQxM2M5MTAwNTIwNCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.iqdLKFCSgeWG3SYso7Rqj297FORviPf9hDdn2kKygTA' + Authorization: `Bearer ${this.configService.get('THE_OPEN_MOVIE_DATABASE_API_KEY')}` } } ) @@ -122,9 +120,7 @@ export class EntertainmentService { { headers: { Accept: 'application/json', - Authorization: - // eslint-disable-next-line max-len - 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI1NDMwNWQxNmE1ZThkN2E3ZWMwZmM2NTk5MzZiY2EzMCIsInN1YiI6IjViMzE0MjQ1OTI1MTQxM2M5MTAwNTIwNCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.iqdLKFCSgeWG3SYso7Rqj297FORviPf9hDdn2kKygTA' + Authorization: `Bearer ${this.configService.get('THE_OPEN_MOVIE_DATABASE_API_KEY')}` } } ) @@ -183,9 +179,7 @@ export class EntertainmentService { { headers: { Accept: 'application/json', - Authorization: - // eslint-disable-next-line max-len - 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI1NDMwNWQxNmE1ZThkN2E3ZWMwZmM2NTk5MzZiY2EzMCIsInN1YiI6IjViMzE0MjQ1OTI1MTQxM2M5MTAwNTIwNCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.iqdLKFCSgeWG3SYso7Rqj297FORviPf9hDdn2kKygTA' + Authorization: `Bearer ${this.configService.get('THE_OPEN_MOVIE_DATABASE_API_KEY')}` } } ) @@ -251,9 +245,7 @@ export class EntertainmentService { { headers: { Accept: 'application/json', - Authorization: - // eslint-disable-next-line max-len - 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI1NDMwNWQxNmE1ZThkN2E3ZWMwZmM2NTk5MzZiY2EzMCIsInN1YiI6IjViMzE0MjQ1OTI1MTQxM2M5MTAwNTIwNCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.iqdLKFCSgeWG3SYso7Rqj297FORviPf9hDdn2kKygTA' + Authorization: `Bearer ${this.configService.get('THE_OPEN_MOVIE_DATABASE_API_KEY')}` } } ) diff --git a/src/graphql.schema.ts b/src/graphql.schema.ts index 82bea45..375e50b 100644 --- a/src/graphql.schema.ts +++ b/src/graphql.schema.ts @@ -1,232 +1,232 @@ -/* - * ------------------------------------------------------- - * THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) - * ------------------------------------------------------- - */ - -/* eslint-disable */ - -export enum ENTERTAINMENT_TYPES { - MOVIE = "MOVIE", - TV = "TV" -} - -export enum RESOURCE_TYPE { - TOP_RATED = "TOP_RATED", - POPULAR = "POPULAR", - NOW_PLAYING = "NOW_PLAYING", - UPCOMING = "UPCOMING", - AIRING_TODAY = "AIRING_TODAY", - ON_THE_AIR = "ON_THE_AIR" -} - -export interface Movie { - __typename?: 'Movie'; - id?: Nullable; - name?: Nullable; - overview?: Nullable; - backgroundUrl?: Nullable; - posterUrl?: Nullable; - genres?: Nullable[]>; - homepage?: Nullable; - originalLanguage?: Nullable; - productionCompanies?: Nullable[]>; - releaseDate?: Nullable; - voteAverage?: Nullable; - status?: Nullable; - review?: Nullable; - recommendations?: Nullable[]>; - keywords?: Nullable[]>; - social?: Nullable; - topBilledCast?: Nullable[]>; - featuredCrew?: Nullable[]>; - youtubeVideo?: Nullable