Skip to content

Commit

Permalink
Merge pull request #4 from avoylenko/get-all-sessions
Browse files Browse the repository at this point in the history
Add get all session endpoint
avoylenko authored Jan 29, 2025
2 parents 71c8dee + 2b30d5c commit 2653b37
Showing 4 changed files with 94 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/controllers/sessionController.js
Original file line number Diff line number Diff line change
@@ -339,6 +339,30 @@ const requestPairingCode = async (req, res) => {
}
}

/**
* Get all sessions.
*
* @function
* @async
* @param {Object} req - The HTTP request object.
* @param {Object} res - The HTTP response object.
* @returns {<Object>}
*/
const getSessions = async (req, res) => {
// #swagger.summary = 'Get all sessions'
// #swagger.description = 'Get all sessions.'
/* #swagger.responses[200] = {
description: "Retrieved all sessions.",
content: {
"application/json": {
schema: { "$ref": "#/definitions/GetSessionsResponse" }
}
}
}
*/
return res.json({ success: true, result: Array.from(sessions.keys()) })
}

module.exports = {
startSession,
statusSession,
@@ -348,5 +372,6 @@ module.exports = {
restartSession,
terminateSession,
terminateInactiveSessions,
terminateAllSessions
terminateAllSessions,
getSessions
}
1 change: 1 addition & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ sessionRouter.use(middleware.apikey)
sessionRouter.use(middleware.sessionSwagger)
routes.use('/session', sessionRouter)

sessionRouter.get('/getSessions', sessionController.getSessions)
sessionRouter.get('/start/:sessionId', middleware.sessionNameValidation, sessionController.startSession)
sessionRouter.get('/status/:sessionId', middleware.sessionNameValidation, sessionController.statusSession)
sessionRouter.get('/qr/:sessionId', middleware.sessionNameValidation, sessionController.sessionQrCode)
4 changes: 4 additions & 0 deletions swagger.js
Original file line number Diff line number Diff line change
@@ -72,6 +72,10 @@ const doc = {
ForbiddenResponse: {
success: false,
error: 'Invalid API key'
},
GetSessionsResponse: {
success: true,
result: []
}
}
}
63 changes: 63 additions & 0 deletions swagger.json
Original file line number Diff line number Diff line change
@@ -106,6 +106,52 @@
]
}
},
"/session/getSessions": {
"get": {
"tags": [
"Session"
],
"summary": "Get all sessions",
"description": "Get all sessions.",
"responses": {
"200": {
"description": "Retrieved all sessions.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetSessionsResponse"
}
}
}
},
"403": {
"description": "Forbidden.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ForbiddenResponse"
}
}
}
},
"500": {
"description": "Server failure.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
},
"security": [
{
"apiKeyAuth": []
}
]
}
},
"/session/start/{sessionId}": {
"get": {
"tags": [
@@ -11069,6 +11115,23 @@
"xml": {
"name": "ForbiddenResponse"
}
},
"GetSessionsResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"result": {
"type": "array",
"example": [],
"items": {}
}
},
"xml": {
"name": "GetSessionsResponse"
}
}
},
"securitySchemes": {

0 comments on commit 2653b37

Please sign in to comment.