diff options
| author | Pinapelz <yukais@pinapelz.com> | 2025-06-29 23:55:33 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2025-06-29 23:55:33 -0700 |
| commit | 722df5105c098f404e09e884a817acf92d939648 (patch) | |
| tree | 2644c1921a66279a497fcf69fd778925b37993fb /backend/src | |
| parent | eda5691cfcb3be0bb6ccf1b2ad4fa92801ad86c4 (diff) | |
add route to list supported games
Diffstat (limited to 'backend/src')
| -rw-r--r-- | backend/src/index.ts | 3 | ||||
| -rw-r--r-- | backend/src/routes/gameRoutes.ts | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/backend/src/index.ts b/backend/src/index.ts index 3e2c559..c776ce1 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -8,6 +8,7 @@ import { startSessionCleanup } from './utils/session'; // Routes import * as authRoutes from './routes/authRoutes'; import * as userRoutes from './routes/userRoutes'; +import * as gameRoutes from './routes/gameRoutes'; const app = express(); const port = 5000; @@ -49,6 +50,8 @@ app.post('/api/logout', requireAuth, authRoutes.handleLogout); app.get('/api/me', userRoutes.handleMeRoute); app.get('/api/session', userRoutes.handleGetCurrentSession); +app.get('/api/supportedGames', gameRoutes.handleGetSupportedGames); + app.listen(port, () => { console.log(`Server listening on port ${port}`); }); diff --git a/backend/src/routes/gameRoutes.ts b/backend/src/routes/gameRoutes.ts new file mode 100644 index 0000000..26e7171 --- /dev/null +++ b/backend/src/routes/gameRoutes.ts @@ -0,0 +1,19 @@ +import express from 'express'; +import { prisma } from '../config/db'; + +export const handleGetSupportedGames = async (req: express.Request, res: express.Response) => { + try { + const supportedGames = await prisma.game.findMany({ + select: { + internalName: true, + formattedName: true, + description: true + } + }); + res.status(200).json(supportedGames); + + } catch (error) { + console.error('Supported Games endpoint error:', error); + res.status(500).json({ error: 'Internal server error. Unable to fetch supported games' }); + } +} |
