Skip to content

A backend server providing Push server upgrade using Web Sockets.

Notifications You must be signed in to change notification settings

VertikaJain/node-express-ts-chat-app

 
 

Repository files navigation

Real-Time Secure Chat Application using Web Sockets

  • The real-time implementation of this Chat application is done using Web Sockets development technique.
  • For End-to-end Encryption (E2EE), I have made use of the Signal Protocol at the client side.
  • Refer this link for downloading the Client Application.

Please Note: This application is completely for experimental purpose. Since E2EE is not yet applicable on browsers, I have used local storage of clients for storing the respective decrypted messages and prekey bundles. Also, the flow of encrypted messages can be seen in the Browser's console-> Network->Filter WS-> Header & messages.

Technology Stack

  • NodeJS
  • Express
  • TypeScript
  • MongoDB (Setup can also be done using docker - optional)
  • Web Sockets

Steps for SetUp

npm start 
  • Download this repo (backend/server) and run the following commands in terminal -
npm install
npm run build
npm run seed
nodemon start

It is important to follow the above commands as the application won't work without the dependencies and the database setup.

Also, the seed.js script enables you to setup the database automatically. Alternate option is to create the Database manually for experimental purpose.

Web Sockets (Push Server) as a Service

  • HTTP protocol upgrade to websocket (101 status code)
import * as http from ‘http’

export default class WebSockets {
   	public static wsServer: any
   		  static init(server: http.Server): void {
       		const WebSocketServer = require("websocket").server
         this.wsServer = new WebSocketServer({
              "httpServer": server
         })
    }
}
wsServer.on(‘request',request => {
   const connection = request.accept(null, request.origin);

   connection.on(‘message’, message => {
     console.log('Received Message:', message.utf8Data);
     connection.sendUTF('Hi this is WebSocket server!');
   });
   
   connection.on('close',(reasonCode, description) => {
       console.log('Client has disconnected.');
   });
});

Add ons

  • Apidoc integrated for better api documentation
  • Dummy cron job
  • Dummy controller, router, models configured.
  • Basic JWT setup.
  • Development and production environment setup for easy of use

Resources

PRs and issues are most welcome

About

A backend server providing Push server upgrade using Web Sockets.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.7%
  • JavaScript 2.3%