Backend app for REST API and WebSocket that serves a real-time one-to-one messaging application.
- Node.js@18 and up
- [email protected] and up
- Typescript - strongly typed programming language
- Node.js - JS runtime enviroment
- Express.js - Node.js web application framework
- Mongo - cross-platform document-oriented database
- Mongoose - schema-based ODM to model application data
- Socket.io - event-driven library for real-time web applications
1. First of all you need to clone the repository from github:
https://github.com/GeekoIsaGeek/communicator-back
2. Next step requires you to run npm install in order to install all dependencies.
npm install
3. Now we need to set our env file. Go to the root of your project and execute this command.
cp .env.example .env
And now you should provide .env file all the necessary environment variables:
PORT=
DB_URI=
TOKEN_SECRET=
CLIENT_APP_URL=
You can run development server by executing:
npm run serve
├─── readme
├─── src
│ ├─── config
│ ├─── controllers
│ ├─── middleware
│ ├─── models
│ ├─── routes
│ ├─── socket-handlers
│ ├─── types
│ - server.ts
├─── storage
- .env
- package.json
- README.md
- tsconfig.js
Every listed endpoint is protected from unauthorized access (except ones for authentication). In the context of this application, "connections" are users with whom an authorized user has ever had a chat.
Authenticated user
/user
Registered Users
/users
Chat messages
/messages requires query params: sender, receiver
Connected users
/connections
Login
/login
Registration
/register
Remove user from connections
/connections/remove requires connectionId
Remove all messages from chat
/messages/remove requires query params: sender, receiver