Giter VIP home page Giter VIP logo

node-vidly-backend's Introduction

Node Express Video Rental App Backend

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 for MongoDB transactions to replace deprecated fawn 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 to main on Heroku).

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.

Application Context Overview

The mock context for this application was a video rental shop.

Two distinct user groups would be using the website.

  1. Employees wanting to assist customers in renting and returning movies.

  2. Managers wanting to manage inventory and customer profiles.

Context to Concept Mapping Auth And Admin

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:

  1. Regular employees can register as users and sign in to gain authenticated status.

  2. 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.

Key Features By Auth & Admin Status

This backend application enforces the following levels of access, which are reflected by the React frontend application.

1. No Auth & No Admin status

A site visitor who has not registered / logged in can:

  • See genres
  • See movies
  • Register as a user
  • Login as a user

2. Auth & No Admin status

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

3. Auth & Admin status

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.

Local development

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 or nodemon index.js with global nodemon install.
  • Use Thunder Client in VS Code or another http client to make calls to http://localhost:3900/api/genres and other endpoints.

Important Note:

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.

Local development with local, development backend Node application

For the frontend:

  • Check that a recent version of Node is installed.
  • Clone the GitHub repo.
  • Run npm install at the level of the package.json file to install dependencies.
  • Run npm start.
  • The .env.development file should include: REACT_APP_API_URL=http://localhost:3900/api.

Developer Contact Info

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

node-vidly-backend's People

Contributors

jennatuckerdeveloper avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.