diff --git a/index.js b/index.js index 5dc60a6..403ccd4 100644 --- a/index.js +++ b/index.js @@ -46,6 +46,8 @@ import { } from './init_database.js'; import { getValorantSkins, getSkinTiers } from './valo.js'; import {sleep} from "openai/core"; +import { v4 as uuidv4 } from 'uuid'; +import { uniqueNamesGenerator, adjectives, languages, animals } from 'unique-names-generator'; // Create an express app const app = express(); @@ -3423,6 +3425,28 @@ app.post('/buy-coins', (req, res) => { res.status(200).json({ message : `+${coins}` }); }); +const pokerRooms = {} +app.post('/create-poker-room', (req, res) => { + console.log('creating poker room') + const { creatorId } = req.body + const id = uuidv4() + const name = uniqueNamesGenerator({ dictionaries: [adjectives, languages, animals], separator: ' ', style: 'capital' }); + pokerRooms[id] = { + id: id, + host_id: creatorId, + name: name, + } + io.emit('new-poker-room') +}); + +app.get('/poker-rooms', (req, res) => { + return res.status(200).send({ rooms: pokerRooms }) +}) + +app.get('/poker-rooms/:id', (req, res) => { + return res.status(200).send({ room: pokerRooms[req.params.id] }) +}) + import http from 'http'; import { Server } from 'socket.io'; const server = http.createServer(app); diff --git a/package-lock.json b/package-lock.json index 7c30727..94f22ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,9 @@ "node-cron": "^3.0.3", "openai": "^4.94.0", "pokersolver": "^2.1.4", - "socket.io": "^4.8.1" + "socket.io": "^4.8.1", + "unique-names-generator": "^4.7.1", + "uuid": "^11.1.0" }, "devDependencies": { "nodemon": "^3.0.0" @@ -1728,6 +1730,15 @@ "node": ">=6.0.0" } }, + "node_modules/node-cron/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -2616,6 +2627,15 @@ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "license": "MIT" }, + "node_modules/unique-names-generator": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/unique-names-generator/-/unique-names-generator-4.7.1.tgz", + "integrity": "sha512-lMx9dX+KRmG8sq6gulYYpKWZc9RlGsgBR6aoO8Qsm3qvkSJ+3rAymr+TnV8EDMrIrwuFJ4kruzMWM/OpYzPoow==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -2641,12 +2661,16 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "license": "MIT", "bin": { - "uuid": "dist/bin/uuid" + "uuid": "dist/esm/bin/uuid" } }, "node_modules/vary": { diff --git a/package.json b/package.json index a4268ca..80cff60 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,9 @@ "node-cron": "^3.0.3", "openai": "^4.94.0", "pokersolver": "^2.1.4", - "socket.io": "^4.8.1" + "socket.io": "^4.8.1", + "unique-names-generator": "^4.7.1", + "uuid": "^11.1.0" }, "devDependencies": { "nodemon": "^3.0.0"