Skip to content

Final Bootcamp Project - Built purely in Node JS

Notifications You must be signed in to change notification settings

duquejo/Bootcamp-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to my Node JS Final Project!

Chilltime Logo

Chilltime Video App

Version: v1.1.0

made-with-javascript made-with-nodejs Project Version

JWT Compatible

Project dependencies and development dependencies

  • Dependencies

    • axios (0.22.0): HTTP REST Client for the frontend requests.
    • bootstrap (5.1.2): Frontend framework for quickly sites building (Mobile-first, responsive).
    • bad-words (3.0.4): Analize strings and check their profanity
    • bcryptjs (2.4.3): Encrypt and validates password strings.
    • express (4.17.1): Server management module.
    • cookie-parser (1.4.5): Handles User sessions in the app using server cookies.
    • ffmpeg-static (4.4.0): Static ffmpeg dependencies based in the host OS.
    • ffprobe-static (3.0.0): Static ffprobe dependencies based in the host OS.
    • fluent-ffmpeg (2.1.2): A fluent ffmpeg API for video manipulation and processing.
    • hbs (4.1.2): Handlebars mustache template frontend system.
    • moment (2.29.1): Time manipulation and datatime management library.
    • mongodb (4.1.2): Documental JSON Database (NoSQL)
    • mongoose (6.0.8): MongoDB speciallized ODM library.
    • multer (1.4.3): File handling/Uploading module.
    • node-sass-middleware (0.11.0): Node JS middleware for compiling and building CSS through SASS/SCSS files.
    • validator (13.6.0): Allows backend to manage complex validations.
  • Development dependencies

    • env-cmd: (10.1.0): Enviroment variables module.
    • jest: (27.2.5): Node JS Testing suite with mocking support.
    • nodemon (2.0.13): Server demon for file changes listening and live server updating.
    • supertest: (6.1.6): Boosts Jest with asyncronous tasks and more HTTP Request testing support.

Quick links for the Node JS Bootcamp memories & public projects.

Node JS package.json config

The automated Node JS commands are start, seed, dev, and test:

  ...
  "scripts": {
    "start": "node src/app.js",
    "seed": "env-cmd -f ./src/config/.env node ./src/utils/seed.js",
    "dev": "env-cmd -f ./src/config/.env nodemon ./app.js -e js,hbs",
    "test": "env-cmd -f ./src/config/test.env jest --watch --runInBand"
  },
  ...

These commands have a reason in specific, the command start is for production purposes, seed is for the first database run and also app cleanse tasks, dev por development purposes, and test for running automated unit tests over the defined app routes.

It's Chilltime setup

As I said in the first section, the app has a .env config support... So, if you want to run locally/our server this project, you need to follow this steps first.

  1. Install NPM dependencies & development dependencies. npm i (You need to have installed Node in the host server).
  2. Copy/paste the .env.example file located in src/config/ directory and rename it as .env
  3. Complete the following fields:
# Server variables

APP_PORT="Express Listening Port or 3000 by default"

MONGODB_URL="MongoDB URL, with leading 'mongodb://' config string."
MONGODB_USER="MongoDB User"
MONGODB_PASSWORD="MongoDB Password"

UPLOADS_DIR= "Custom app uploads directory, by default is 'public/uploads"

JWT_SECRET="Secret JWT Key String"
  1. Run npm run seed to populate the users and some categories collection in the MongoDB database. It will include a development user for you.
  2. Execute npm run dev for quick development deployment.
  3. Navigate over http://localhost:3000 (Or your custom port) and try to login here: http://localhost:3000/login (Or your custom port) with this demo credentials:

User 1:
Username: demo
Email: [email protected]
Password: demo123*

User 2:
Username: demo2
Email: [email protected]
Password: demo123*

It's Chilltime test setup

If you want to run the automated unit tests, continue with the following steps:

  1. Install NPM dependencies & development dependencies. npm i (You need to have installed Node in the host server).
  2. Copy/paste the .env.example file located in src/config/ directory and rename it as test.env.
  3. Complete the following fields:
# Server variables

APP_PORT="Express Listening Port, It's recommended to use 0"

MONGODB_URL="MongoDB Test URL, with leading mongodb:// config string."
MONGODB_USER="MongoDB User"
MONGODB_PASSWORD="MongoDB Password"

UPLOADS_DIR= "Check step 4 or public/uploads"

JWT_SECRET="Secret JWT Key String"
  1. If you want to run tests without removing the uploaded uploads, please configure UPLOADS_DIR in the test.env file, or just use public/uploads like a development suite.
  2. Take care if you want to run the automated tests in the main dev/prod uploads directory, that's because these testing tasks clean the whole database constantly.
  3. Execute npm run test for quick testing deployment.

Notes about ffmpeg and ffprobe

FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.

This video codecs are supported in my app, I'm using this for the auto video thumbnail generation. But.. It can open up the possibilities to make a LOT of things with the uploaded videos:

  • Video standarization: Convert all sources to a general one... (Web friendly standard - Like webm).
  • Video compressing & optimization.
  • Video quick view (Like a gif or short video) support.

The 'fmpeg-static' and 'ffprobe-static' dependencies enable the native support for quickly implementation. It will analize the current OS and will install the best option.

Future updates/improvements

  • Users management.
  • User register
  • User avatar uploading support.
  • Video Standarization.
  • Video Optimization.
  • Quick Peek Video support (Like youtube).
  • Refactor Categories & Videos model relationship.
  • Tests coverage over 100% (Including cookie unit tests).
  • Commenting system support.
  • Use React/Angular/Vue to serve the frontend.