https://github.com/viveksite/chat_app_backend
Implementation of backend express and socket server for creating scalable chat application.
https://github.com/viveksite/chat_app_backend
authentication expressjs persistent-cache redis typescript websocket
Last synced: 6 months ago
JSON representation
Implementation of backend express and socket server for creating scalable chat application.
- Host: GitHub
- URL: https://github.com/viveksite/chat_app_backend
- Owner: VivekSite
- Created: 2024-08-28T04:36:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-25T08:55:20.000Z (over 1 year ago)
- Last Synced: 2025-03-10T21:50:00.919Z (about 1 year ago)
- Topics: authentication, expressjs, persistent-cache, redis, typescript, websocket
- Language: TypeScript
- Homepage:
- Size: 103 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#### This is the backend Implementation of express and socket server for creating scalable chat application.
## Dependencies
- MongoDB
- Redis
- Using bullMQ library and it uses the redis to store the queue data.
- By using queues I'm trying to reduce the time taken by DB operations. and after sending the message I'm adding the messages inot DB asynchronously.
## Run the code locally
- Clone the repo: `git clone https://github.com/VivekSite/chat_app_backend.git`.
- Install the MongoDB community version or we can also use connection string to connect with the MongoDB atlas.
- Same for Redis we can install redis server locally.
- For MacOS run `brew install redis`.
- For Linux run `sudo apt install redis-server`.
- Install all the other dependencies: `yarn install`.
- Now lets update the .env file
- copy the .env.example file `cp .env.example .env`
```
NODE_ENV=development
PORT=8080
MONGO_URI=mongodb://localhost:27017/chat_application
REDIS_URL=redis://localhost:6379
ACCESS_TOKEN_SECRET='*******************************************'
REFRESH_TOKEN_SECRET='*******************************************'
HASH_SECRET='*******************************************'
OTP_SECRET='*******************************************'
EMAIL_SENDER=example@gmail.com
EMAIL_PASS_KEY='abcd efgh ijkl mnop'
```
- Update all the secrets. we can use following command to generate the secrets:
- `openssl rand -hex 64`
- For `EMAIL_PASS_KEY` we can generate the App Password from `https://myaccount.google.com`
- Start the development server: `yarn run dev`.
we can also use npm to run the scripts