Skip to content

jumacro/Chatify

Repository files navigation

Nodejs Chat Server - ES6 and Promise

Overview

This is a API and chat application using ES6 and Express with Code Coverage and JWT Authentication. Inspired from Kunal Kapadia ES6 boilerplate. Follows Airbnb's Javascript style guide.

Code Features

Feature Summary
ES6 via Babel ES6 support using Babel.
ES6 Class based approach ES6 classes - Jabascript MDN.
Code Linting JavaScript code linting is done using ESLint - a pluggable linter tool for identifying and reporting on patterns in JavaScript. Uses ESLint with eslint-config-airbnb, which tries to follow the Airbnb JavaScript style guide.
Auto server restart Restart the server using nodemon in real-time anytime an edit is made, with babel compilation and eslint.
Debugging via debug Instead of inserting and deleting console.log you can replace it with the debug function and just leave it there. You can then selectively debug portions of your code by setting DEBUG env variable. If DEBUG env variable is not set, nothing is displayed to the console.
Promisified Code via bluebird All the code is promisified and even so our tests via supertest.
JWT Authentication Authentication is done using jsonwentoken and passport-jwt.
Secure app via helmet Helmet helps secure Express apps by setting various HTTP headers.
Uses yarn over npm Uses new released yarn package manager by facebook. You can read more about it here
  • CORS support via cors
  • Uses http-status to set http status code. It is recommended to use httpStatus.INTERNAL_SERVER_ERROR instead of directly using 500 when setting status code.
  • Has .editorconfig which helps developers define and maintain consistent coding styles between different editors and IDEs.

Chat Features

  1. Support for group chat
  2. Support for private chat
  3. Delivery and Receipt notifications
  4. Disconnect handling
  5. Message pagination and compatibility with Window read view (Mobile/Desktop)

Getting Started

Clone the repo:

git clone https://github.com/jumacro/Chatify.git
cd chatify

Install yarn:

npm install -g yarn

Install dependencies:

yarn

Start server:

# Start server
yarn start

# Selectively set DEBUG env var to get logs
DEBUG=chatify:* yarn start

Refer debug to know how to selectively turn on logs.

Lint:

# Lint code with ESLint
yarn lint

# Run lint on any file change
yarn lint:watch

Other gulp tasks:

# Wipe out dist and coverage directory
gulp clean

# Default task: Wipes out dist and coverage directory. Compiles using babel.
gulp
Deployment
# compile to ES5
1. yarn build

# upload dist/ to your server
2. scp -rp dist/ user@dest:/path

# install production dependencies only
3. yarn --production

# Use any process manager to start your services
4. pm2 start dist/index.js

API logging

Logs detailed info about each api request to console during development.

Error logging

Logs stacktrace of error to console along with other details.

To do

  1. Class approach for Socket Server
  2. Audio and Video Support for chat
  3. Chat Media controller