- Added GraphQL mutations and subscriptions for joining and leaving rooms - Implemented room member tracking and display in room list - Added leave room confirmation and error handling in chat room - Updated room list and chat room components with new interaction features - Improved UI with member badges, join/leave buttons, and error messages - Enhanced room query to include member information |
||
|---|---|---|
| .. | ||
| prisma | ||
| src | ||
| .dockerignore | ||
| .gitignore | ||
| Dockerfile | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
Unreal Chat API
The backend API for the Unreal Chat application, built with Apollo Server, GraphQL, and Prisma.
Features
- GraphQL API with Apollo Server
- Real-time subscriptions for messages and rooms
- Prisma ORM with MariaDB
- User authentication
- Chat rooms and messaging
Getting Started
Prerequisites
- Node.js (v18 or later)
- npm (v10 or later)
- MariaDB or MySQL
Installation
- Install dependencies:
npm install
- Set up the database:
Make sure you have MariaDB running and update the connection string in prisma/.env if needed.
- Run Prisma migrations:
npm run prisma:migrate
- Start the development server:
npm run dev
The API will be available at http://localhost:4000/graphql.
Available Scripts
npm run dev- Start the development servernpm run build- Build the applicationnpm run start- Start the production servernpm run prisma:generate- Generate Prisma clientnpm run prisma:migrate- Run Prisma migrationsnpm run prisma:studio- Open Prisma Studio
API Documentation
Authentication
For development purposes, authentication is simplified. In a production environment, you would use JWT tokens.
GraphQL Schema
The GraphQL schema includes the following main types:
User: Represents a user in the systemRoom: Represents a chat roomMessage: Represents a message in a chat room
Queries
me: Get the current userusers: Get all usersuser(id: ID!): Get a user by IDrooms: Get all public roomsroom(id: ID!): Get a room by IDmessages(roomId: ID!): Get messages in a room
Mutations
register(email: String!, username: String!, password: String!): Register a new userlogin(email: String!, password: String!): Login a usercreateRoom(name: String!, description: String, isPrivate: Boolean): Create a new roomjoinRoom(roomId: ID!): Join a roomleaveRoom(roomId: ID!): Leave a roomsendMessage(content: String!, roomId: ID!): Send a message to a room
Subscriptions
messageAdded(roomId: ID!): Subscribe to new messages in a roomroomAdded: Subscribe to new rooms