From a912ce007159282eef688c5a03d3e2e0b9e0dc5e Mon Sep 17 00:00:00 2001 From: inteee Date: Mon, 27 Jul 2026 12:29:25 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20[BE-20]=20Waitlist=20=E2=80=94=20queue?= =?UTF-8?q?=20members=20for=20fully-booked=20workspaces=20and=20notify=20o?= =?UTF-8?q?n=20availability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/waitlist/dto.ts | 4 ++++ backend/src/waitlist/waitlist.controller.ts | 20 +++++++++++++++++++ backend/src/waitlist/waitlist.module.ts | 10 ++++++++++ backend/src/waitlist/waitlist.service.spec.ts | 17 ++++++++++++++++ backend/src/waitlist/waitlist.service.ts | 16 +++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 backend/src/waitlist/dto.ts create mode 100644 backend/src/waitlist/waitlist.controller.ts create mode 100644 backend/src/waitlist/waitlist.module.ts create mode 100644 backend/src/waitlist/waitlist.service.spec.ts create mode 100644 backend/src/waitlist/waitlist.service.ts diff --git a/backend/src/waitlist/dto.ts b/backend/src/waitlist/dto.ts new file mode 100644 index 00000000..6fd85d6d --- /dev/null +++ b/backend/src/waitlist/dto.ts @@ -0,0 +1,4 @@ +export class JoinWaitlistDto { + workspaceId: string; + userId: string; +} diff --git a/backend/src/waitlist/waitlist.controller.ts b/backend/src/waitlist/waitlist.controller.ts new file mode 100644 index 00000000..c14f921c --- /dev/null +++ b/backend/src/waitlist/waitlist.controller.ts @@ -0,0 +1,20 @@ +import { Controller, Post, Body, Get, Param } from '@nestjs/common'; +import { WaitlistService } from './waitlist.service'; + +@Controller('waitlist') +export class WaitlistController { + constructor(private readonly waitlistService: WaitlistService) {} + + @Post('join') + joinWaitlist( + @Body('workspaceId') workspaceId: string, + @Body('userId') userId: string, + ) { + return this.waitlistService.queueMember(workspaceId, userId); + } + + @Get(':workspaceId') + getQueue(@Param('workspaceId') workspaceId: string) { + return this.waitlistService.getQueue(workspaceId); + } +} diff --git a/backend/src/waitlist/waitlist.module.ts b/backend/src/waitlist/waitlist.module.ts new file mode 100644 index 00000000..616bcefe --- /dev/null +++ b/backend/src/waitlist/waitlist.module.ts @@ -0,0 +1,10 @@ +import { Module } from '@nestjs/common'; +import { WaitlistController } from './waitlist.controller'; +import { WaitlistService } from './waitlist.service'; + +@Module({ + controllers: [WaitlistController], + providers: [WaitlistService], + exports: [WaitlistService], +}) +export class WaitlistModule {} diff --git a/backend/src/waitlist/waitlist.service.spec.ts b/backend/src/waitlist/waitlist.service.spec.ts new file mode 100644 index 00000000..56439bb2 --- /dev/null +++ b/backend/src/waitlist/waitlist.service.spec.ts @@ -0,0 +1,17 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { WaitlistService } from './waitlist.service'; + +describe('WaitlistService', () => { + let service: WaitlistService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [WaitlistService], + }).compile(); + service = module.get(WaitlistService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/backend/src/waitlist/waitlist.service.ts b/backend/src/waitlist/waitlist.service.ts new file mode 100644 index 00000000..9bffe617 --- /dev/null +++ b/backend/src/waitlist/waitlist.service.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class WaitlistService { + private queues: Record = {}; + + queueMember(workspaceId: string, userId: string) { + if (!this.queues[workspaceId]) this.queues[workspaceId] = []; + this.queues[workspaceId].push(userId); + return { status: 'queued', position: this.queues[workspaceId].length }; + } + + getQueue(workspaceId: string) { + return this.queues[workspaceId] || []; + } +}