refacto: Displaying number of players for each team + adding logo at registration
This commit is contained in:
@@ -2,7 +2,7 @@ import express from "express";
|
||||
import bcrypt from "bcryptjs";
|
||||
import jwt from "jsonwebtoken";
|
||||
import { JWT_SECRET, authMiddleware } from "../middleware/auth.js";
|
||||
import { createUser, getUserByUsername, getUserById } from "../db/usersDb.js";
|
||||
import { createUser, getUserByUsername, getUserById, getTeamPlayerCounts } from "../db/usersDb.js";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -67,6 +67,17 @@ router.post("/login", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// GET /api/auth/player-counts
|
||||
router.get("/player-counts", async (_req, res) => {
|
||||
try {
|
||||
const counts = await getTeamPlayerCounts();
|
||||
return res.json(counts);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return res.status(500).json({ error: "database_error" });
|
||||
}
|
||||
});
|
||||
|
||||
// GET /api/auth/me
|
||||
router.get("/me", authMiddleware, async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user