The Group Chat NodeJS API Service provides a comprehensive set of APIs to support a group messaging service. This service allows users to create accounts, form groups, send messages, and manage group memberships.
- User Authentication: Login and logout functionalities with session management.
- Group Management: Create, update, delete groups, and manage group memberships.
- Messaging: Send, receive, like, and dislike messages within groups.
- User Management: Retrieve user information and search users.
- GET /health: Verify if the service is running.
- POST /auth/{userName}/login: Authenticate a user and start a session.
- POST /auth/{userName}/logout: Logout a user and end the session.
- GET /admin/users: Retrieve the current admin's details.
- POST /admin/users: Create a new user.
- GET /users: Get details of the current logged-in user.
- GET /users/info: Retrieve information about multiple users by email IDs.
- GET /users/search: Search for users by a text query.
- GET /groups: List all groups associated with the user.
- POST /groups: Create a new group.
- PUT /groups/{groupId}: Update a specific group's details.
- DELETE /groups/{groupId}: Delete a specific group.
- GET /groups/{groupId}/members: Get members of a specific group.
- PUT /groups/{groupId}/members: Add members to a group.
- DELETE /groups/{groupId}/members: Remove members from a group.
- GET /groups/{groupId}/messages: Retrieve messages from a group.
- POST /groups/{groupId}/messages: Send a message to a group.
- POST /groups/{groupId}/messages/{messageId}/like: Like a message.
- POST /groups/{groupId}/messages/{messageId}/dislike: Dislike a message.
- Node.js: Ensure Node.js is installed.
- pnpm: Install Node Package Manager.
- MongoDB: Set up a MongoDB database.
- Clone the repository:
git clone https://github.com/pavan555/group-chat.git- Navigate to the project directory:
cd group-chat- Install dependencies:
pnpm install --shamefully-hoistStart the service locally:
pnpm server:startAccess the API at http://localhost:3000.
Ensure to configure the following environment variables:
PORT=3000
DB_CONNECTION_URL=provide DB connection URL
DB_NAME= provide db name
DB_USER= provide db user
DB_PASSWORD= provide db password
DB_SSL_ENABLED=true
DB_SERVER_SELECTION_TIMEOUT=20000
DB_MAX_POOL_SIZE=5
AUTH_TOKEN= This will be used to authenticate admin APIs
JWT_SECRET=This is a secret which is used to validate & generate JWT tokens
JWT_ALGORITHM=algorithm for generation/validation of JWT
Currently admin user is pre-populated with this following details if not exists in connected mongoDB
{
"_id": "66b47ff577c995118548f41e",
"emailId": "admin@gmail.com",
"password": "samplePassword",
"role": "ADMIN",
"name": "Admin User",
"admin": true
}