Skip to content

Commit 63adef3

Browse files
Nestjs rewrite
**As part of this PR the following has been completed:** - Rewrote the entire project in NestJS - Reworked the structure of the project to make it easier to identify key areas. With each new section there are various README files which discuss the section. - Added various unit tests with Vitest to cover all the pieces of functionality with the help of Cursor - The project is now type safe, all response interfaces are generated from the Graphql schema. Every other interface is manually maintained as the data is from The Open Movie Database's systems OR the desired types couldn't be automated. - Any environment variables required are now validated via Joi (Would have used zod but couldn't OR you have to do a lot of work just to get it to work) - Updated the github actions to use yarn latest version. - Added a "Discover" module to allow users to quickly search for shows or movies, for now this just mimics what the The Open Movie Database discover page is doing. There still some work that needs doing about this, currently it fetches one one page at a time to get this working at the UI layer it'll need to use an infinite query
2 parents ae914cb + 9f931e9 commit 63adef3

File tree

273 files changed

+25160
-11154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+25160
-11154
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ root = true
33
[*]
44
charset = utf-8
55
indent_size = 2
6-
indent_style = space
6+
indent_style = tab
77
insert_final_newline = true
88
max_line_length = 100
99
trim_trailing_whitespace = true
@@ -15,4 +15,4 @@ trim_trailing_whitespace = false
1515
indent_style = tab
1616
[*.scss]
1717
indent_size = 2
18-
indent_style = space
18+
indent_style = tab

.eslintignore

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
./README.md
2-
3-
node_modules/*
4-
5-
*.test.js
6-
7-
package.json
8-
9-
package-lock.json
10-
11-
./.github/workflows/**/*.yml
1+
.github/

.eslintrc

Lines changed: 91 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,107 @@
11
{
2-
"env": {
3-
"browser": true,
4-
"commonjs": true,
5-
"es2020": true
6-
},
7-
"extends": ["airbnb-base", "prettier", "plugin:import/errors", "plugin:import/warnings"],
8-
"plugins": ["prettier"],
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
94
"parserOptions": {
10-
"ecmaVersion": 11
5+
"project": true,
6+
"tsconfigRootDir": ".",
7+
"sourceType": "module"
118
},
9+
"plugins": ["@typescript-eslint", "sonarjs", "prettier"],
10+
"extends": [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
13+
"airbnb-base",
14+
"airbnb-typescript/base",
15+
"plugin:sonarjs/recommended",
16+
"plugin:@typescript-eslint/strict-type-checked",
17+
"plugin:@typescript-eslint/stylistic-type-checked",
18+
"plugin:prettier/recommended"
19+
],
20+
"ignorePatterns": ["**/node_modules/**", "dist/**", "*.graphql"],
1221
"rules": {
13-
"array-callback-return": "off",
14-
"import/no-extraneous-dependencies": [
22+
"@typescript-eslint/lines-between-class-members": "off",
23+
"@typescript-eslint/no-throw-literal": "off",
24+
"@typescript-eslint/restrict-template-expressions": "off",
25+
"@typescript-eslint/no-duplicate-enum-values": "off",
26+
// These rules are for reference only.
27+
//#region eslint
28+
"class-methods-use-this": "off",
29+
// https://github.com/typescript-eslint/typescript-eslint/issues/1277
30+
"consistent-return": "off",
31+
"func-names": "off",
32+
"max-len": ["error", { "code": 140, "ignoreTemplateLiterals": true, "ignoreUrls": true }],
33+
"newline-per-chained-call": "off",
34+
"no-await-in-loop": "off",
35+
"no-continue": "off",
36+
// https://github.com/airbnb/javascript/issues/1342
37+
"no-param-reassign": ["error", { "props": false }],
38+
// https://github.com/airbnb/javascript/issues/1271
39+
// https://github.com/airbnb/javascript/blob/fd77bbebb77362ddecfef7aba3bf6abf7bdd81f2/packages/eslint-config-airbnb-base/rules/style.js#L340-L358
40+
"no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
41+
"no-underscore-dangle": ["error", { "allow": ["_id"] }],
42+
"no-void": ["error", { "allowAsStatement": true }],
43+
"object-curly-newline": "off",
44+
"spaced-comment": [
1545
"error",
16-
{
17-
"devDependencies": ["**/*.test.js"]
18-
}
46+
"always",
47+
{ "line": { "markers": ["/", "#region", "#endregion"] } }
1948
],
20-
"no-process-exit": "error",
21-
"no-debugger": 0,
22-
"no-alert": 0,
23-
"no-await-in-loop": 0,
24-
"no-return-assign": ["error", "except-parens"],
25-
"no-restricted-syntax": [2, "ForInStatement", "LabeledStatement", "WithStatement"],
26-
"no-unused-vars": "error",
27-
"prefer-const": [
49+
//#endregion
50+
51+
//#region import
52+
"import/extensions": ["error", "never"],
53+
// https://github.com/benmosher/eslint-plugin-import/issues/1753
54+
"import/named": "off",
55+
"import/no-default-export": "error",
56+
"import/order": [
2857
"error",
2958
{
30-
"destructuring": "all"
59+
"groups": [["builtin", "external", "internal"]],
60+
"newlines-between": "always",
61+
"alphabetize": { "order": "asc", "caseInsensitive": true }
3162
}
3263
],
33-
"arrow-body-style": [2, "as-needed"],
34-
"no-unused-expressions": [
35-
2,
36-
{
37-
"allowTaggedTemplates": true
38-
}
64+
"import/prefer-default-export": "off",
65+
//#endregion
66+
67+
//#region @typescript-eslint
68+
"@typescript-eslint/consistent-type-assertions": [
69+
"error",
70+
{ "assertionStyle": "angle-bracket" }
3971
],
40-
"no-param-reassign": [
41-
2,
72+
"@typescript-eslint/naming-convention": [
73+
"error",
74+
{ "selector": "default", "format": ["strictCamelCase"] },
75+
{ "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE", "StrictPascalCase"] },
76+
// https://github.com/microsoft/TypeScript/issues/9458
4277
{
43-
"props": false
44-
}
78+
"selector": "parameter",
79+
"modifiers": ["unused"],
80+
"format": ["strictCamelCase"],
81+
"leadingUnderscore": "allow"
82+
},
83+
{ "selector": "property", "format": null },
84+
{ "selector": "typeProperty", "format": null },
85+
{ "selector": "typeLike", "format": ["StrictPascalCase"] },
86+
{ "selector": "enumMember", "format": ["UPPER_CASE"] }
4587
],
46-
"no-console": 0,
47-
"default-case": 0,
48-
"import/prefer-default-export": 0,
49-
"func-names": "off",
50-
"space-before-function-paren": 0,
51-
"comma-dangle": 0,
52-
"max-len": 0,
53-
"import/extensions": 2,
54-
"no-underscore-dangle": 0,
55-
"consistent-return": 0,
56-
"radix": 0,
57-
"no-shadow": [
58-
2,
88+
"@typescript-eslint/no-extraneous-class": "off",
89+
"@typescript-eslint/no-unsafe-member-access": "off",
90+
//#endregion
91+
92+
//#region sonarjs
93+
"sonarjs/no-duplicate-string": "off",
94+
"sonarjs/cognitive-complexity": ["error", 25],
95+
//#endregion
96+
97+
"prettier/prettier": [
98+
"error",
5999
{
60-
"hoist": "all",
61-
"allow": ["resolve", "reject", "done", "next", "err", "error"]
100+
"singleQuote": true,
101+
"endOfLine": "auto"
62102
}
63103
],
104+
64105
"quotes": [
65106
2,
66107
"single",
@@ -69,11 +110,11 @@
69110
"allowTemplateLiterals": true
70111
}
71112
],
72-
"prettier/prettier": [
113+
114+
"@typescript-eslint/array-type": [
73115
"error",
74116
{
75-
"singleQuote": true,
76-
"endOfLine": "auto"
117+
"default": "generic"
77118
}
78119
]
79120
}

.github/workflows/greeting-action.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/linting-action.yml

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,50 @@
1-
# Job name
2-
name: Application Linting
1+
name: Lint
32

4-
# When the to run the greeting
53
on: [pull_request, push]
64

7-
# Jobs to run for the action (You can have multiple actions in one file)
85
jobs:
96
run-linters:
10-
# Job display name
11-
name: Running the eslint checks
12-
13-
# Runs on a Linux based OS
7+
name: Run linters
148
runs-on: ubuntu-latest
159

10+
# Run the job on Node 20 and 23 which better support modern testing frameworks
11+
strategy:
12+
matrix:
13+
node-version: [20.x, 21.x, 23.x]
14+
1615
# Steps involved for this particular task
1716
steps:
18-
# Checks out the reporsitoy and enables the use of commands made avaliable in the project ie npm run
17+
# Checks out the repository and enables the use of commands made available in the project ie npm run
1918
- name: Check out Git repository
2019
uses: actions/checkout@v2
2120

22-
# Setup Nodes on the versions specified in the matrix stratergy
23-
- name: Set up Node.js version
21+
- name: Set up Node.js version ${{ matrix.node-version }}
2422
uses: actions/setup-node@v1
2523
with:
26-
node-version: 12
24+
node-version: ${{ matrix.node-version }}
2725

28-
# Cache the node_modules
29-
- name: Cache node modules
30-
uses: actions/cache@v2
26+
- name: Enable Corepack
27+
run: corepack enable
3128

32-
# Defining the cache env config ie the key
33-
env:
34-
cache-name: cache-node-modules
29+
- name: Set Yarn version
30+
run: yarn set version 4.2.2
3531

36-
# Caching options (https://github.com/actions/cache)
32+
- name: Cache yarn dependencies
33+
uses: actions/cache@v2
34+
env:
35+
cache-name: cache-yarn-dependencies
3736
with:
38-
# npm cache files are stored in `~/.npm` on Linux/macOS
39-
path: ~/.npm
40-
41-
# Key for caching the files initally
42-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
43-
44-
# Restore keys
37+
path: |
38+
.yarn/cache
39+
.yarn/unplugged
40+
.yarn/build-state.yml
41+
.yarn/install-state.gz
42+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
4543
restore-keys: |
46-
${{ runner.os }}-build-${{ env.cache-name }}-
47-
${{ runner.os }}-build-
48-
${{ runner.os }}-
44+
${{ runner.os }}-yarn-
4945
50-
# Installs all the project dependencies e.g. prettier, eslint etc via a custom project script
51-
- name: Install Node.js dependencies
52-
run: npm run allDependencies
46+
- name: Install dependencies
47+
run: yarn install
5348

54-
# Run the linting action
5549
- name: Run linters
56-
uses: samuelmeuli/lint-action@v1
57-
with:
58-
github_token: ${{ secrets.GITHUB_TOKEN }} # Authorizes the github action via a Github token which is for this repo only (Generated automatically)
59-
eslint: true # Enables eslint
60-
prettier: true # Enables prettier to prettieifer the code when commiting and spots any violations
61-
auto_fix: true # Auto fixes an prettier or eslint violations
62-
git_name: 'TheOpenMovieDB-GraphQL-Example BOT'
63-
git_email: 'AlexMachin1997@gmail.com'
64-
commit_message: 'TheOpenMovieDB-GraphQL-Example BOT has fixed an eslint/prettier issue' # Might need removing if it causes the linting to break
50+
run: yarn lint

.github/workflows/test-action.yml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ on: [pull_request, push]
88
jobs:
99
test:
1010
# Job display name
11-
name: Running the jest tests
11+
name: Running Vitest tests
1212

1313
# Runs on a Linux based OS
1414
runs-on: ubuntu-latest
1515

16-
# Run the job on 2 different versions of Node (12, 14)
16+
# Run the job on Node 20 and 23 which better support modern testing frameworks
1717
strategy:
1818
matrix:
19-
node-version: [12.x, 14.x]
19+
node-version: [20.x, 21.x, 23.x]
2020

2121
# Steps involved for this particular task
2222
steps:
@@ -30,35 +30,36 @@ jobs:
3030
with:
3131
node-version: ${{ matrix.node-version }}
3232

33-
# Cache the node_modules
34-
- name: Cache node modules
35-
uses: actions/cache@v2
33+
# Enable Corepack for Yarn
34+
- name: Enable Corepack
35+
run: corepack enable
3636

37-
# Defining the cache env config ie the key
38-
env:
39-
cache-name: cache-node-modules
37+
# Set Yarn version
38+
- name: Set Yarn version
39+
run: yarn set version 4.2.2
4040

41-
# Caching options (https://github.com/actions/cache)
41+
# Cache the yarn dependencies
42+
- name: Cache yarn dependencies
43+
uses: actions/cache@v2
44+
env:
45+
cache-name: cache-yarn-dependencies
4246
with:
43-
# npm cache files are stored in `~/.npm` on Linux/macOS
44-
path: ~/.npm
45-
46-
# Key for caching the files initally
47-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
48-
49-
# Restore keys
47+
path: |
48+
.yarn/cache
49+
.yarn/unplugged
50+
.yarn/build-state.yml
51+
.yarn/install-state.gz
52+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
5053
restore-keys: |
51-
${{ runner.os }}-build-${{ env.cache-name }}-
52-
${{ runner.os }}-build-
53-
${{ runner.os }}-
54+
${{ runner.os }}-yarn-
5455
55-
# Installs all the project dependencies e.g. prettier, eslint etc via a custom project script
56-
- name: Install Node.js dependencies
57-
run: npm run allDependencies
56+
# Install dependencies using Yarn
57+
- name: Install dependencies
58+
run: yarn install
5859

59-
# Run the react-testing-library tests
60+
# Run the Vitest tests
6061
- name: Run all tests
6162
env:
6263
OPEN_MOVIE_DB_API_URI: ${{ secrets.OPEN_MOVIE_DB_API_URI }}
6364
OPEN_MOVIE_DB_API_KEY: ${{ secrets.OPEN_MOVIE_DB_API_KEY }}
64-
run: npm run test
65+
run: yarn test

0 commit comments

Comments
 (0)