diff --git a/.eslintrc b/.eslintrc index c74bf24..75b72eb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,104 +1,115 @@ { - "root": true, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": true, - "tsconfigRootDir": ".", - "sourceType": "module" - }, - "plugins": ["@typescript-eslint", "sonarjs", "jest", "prettier"], - "extends": [ - "eslint:recommended", - "airbnb-base", - "airbnb-typescript/base", - "plugin:jest/recommended", - "plugin:sonarjs/recommended", - "plugin:@typescript-eslint/strict-type-checked", - "plugin:@typescript-eslint/stylistic-type-checked", - "plugin:prettier/recommended" - ], - "ignorePatterns": ["**/node_modules/**", "dist/**", "src/entity/**"], - "rules": { - // These rules are for reference only. - //#region eslint - "class-methods-use-this": "off", - // https://github.com/typescript-eslint/typescript-eslint/issues/1277 - "consistent-return": "off", - "func-names": "off", - "max-len": ["error", { "code": 140, "ignoreTemplateLiterals": true, "ignoreUrls": true }], - "newline-per-chained-call": "off", - "no-await-in-loop": "off", - "no-continue": "off", - // https://github.com/airbnb/javascript/issues/1342 - "no-param-reassign": ["error", { "props": false }], - // https://github.com/airbnb/javascript/issues/1271 - // https://github.com/airbnb/javascript/blob/fd77bbebb77362ddecfef7aba3bf6abf7bdd81f2/packages/eslint-config-airbnb-base/rules/style.js#L340-L358 - "no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"], - "no-underscore-dangle": ["error", { "allow": ["_id"] }], - "no-void": ["error", { "allowAsStatement": true }], - "object-curly-newline": "off", - "spaced-comment": ["error", "always", { "line": { "markers": ["/", "#region", "#endregion"] } }], - //#endregion + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": true, + "tsconfigRootDir": ".", + "sourceType": "module" + }, + "plugins": ["@typescript-eslint", "sonarjs", "jest", "prettier"], + "extends": [ + "eslint:recommended", + "airbnb-base", + "airbnb-typescript/base", + "plugin:jest/recommended", + "plugin:sonarjs/recommended", + "plugin:@typescript-eslint/strict-type-checked", + "plugin:@typescript-eslint/stylistic-type-checked", + "plugin:prettier/recommended" + ], + "ignorePatterns": ["**/node_modules/**", "dist/**", "*.graphql"], + "rules": { + // These rules are for reference only. + //#region eslint + "class-methods-use-this": "off", + // https://github.com/typescript-eslint/typescript-eslint/issues/1277 + "consistent-return": "off", + "func-names": "off", + "max-len": ["error", { "code": 140, "ignoreTemplateLiterals": true, "ignoreUrls": true }], + "newline-per-chained-call": "off", + "no-await-in-loop": "off", + "no-continue": "off", + // https://github.com/airbnb/javascript/issues/1342 + "no-param-reassign": ["error", { "props": false }], + // https://github.com/airbnb/javascript/issues/1271 + // https://github.com/airbnb/javascript/blob/fd77bbebb77362ddecfef7aba3bf6abf7bdd81f2/packages/eslint-config-airbnb-base/rules/style.js#L340-L358 + "no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"], + "no-underscore-dangle": ["error", { "allow": ["_id"] }], + "no-void": ["error", { "allowAsStatement": true }], + "object-curly-newline": "off", + "spaced-comment": [ + "error", + "always", + { "line": { "markers": ["/", "#region", "#endregion"] } } + ], + //#endregion - //#region import - "import/extensions": ["error", "never"], - // https://github.com/benmosher/eslint-plugin-import/issues/1753 - "import/named": "off", - "import/no-default-export": "error", - "import/order": [ - "error", - { - "groups": [["builtin", "external", "internal"]], - "newlines-between": "always", - "alphabetize": { "order": "asc", "caseInsensitive": true } - } - ], - "import/prefer-default-export": "off", - //#endregion + //#region import + "import/extensions": ["error", "never"], + // https://github.com/benmosher/eslint-plugin-import/issues/1753 + "import/named": "off", + "import/no-default-export": "error", + "import/order": [ + "error", + { + "groups": [["builtin", "external", "internal"]], + "newlines-between": "always", + "alphabetize": { "order": "asc", "caseInsensitive": true } + } + ], + "import/prefer-default-export": "off", + //#endregion - //#region @typescript-eslint - "@typescript-eslint/consistent-type-assertions": ["error", { "assertionStyle": "angle-bracket" }], - "@typescript-eslint/lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }], - "@typescript-eslint/naming-convention": [ - "error", - { "selector": "default", "format": ["strictCamelCase"] }, - { "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE", "StrictPascalCase"] }, - // https://github.com/microsoft/TypeScript/issues/9458 - { - "selector": "parameter", - "modifiers": ["unused"], - "format": ["strictCamelCase"], - "leadingUnderscore": "allow" - }, - { "selector": "property", "format": null }, - { "selector": "typeProperty", "format": null }, - { "selector": "typeLike", "format": ["StrictPascalCase"] }, - { "selector": "enumMember", "format": ["UPPER_CASE"] } - ], - "@typescript-eslint/no-extraneous-class": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - //#endregion + //#region @typescript-eslint + "@typescript-eslint/consistent-type-assertions": [ + "error", + { "assertionStyle": "angle-bracket" } + ], + "@typescript-eslint/lines-between-class-members": [ + "error", + "always", + { "exceptAfterSingleLine": true } + ], + "@typescript-eslint/naming-convention": [ + "error", + { "selector": "default", "format": ["strictCamelCase"] }, + { "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE", "StrictPascalCase"] }, + // https://github.com/microsoft/TypeScript/issues/9458 + { + "selector": "parameter", + "modifiers": ["unused"], + "format": ["strictCamelCase"], + "leadingUnderscore": "allow" + }, + { "selector": "property", "format": null }, + { "selector": "typeProperty", "format": null }, + { "selector": "typeLike", "format": ["StrictPascalCase"] }, + { "selector": "enumMember", "format": ["UPPER_CASE"] } + ], + "@typescript-eslint/no-extraneous-class": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + //#endregion - //#region sonarjs - "sonarjs/no-duplicate-string": "off", - "sonarjs/cognitive-complexity": ["error", 25], - //#endregion + //#region sonarjs + "sonarjs/no-duplicate-string": "off", + "sonarjs/cognitive-complexity": ["error", 25], + //#endregion - "prettier/prettier": [ - "error", - { - "singleQuote": true, - "endOfLine": "auto" - } - ], + "prettier/prettier": [ + "error", + { + "singleQuote": true, + "endOfLine": "auto" + } + ], - "quotes": [ - 2, - "single", - { - "avoidEscape": true, - "allowTemplateLiterals": true - } - ] - } + "quotes": [ + 2, + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": true + } + ] + } } diff --git a/.vscode/settings.json b/.vscode/settings.json index ec13d67..0dfe76a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,70 +1,70 @@ { - "scss.lint.unknownAtRules": "ignore", - "files.eol": "\n", - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.formatOnSave": true, - "editor.formatOnPaste": true, - "editor.detectIndentation": true, - "editor.fontLigatures": false, - "editor.snippetSuggestions": "top", - "editor.suggest.localityBonus": true, - "editor.acceptSuggestionOnCommitCharacter": false, - "editor.renderWhitespace": "boundary", - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" - }, - "editor.cursorSmoothCaretAnimation": "on", - "editor.fontSize": 20, - "editor.minimap.enabled": false, - "editor.tabSize": 2, + "scss.lint.unknownAtRules": "ignore", + "files.eol": "\n", + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.formatOnPaste": true, + "editor.detectIndentation": true, + "editor.fontLigatures": false, + "editor.snippetSuggestions": "top", + "editor.suggest.localityBonus": true, + "editor.acceptSuggestionOnCommitCharacter": false, + "editor.renderWhitespace": "boundary", + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "editor.cursorSmoothCaretAnimation": "on", + "editor.fontSize": 30, + "editor.minimap.enabled": false, + "editor.tabSize": 2, - "files.trimTrailingWhitespace": true, - "files.trimFinalNewlines": true, + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, - "workbench.sideBar.location": "right", + "workbench.sideBar.location": "right", - "javascript.updateImportsOnFileMove.enabled": "always", + "javascript.updateImportsOnFileMove.enabled": "always", - "typescript.validate.enable": true, + "typescript.validate.enable": true, - "files.autoSave": "off", - "files.exclude": { - "USE_GITIGNORE": true - }, - "files.defaultLanguage": "{activeEditorLanguage}", + "files.autoSave": "off", + "files.exclude": { + "USE_GITIGNORE": true + }, + "files.defaultLanguage": "{activeEditorLanguage}", - "javascript.validate.enable": true, // Highligts the unused imports when true - "editor.showUnused": true, // Highligts the unused imports when true + "javascript.validate.enable": true, // Highligts the unused imports when true + "editor.showUnused": true, // Highligts the unused imports when true - "search.exclude": { - "**/node_modules": true, - "**/bower_components": true, - "**/*.code-search": true, - "**/build": true, - "**/.build": true - }, + "search.exclude": { + "**/node_modules": true, + "**/bower_components": true, + "**/*.code-search": true, + "**/build": true, + "**/.build": true + }, - "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"], + "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"], - "breadcrumbs.enabled": true, - "npm.runSilent": true, - "explorer.confirmDragAndDrop": true, + "breadcrumbs.enabled": true, + "npm.runSilent": true, + "explorer.confirmDragAndDrop": true, - "[javascript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.suggestSelection": "recentlyUsedByPrefix", - "editor.suggest.showKeywords": true - }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.suggestSelection": "recentlyUsedByPrefix", + "editor.suggest.showKeywords": true + }, - "[json]": { - "breadcrumbs.showBooleans": true - }, + "[json]": { + "breadcrumbs.showBooleans": true + }, - "files.associations": { - "*.react.js": "javascriptreact", - "*.jsx": "javascriptreact" - }, - "terminal.integrated.fontSize": 20, - "screencastMode.fontSize": 59, - "scm.inputFontSize": 20 + "files.associations": { + "*.react.js": "javascriptreact", + "*.jsx": "javascriptreact" + }, + "terminal.integrated.fontSize": 20, + "screencastMode.fontSize": 59, + "scm.inputFontSize": 20 } diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz new file mode 100644 index 0000000..6f25e99 Binary files /dev/null and b/.yarn/install-state.gz differ diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 0000000..0acb263 --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/package.json b/package.json index d6f71c1..888d5c9 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "UNLICENSED", "scripts": { "build": "nest build", - "lint": "yarn run eslint ./src/** --ext ts,tsx --fix", + "lint": "yarn run eslint ./src/**/*.{ts,tsx} --fix", "format": "prettier --write ./src", "ts-validate": "tsc", "validate": "yarn run ts-validate && yarn run format && yarn run lint", @@ -20,14 +20,20 @@ "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", - "prepare": "husky install" + "prepare": "husky install", + "gql-to-interfaces": "cd ./src && ts-node schema-to-typings" }, "dependencies": { + "@apollo/server": "^4.10.4", + "@nestjs/apollo": "^12.1.0", "@nestjs/common": "^10.0.0", "@nestjs/core": "^10.0.0", + "@nestjs/graphql": "^12.1.1", "@nestjs/platform-express": "^10.0.0", + "graphql": "^16.8.1", "reflect-metadata": "^0.1.13", - "rxjs": "^7.8.1" + "rxjs": "^7.8.1", + "ts-morph": "^22.0.0" }, "devDependencies": { "@nestjs/cli": "^10.0.0", @@ -47,6 +53,7 @@ "eslint-plugin-jest": "^27.6.0", "eslint-plugin-prettier": "^5.1.2", "eslint-plugin-sonarjs": "^0.23.0", + "husky": "^8.0.0", "jest": "^29.5.0", "prettier": "^3.0.0", "source-map-support": "^0.5.21", @@ -55,8 +62,7 @@ "ts-loader": "^9.4.3", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3", - "husky": "^8.0.0" + "typescript": "^5.1.3" }, "jest": { "moduleFileExtensions": [ @@ -74,5 +80,6 @@ ], "coverageDirectory": "../coverage", "testEnvironment": "node" - } + }, + "packageManager": "yarn@4.2.2" } diff --git a/src/app.module.ts b/src/app.module.ts index cdf7786..3c4a40d 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,10 +1,17 @@ +import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo'; import { Module } from '@nestjs/common'; +import { GraphQLModule } from '@nestjs/graphql'; import { AppController } from './app.controller'; import { AppService } from './app.service'; @Module({ - imports: [], + imports: [ + GraphQLModule.forRoot({ + driver: ApolloDriver, + playground: true + }) + ], controllers: [AppController], diff --git a/src/graphql.ts b/src/graphql.ts new file mode 100644 index 0000000..4c0a393 --- /dev/null +++ b/src/graphql.ts @@ -0,0 +1,202 @@ +/* + * ------------------------------------------------------- + * THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) + * ------------------------------------------------------- + */ + +/* eslint-disable */ + +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; + reviews?: Nullable[]>; + recommendations?: Nullable[]>; + keywords?: Nullable[]>; + social?: Nullable; + featuredCast?: Nullable[]>; + featuredCrew?: Nullable[]>; + featuredVideo?: Nullable