This application was built by Jenna Tucker as a learning/practice exercise in fullstack JavaScript. The frontend app connected to this backend app is currently deployed on Heroku.
This backend app is based on Mosh Hamedani's Node course. Please note that Mosh's course is several years old, so some significant changes will be necessary that may impede early learners. This version has many distinctions.
Some key changes to this version include:
- Use of updated libraries and dependencies and relevant code changes throughout code base.
- Use of
mongoose
forMongoDB
transactions to replace deprecatedfawn
library. - Requires a
MongoDB
replica set for transactions. - Significant additional Jest tests for higher test coverage.
- Use of GitHub Actions for CI (continuous integration with PR's triggering Jest tests).
- Use of Heroku for CD (changes to
main
on GitHub deploys tomain
onHeroku
).
The focus in this application was to:
- Use modern Node features and libraries
- Use contemporary Express features and best practices to build the API
- Make good use of middleware to simplify code and minimize duplication
- Establish a maintainable, clean code base
- Write enough tests to get good code coverage and encourage ongoing refactoring
- Practice TDD to gain intuitive sense of advantages in code-first and test-first workflows
- Keep learning practices as close to real-world development work as possible
This version of the application does not focus on or include:
- Jest test design that allows a pool of workers to run tests concurrently (tests are slow)
The frontend React application can also be viewed on GitHub.
The mock context for this application was a video rental shop.
Two distinct user groups would be using the website.
-
Employees wanting to assist customers in renting and returning movies.
-
Managers wanting to manage inventory and customer profiles.
The app meets an early set of necessary functionality. Based on the assumption that future features would likely be added, the following conceptual points would be useful for developers:
-
Regular employees can register as users and sign in to gain authenticated status.
-
Managers must have both registered / logged in auth status and further authorization status. This change gets made when someone with database access adds
isAdmin: true
to the employee's user document.
This backend application enforces the following levels of access, which are reflected by the React frontend application.
A site visitor who has not registered / logged in can:
- See genres
- See movies
- Register as a user
- Login as a user
A logged in user who is not admin can also:
- Logout and return to not logged in UI state
- See all customers
- See all rentals
- Search rentals
- Create new rentals
- Check in rentals
Future features might include:
- See their own account information
- Like and unlike movies (manage their own favorites list
- Change their account information, includes reset pw workflow
A logged in user who is an admin can:
- Add / update genres
- Add / update / delete movies
- Add / update / delete customers
Future features might include:
- Allow managers to grant access for users to register, so general site can be public.
To run this app in a local development environment:
- Check that a recent version of Node is installed.
- Clone the GitHub repo.
- Run
npm install
. - Set an environment variable
vidly_db
to a MongoDB database in MongoDB Atlas or on local. - Run with
node index.js
ornodemon index.js
with globalnodemon
install. - Use Thunder Client in VS Code or another
http client
to make calls tohttp://localhost:3900/api/genres
and other endpoints.
The backend application uses mongoose
for MongoDB
transactions, which require a replica set. The easiest way to get this set up for dev is to use Mongo DB Atlas free tier, but good instructions for setting up a replica set on a local machine can be found online.
- Check that a recent version of Node is installed.
- Clone the GitHub repo.
- Run
npm install
at the level of thepackage.json
file to install dependencies. - Run
npm start
. - The
.env.development
file should include:REACT_APP_API_URL=http://localhost:3900/api
.
You are welcome to contact me regarding:
- Jobs
- Alternative learning and self-learning to code
- Women and LGBTQ+ folks in tech
LinkedIn: https://www.linkedin.com/in/jenna-tucker/
Gmail: jennatuckerdeveloper[at]gmail.com