Skip to content
πŸ“‘ API for chat application for DogeCodes React course
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
controllers Better config for Prettier Oct 15, 2018
.gitignore Add .gitignore. Remove yarn.lock Feb 7, 2018
.prettierrc.json Better config for Prettier Oct 15, 2018


Chat API

API for chat application for DogeCodes React course.

This is a simple API server that implements a logic required to correct work of DogeCodes React Chat application.


To run this server localy you need to have these requirements:


Use following commands to run this API-server localy:

git clone
cd react-chat-api
npm install
npm run start:dev # or `npm start` for production

Note: Don't forget to start mongod for connection to database.


Current version of API is v1, so you need to specify the version of API before every route. For example:



Here's the map of API's HTTP routes:

  • / β€” routes related to authentication.
    • /signup POST β€” create new user with username and password.
    • /login POST β€” log user in with username and password.
    • /logout GET β€” log out active user.
  • /users β€” routes related to users.
    • /users GET β€” retrieve data about all users.
    • /users/me GET β€” retrieve my user's data.
    • /users/me POST β€” update my user's information (username, firstName, lastName and city).
    • /users/:id GET β€” retrieve information about user with specific :id.
  • /chats β€” routes related to chats.
    • /chats GET β€” retrieve information about all chats.
    • /chats POST β€” create new chat with specified title.
    • /chats/my GET β€” get list of all user's chats.
    • /chats/:id GET β€” get chat's information with messages by specific chat's :id.
    • /chats/:id POST β€” send new message to chat with specific :id.
    • /chast/:id DELETE β€” delete chat with specific :id. Only creator of the chat can delete it.
    • /chats/:id/join GET β€” join chat with specific :id.
    • /chats/:id/leave GET β€” leave chat with specific :id.

If you're using Insomnia for debugging APIs, you can download a workspace backup:

Download .zip


This API also emmits and listens some events.

Sockets connection requires authentication with access-token. Here's an example of establishing sockets connection:

import SocketIOClient from '';

socket = SocketIOClient('path/to/api', {
  query: {
    token: '...your access-token here...',

Here's the list of events:


  • new-message β€” emmited when someone sends new message to specific chat.
  • new-chat β€” emmited when someone creates new chat.
  • deleted-chat β€” emmited when someone deletes a chat.


  • connection β€” connection of client.
  • mount-chat β€” mount a client to listen for messages in chat with specific :chatId.
  • unmount-chat β€” unmout a client from listening for messages in chat with specific :chatId.
  • send-message β€” send message with content to chat with


MIT Β© Denys Dovhan

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.