Skip to content

Sattvabit/group-demo

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

Group Room API

A NestJS backend API that allows multiple users to join shared "rooms" (groups) to unlock benefits when the group is full.

Features

Create Group Rooms: Define maximum participants and get unique room identifiers
Join Groups: Users can join available groups until they're full
Real-time Status: Check current participants, completion status, and time remaining
Auto-Expiry: Groups automatically expire after 30 minutes if not completed
JSON Storage: All data persisted in groups.json file

Quick Start

  1. NVM Use

    nvm use
  2. Install dependencies

    npm install
  3. Start the server

    npm run start:dev
  4. Test the API

    # Create a group
    curl -X POST http://localhost:3000/groups \
      -H "Content-Type: application/json" \
      -d '{"name": "Adventure Quest", "maxParticipants": 4}'
    
    # Join the group (replace GROUP_ID with actual ID)
    curl -X POST http://localhost:3000/groups/GROUP_ID/join \
      -H "Content-Type: application/json" \
      -d '{"userId": "user123"}'
    
    # Check group status
    curl http://localhost:3000/groups/GROUP_ID

API Endpoints

Method Endpoint Description
POST /groups Create a new group room
POST /groups/:id/join Join an existing group
GET /groups/:id View group status
GET /groups Get all groups

Data Structure

Each group contains:

  • id: Unique identifier (UUID)
  • name: Group name
  • maxParticipants: Maximum number of users
  • userIds: Array of joined user IDs
  • createdAt: Creation timestamp
  • isComplete: Whether group is full
  • isExpired: Whether group has expired

Business Rules

  • Groups complete when they reach maxParticipants
  • Groups expire 30 minutes after creation if not completed
  • Users cannot join the same group twice
  • No joining full or expired groups

Testing

See API_TESTING.md for comprehensive testing examples and scenarios.

Architecture

  • NestJS: Modern Node.js framework
  • TypeScript: Type-safe development
  • JSON Storage: Simple file-based persistence
  • UUID: Unique group identifiers
  • CORS Enabled: Cross-origin request support

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published