33 * resourcePath: /queue
44 * description: Express API router for queue management in G5API.
55 */
6-
6+ import config from "config" ;
77import { Router } from 'express' ;
88import Utils from "../utility/utils.js" ;
99import { QueueService } from "../services/queue.js" ;
@@ -21,10 +21,6 @@ const router = Router();
2121 * properties:
2222 * name:
2323 * type: string
24- * description: Human-readable name of the queue
25- * example: "Support Queue"
26- * slug:
27- * type: string
2824 * description: Unique identifier for the queue
2925 * example: "support-queue-abc123"
3026 * createdAt:
@@ -142,7 +138,7 @@ router.get('/:slug', async (req, res) => {
142138 res . status ( 200 ) . json ( queue ) ;
143139 } catch ( error : Error | any ) {
144140 console . error ( 'Error fetching queue:' , error ) ;
145- if ( error . message . includes ( 'not found ' ) ) {
141+ if ( error . message . includes ( 'does not exist ' ) ) {
146142 return res . status ( 404 ) . json ( { error : 'Queue not found.' } ) ;
147143 }
148144 res . status ( 500 ) . json ( { error : 'Failed to fetch queue.' } ) ;
@@ -260,8 +256,8 @@ router.post('/', Utils.ensureAuthenticated, async (req, res) => {
260256 const isPrivate : boolean = req . body [ 0 ] . private ? true : false ;
261257
262258 try {
263- await QueueService . createQueue ( req . user ?. steam_id ! , maxPlayers , isPrivate ) ;
264- res . json ( { message : "Queue created successfully!" } ) ;
259+ const descriptor = await QueueService . createQueue ( req . user ?. steam_id ! , maxPlayers , isPrivate ) ;
260+ res . json ( { message : "Queue created successfully!" , url : ` ${ config . get ( "server.apiURL" ) } /queue/ ${ descriptor . name } ` } ) ;
265261 } catch ( error ) {
266262 console . error ( 'Error creating queue:' , error ) ;
267263 res . status ( 500 ) . json ( { error : 'Failed to create queue.' } ) ;
@@ -330,7 +326,7 @@ router.post('/', Utils.ensureAuthenticated, async (req, res) => {
330326 */
331327router . put ( '/:slug' , Utils . ensureAuthenticated , async ( req , res ) => {
332328 const slug : string = req . params . slug ;
333- const action : string = req . body . action ? req . body . action : 'join' ;
329+ const action : string = req . body [ 0 ] . action ? req . body [ 0 ] . action : 'join' ;
334330
335331 try {
336332 if ( action === 'join' ) {
0 commit comments