Skip to content
/ chat_app Public

🔴 This is a real time chat application built with Node.js, Express.js, Typescript, PostgreSQL, Redis.

Notifications You must be signed in to change notification settings

Bekhx/chat_app

Repository files navigation

Global node js packages

$ npm install -g [email protected]
$ npm install -g nodemon
$ npm install -g db-migrate
$ npm install -g db-migrate-pg

Important!

Before starting, install docker-compose to your machine and start docker containers:

$ docker-compose up

Environment

  • need create .env file
  • example: .env.sample

Migrate database

# Create tables
$ npm run up
# Delete tables
$ npm run down

Start project

$ npm install
$ npm run start:dev

Swagger documentation

Socket.io api

  • ws://host:port/chat
    • Headers:
      • authorization
    • Events. Listen on connect.
      • msg_receive
      • error
    • Sending messages
      • Event send message:
        • msg_send
      • Event send file:
        • msg_send:file

Examples socket.io api

Message send: type JSON

{
    "room": "2d52e031-7039-48bb-8052-056649670bd1",
    "interlocutorId": 2,
    "message": "Hi, I'm Robert Deniro"
}

Message receive: type JSON

{
    "id": 10,
    "room": "2d52e031-7039-48bb-8052-056649670bd1",
    "date": "2022-08-09T09:55:22.753Z",
    "message": "Hi, I'm Robert Deniro",
    "filePath": null,
    "from": 4,
    "to": 2
}

File send: type JSON

{
    "room": "2d52e031-7039-48bb-8052-056649670bd1",
    "interlocutorId": 2,
    "file": "text file",
    "extension": "txt"
}

File receive: type JSON

{
    "id": 9,
    "room": "2d52e031-7039-48bb-8052-056649670bd1",
    "date": "2022-08-09T08:15:59.816Z",
    "message": null,
    "filePath": "http://localhost:8050/files/a39d83eb-ad2d-4182-a270-5c576d29e340.txt",
    "from": 4,
    "to": 2
}

About

🔴 This is a real time chat application built with Node.js, Express.js, Typescript, PostgreSQL, Redis.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published