Skip to content

A hands-on project from Udemy: The Complete Node.js Developer Course (2nd Edition)

Notifications You must be signed in to change notification settings

rubychi/udemy-chatapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatApp

Build Status Coverage Status Known Vulnerabilities

A hands-on project from Udemy: The Complete Node.js Developer Course (2nd Edition)

udemy-chatapp

Features

  • Join a specified room to chat

  • Send the geographical location to other users in the room if permission is granted

  • Automatically scroll down upon receiving a new message

  • Responsive web design (RWD)

Custom Features

  • Colorized the user and the administrator's messages to set them apart from the rest

  • Save text messages in the cloud so that user won't miss any messages of the day

  • Add nyc (the command-line-client for Istanbul) for checking the test coverage and generating the test report

Getting Started

Follow the instructions below to set up the environment and run this project on your local machine

Prerequisites

  • Node.js
  • MongoDB

Installing

  1. Download ZIP or clone this repo
> git clone https://github.com/rubychi/udemy-chatapp.git
  1. Start a MongoDB server running on port 27017
> mongod
  1. Install dependencies via NPM
> npm install
  1. Create your own config.json to securely store credentials inside \server\config
{
  "test": {
    "PORT": "3000",
    "MONGODB_URI": "mongodb://localhost:27017/ChatAppTest"
  },
  "development": {
    "PORT": "3000",
    "MONGODB_URI": "mongodb://localhost:27017/ChatApp"
  }
}
  1. Back to the root directory and type the below command to start the server and the service
> npm run dev-watch
  1. See it up and running on http://localhost:3000

Running the tests

If you just want to run the tests, type in the command below

> npm run test-watch

For checking the test coverage and generating the html report:

> npm run test-report

Deployment

  1. Deploy to Heroku
> heroku create
> git push heroku master
> heroku addons:create mongolab:sandbox
  1. Set up config vars
> heroku config:set
  MONGODB_URI=[Your MongoDB URI]
  1. Open the app in the browser
> heroku open

Alternatively

Click this button to deploy to your Heroku server

Deploy

Built With

Frontend

  • jquery
  • mustache

Backend

  • express
  • mongodb
  • mongoose
  • compression
  • helmet

Utils

  • socket.io
  • lodash
  • moment

Testing Frameworks

  • mocha
  • nyc

Course Notes

  • Send an event to everybody in the room 'The Office Fans'
io.emit -> io.to('The Office Fans').emit
  • Send an event to everybody in the room 'The Office Fans' except for the current user
socket.broadcast.emit -> socket.broadcast.to('The Office Fans').emit
  • Send an event to a specific user
socket.emit