This is the backend of a project about a real-time chat application that uses the MERN stack.
To run the application, follow these steps:
- Clone the repository or download it as a ZIP file.
- In a terminal, navigate to the folder where the application is located.
- Run the
npm install
command to install all the necessary dependencies. - Run the
npm run dev
command to start the application in development mode. - Server will run on port
3000
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/'
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. |
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.