A RESTful API for movie lovers that want to be able to access information about different movies. It’s the M, E and N from the MERN stack and connects to a database that is hosted on MongoDB Atlas.
Find the R (MoviePool Client) here.
This RESTful API has been built split into several tasks for Achievement 2 and 3 in Career Foundry's Full-Stack Web Development Program. The non-relational database has been built by me and is hosted on MongoDB Atlas.
- MERN stack must be used (MongoDB, Express, Node.js)
- API
- must use RESTful architecture
- must at least use commonly used HTTP methods (
POST
,GET
,PUT
,DELETE
), following CRUD - must at least use 3 middleware functions
- must be tested in Postman - web or app
- business logic must be modeled with Mongoose
- must include user authentication and authorization
- must include data validation logic
- must meet data security regulations
- must be deployed to either Heroku or Render
- must use JSDoc for technical documentation (see feature branch)
- the database
- must be non-relational
- must contain two collections:
users
movies
with various documents - must be build using MongoDB (MongoDB Community Server, Mongo Shell, MongoDB Database Tools) with "code first" approach: first design endpoints, then design database
- must be hostet on MongoDB Atlas
users
- new users
- are able to sign up
- userName
- password
- birthDate
- are able to sign up
- registered users
- are able to login
- userName
- password
- are able to logout
- are able to update their personal information
- userName
- password
- birthDate
- favoriteMovies
- have access to information about movies
- are able to add a movie to their list of favorite movies
- are able to delete a movie off of their list of favorite movies
- are able to delete their account
- are able to login
movies
- return a list of all movies
- return data about a single movie by title
- title
- description
- genre
- genreName
- description
- director
- directorName
- bio
- birthDate
- deathDate
- imagePath
- featured
- return data about a genre by genreName (e.g. "Thriller")
- return data about a director by directorName
- bio
- birthDate
- deathDate
- HTML
- JavaScript
- Node.js - https://nodejs.org/en/
- MongoDB - to build the non-relational database which is hosted on MongoDB Atlas
brew tap mongodb/brew
to install the MongoDB custom 'tap'brew install mongodb-community
- will install the latest available production release of MongoDB Community Server, Mongo Shell, MongoDB Database Tools
- MongoDB Community Server
- any time one wants to interact with the database, view the app or use Mongo Shell
- Mongo Shell
- start the MongoDB Community Server, you need to have it running any time you want to interact with your database, view your app, or use the Mongo shell
brew services start mongodb-community
- run
mongosh
- exit with
exit
orquit()
- stop the MongoDB Community Server
brew services stop mongodb-community
- https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/
- https://github.com/mongodb/homebrew-brew
- start the MongoDB Community Server, you need to have it running any time you want to interact with your database, view your app, or use the Mongo shell
bcrypt
for password hashingbody-parser
to read the body of HTTP requests to get additional information not stored in the request URLscors
to control which domains have access to the APIexpress
server-side minimalist programming framework for Node.jsexpress-validator
for server-side validationjsonwebtoken
for token-based authentication, via Bearer tokenmongoose
for defining the data schema, for data modeling the business logic, for creating the models/the business logic layer and for connecting to the database (to install Mongoose, the MongoDB Server must be up)morgan
as soon as the server is started, this will log time and date of the request, request method, URL path, response code, number of characters the response sent back to the terminal and to thelog.txt
you find in the projectpassport
,passport-jwt
,passport-local
for authentication and authorizationuuid
to generate unique IDs - not used at the moment
dotenv
to create an environment variable to connect to the remote MongoDB Atlas URInodemon
for watching for any changes in the code and automatically restarting the serverjsdoc
for technical documentation (see feature branch)
"node": ">=14 <15"
explicitely set due to a MongoDB error in connection to hosting on Render, see here: Specifying a Node version
- clone project
cd
into project- run
npm install
- beware of the
.env
file that is not committed; when cloning, you won't have theCONNECTION_URI
variable and you won't have the assigned value (the MongoDB URI) so the project won't work
cd
into correct directory and start the server withnpm run dev
- this will start the project on
http://localhost:8080/
- stop the server with
ctrl c
cd
into correct directory and start the server withnode index.js
- for each change in code, you need to manually exit and restart the server
- stop the server with
ctl c
cd
into correct directory and start the server withnpm run start
- swagger doc will be on
http://localhost:8080/documentation
- stop the server with
ctl c
- https://www.postman.com/
cd
into correct directory and start Node.js repl terminal withnode index.js
ornpm run dev
if you use Nodemon- go to Postman (either browser or app)
- test the endpoints
- as
jsdoc
is installed locally vianpm install --save-dev jsdoc
to trigger build, run
./node_modules/.bin/jsdoc yourJavaScriptFile.js
- ONLY WORKS IN FEATURE BRANCH!
- (if installed globally, you could run
jsdoc yourJavaScriptFile.js
)
- https://github.com/OAI/OpenAPI-Specification/releases
- https://editor.swagger.io/
- https://petstore.swagger.io/?_ga=2.223173272.2032246104.1680158771-1614811837.1678349012#/user/deleteUser
- https://swagger.io/docs/specification/basic-structure/
- https://swagger.io/tools/swagger-ui/
- https://swagger.io/docs/open-source-tools/swagger-ui/usage/installation/
- https://www.npmjs.com/package/swagger-ui-express
- https://www.npmjs.com/package/yaml
- API documentation with Postman - this one is a bit older. https://www.youtube.com/watch?v=Ayo_KdLLcTA
- API Documentation | The Exploratory - this one is a bit newer https://www.youtube.com/watch?v=XNVo9WkCoak
- old (!) documentation / WIP https://documenter.getpostman.com/view/26201251/2s93RRvDAq