Skip to content

JefersonLC/api_realtime-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Realtime Chat

This is the backend of a project about a real-time chat application that uses the MERN stack.

How to Install and Run

To run the application, follow these steps:

  1. Clone the repository or download it as a ZIP file.
  2. In a terminal, navigate to the folder where the application is located.
  3. Run the npm install command to install all the necessary dependencies.
  4. Run the npm run dev command to start the application in development mode.
  5. Server will run on port 3000

Environment

Before running the application it is necessary to configure the environment variables

// .env

PORT=3000

DATABASE_URL='mysql://root:admin@localhost:3306/mydb'

GOOGLE_CLIENT_ID=/* Your Google client id */
GOOGLE_CLIENT_SECRET=/* Your Google client secret */
GOOGLE_CALLBACK_URL='http://localhost:3000/api/auth/google/callback'

SECRET_KEY='MyS3creTK3y'

CLIENT_APP_URL='http://localhost:5173/'

Enpoints

Method Endpoint Description
GET /api/auth/google Returns the page to select the google account.
GET /api/auth/google/callback Redirects to our client application sending the authentication token as query parameter.
GET /api/profile Requires an authentication token.
Returns the session data of the authenticated user.
GET /api/messages Requires an authentication token.
Returns all messages registered in the database.
You can send the query parameters limit and offset for pagination, but it is not required.
POST /api/messages Requires an authentication token.
Creates a message and returns it.

Contributions

I appreciate contributions and suggestion to improve my API. If you have any ideas or encounter any issues, feel free to open an issue or submit a pull request.