Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#54 - [Game Service] Question generator and retriever #56

Merged
merged 12 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
coverage
docs/build
.env
webapp/.env
webapp/.env
gameservice/public/images/*
24 changes: 24 additions & 0 deletions gameservice/gameserver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const express = require('express');
const mongoose = require('mongoose');
const questionRouter = require('./routers/RouterQuestionRetriever');
const generateRouter = require('./routers/RouterQuestionFetcher');

const app = express();
const port = 8004;

// Connection to MongoDB game database
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/game';
mongoose.connect(mongoUri)
.then(() => console.log('✅ Connected to MongoDB'))
.catch(err => console.error('❌ Error when connecting to MongoDB:', err));

// Middleware to serve static files
app.use(express.static('public'));

// Routers
app.use(questionRouter);
app.use(generateRouter);

app.listen(port, () => {
console.log(`🚀 Server running on: http://localhost:${port}`);
});
Loading