+
Added Game page
This commit is contained in:
+11
-7
@@ -63,7 +63,6 @@ app.post('/register', async (req, res) => {
|
||||
// Login route
|
||||
app.post('/login', (req, res) => {
|
||||
const { username, password } = req.body;
|
||||
console.log("Trying to Login: ", username);
|
||||
db.get('SELECT * FROM users WHERE username = ?', [username], async (err, row) => {
|
||||
if (err) {
|
||||
return res.status(500).json({ error: 'Internal server error' });
|
||||
@@ -198,23 +197,28 @@ app.get('/games/:userId/characters', (req, res) => {
|
||||
if (err) {
|
||||
return res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
// Directly return the array of characters
|
||||
console.log("Characters: ", rows);
|
||||
res.json(rows);
|
||||
});
|
||||
});
|
||||
|
||||
// Fetch Player Character
|
||||
app.get('/games/:gameId/:playerId/character', (req, res) => {
|
||||
app.get('/games/:gameId/:userId/character', (req, res) => {
|
||||
const gameId = req.params.gameId;
|
||||
const playerId = req.params.playerId;
|
||||
db.get('SELECT * FROM PlayerCharacter WHERE GameID = ? AND PlayerID = ?', [gameId, playerId], (err, row) => {
|
||||
const userId = req.params.userId;
|
||||
console.log(`Fetching character for gameId: ${gameId}, userId: ${userId}`); // Debug output
|
||||
db.get('SELECT * FROM PlayerCharacter WHERE GameID = ? AND PlayerID = ?', [gameId, userId], (err, row) => {
|
||||
if (err) {
|
||||
console.error('Database error:', err); // Debug output
|
||||
return res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
if (!row) {
|
||||
console.log('No character found'); // Debug output
|
||||
return res.status(404).json({ error: 'No character found' });
|
||||
}
|
||||
console.log('Character found:', row); // Debug output
|
||||
res.json(row);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
// Fetch Player Items
|
||||
app.get('/games/:charId/items', (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user