Movie / TV Info app based on TMDB API
Website: https://mtvi.netlify.app
This project was created to learn how to build SPA (single page application) with technologies such as React, TypeScript, and Netlify.
- Netlify CLI
- Webpack
- TypeScript
- Babel + core-js
- Eslint + Prettier
- React
- React Router
- React Query
- Axios + localForage
- Material-UI
-
Clone or download the repo.
-
The following Node.js version is required for this project, the recommended way to install a specific version is via nvm, nvm-windows or another Node.js version manager:
^14.0.0
-
Install dependencies using the following command in your project directory, requires Node.js and npm (which comes with Node.js).
$ npm install
-
Create Netlify account.
-
There are several options how to create a project with Netlify, but the most robust one is the Netlify CLI which is used in this project, follow these steps:
-
Use continuous deployment (requires GitHub account) or manual deploys.
For continuous deployment, it is possible to choose which branches will trigger the deployment.
-
Set the following environment variables to 'Site settings > Build & deploy > Environment > Environment variables':
For TMDB API (requires account) set
TMDB_API_KEY
as a name and your given key as a value.For serverless functions runtime set
AWS_LAMBDA_JS_RUNTIME
as a name andnodejs14.x
as a value. -
Use the following npm scripts which are aliases for Netlify Dev and Netlify CLI commands:
netlify:start
- start a local dev server for the build tool you’re using.netlify:preview
- deploy to a unique draft URL for previewing and testing.netlify:deploy
- do a production deploy to your main site URL (typically used for manual deploys).
The src
folder contains application source code, which I distinguish as follows:
-
'Local' code is located right in the
src
folder and is used only once inApp.*
orindex.*
files. For exampleroutes
folder andFooter
component are 'local'. -
'Shared' code is located in the
shared
folder. This folder contains only code that is needed in more than one place, it can be components, hooks, utils, etc. -
'Global' code is also located in the
src
folder. It is usually best to keep code that is only relevant for the corresponding feature / module closer to that feature / module, but sometimes it is more convenient to keep certain code in one 'global' folder / file. For example, in this project, theapi
folder is 'global'.
It's a very simple structure, but enough for this project.
The commit messages are written according to the Conventional Commits specification (mostly).
Node.js versions are specified in several places:
- In the Netlify UI
AWS_LAMBDA_JS_RUNTIME
env variable must be set for serverless functions runtime. - In the
.nvmrc
file, so that Netlify knows which version of Node.js it should use to build your site, can also be set as an env variable in the Netlify UI. - In the
package.json
engines
field whichnode/no-unsupported-features/*
rules use for linting, can also be overwritten by each rule.
- Create a home page.
- Internationalization.
- Authentication with TMDB (to be able to rate movies / series, ect.).
- Write tests (not a big project, but with the above enhancements and for practice it could be worth it).