A messaging App created with Node.js, MongoDB and Socket.io.
Clone this(back-end) repository
git clone https://github.com/besimgurbuz/messaging-app-next.git
After cloning you should change .env.sample
file name to .env
file and paste correct secrets which I send you:
cd messaging-app-next
mv .env.sample .env
Now you are ready to clone front-end. Don't forget both of these repos should be in the same directory. So:
cd ..
Clone front-end repository
git clone https://github.com/besimgurbuz/messaging-app-ui.git
You should clone both of these repositories into the same directory.
There are same docker-compose.yml
files both of these repos. You can use any of these docker-compose.yml
file for running. But first you should move docker-compose.yml
file into the upper directory which includes both repositories.
$ mv ./messaging-app-next/docker-compose.yml ./docker-compose.yml
$ ls
messaging-app-next
messaging-app-ui
docker-compose.yml
In this directory run:
docker-compose up
After docker-compose install and run our both back-end and front-end now you can open localhost:4200.
Another important note I recommend you to open app in Chrome or close any cookie & local storage browser blocker.
git clone https://github.com/besimgurbuz/messaging-app-next.git
Create .env
file. And paste secrets which I send.
$ cd messaging-app-next
$ mv .env.sample .env
# You should be in the messaging-app-next folder
$ pwd
$YOUR_CLONE_DIRECTORY/messaging-app-next
# Installing dependencies
$ npm install
# Running
$ npm run start
# With nodemon
$ npm run dev
Now open another terminal and clone front-end repository.
$ git clone https://github.com/besimgurbuz/messaging-app-ui.git
$ cd messaging-app-ui
$ npm install
$ npm run start
Now you are ready to open app. Horay!!
Available endpoints in application
-
GET
/
- Response
Endpoint responds with json{ "message": "APP is up and running!" }
- Response
-
GET
/api/v1
- Response
Endpoint responds with json{ "message": "API - 🤘" }
- Response
-
POST
/api/v1/login
- Expected Request Body
- username
- password
{ "username": "username", "password": "password" }
- Response
Endpoint responds with in json format. If given crediantials are correct sends:- token: A token which created and assigned by JWT.
- user: A object which contains user's username and email.
{ "token": "JWT", "user": { "username": "username", "email": "example@email.com" } }
- Errors
400
- Request body validations:- username and email should be given
400
- There is no user with this username - $username500
- Cannot logged in. Try again.
- Expected Request Body
-
POST
/api/v1/register
- Expected Request Body
- username
- password
{ "username": "username", "email": "example@email.com", "password": "password" }
- Response
Endpoint responds with in json format. If given crediantials are correct creates new user and sends saved user data:{ "blockedList": [], "username": "username", "email": "example@email.com" }
- Errors
400
- Request body validations:- username must be between 5 and 20 characters
- email must be a valid email
- password must be between 8 and 50 characters
400
- There is already a registered user with this email - $email400
- There is already a registered user with this username - $username500
- User cannot be saved
- Expected Request Body
-
GET
/api/v1/chat
- Expected Headers
- 'Auth-Token': JWT_TOKEN
- Response
Endpoint response in json format. If given token is found it sends user's chats data. - Errors
400
- Access Denied
- Expected Headers
-
GET
/api/v1/chat/:id
- Expected Headers
- 'Auth-Token': JWT_TOKEN
- Expected Parameters
- id - Chat id
- Response
Endpoint response in json format. If given token is found it sends user's chats data. - Errors
400
- Access Denied
- Expected Headers
-
POST
/api/v1/chat
- Expected Request Body
- receiver
{ "receiver": "receiver" }
- Response
Endpoint responds with in json format. If the username is verified and the receiver is a user and doesn't already exist, they'll create a new chat.{ "subscribers": ["username", "receiver"], "lastActivity": "2020-09-22T13:28:29.043Z", "messages": [] }
- Errors
400
- Please enter a user who is not yourself400
- Unknown receiver400
- Sorry you cannot chat with this user, he/she blocked you..500
- Chat cannot be created'
- Expected Request Body
-
POST
/api/v1/block-user
- Expected Request Body
- block
{ "block": "block_username" }
- Response
Endpoint responds with in json format. If the username is verified and the block_usernmae is a user and doesn't already blocked, updates verified usersblockList
.{ "message": "User blocked." }
- Errors
400
- The user to be blocked was not found on the system.400
- You already blocked this user400
- Body sould contain a username who is gonna be blocked.500
- User cannot be blocked.
- Expected Request Body
besimgurbuz - besimgurbuz.dev