Add badges, checkins, and transport endpoints

Introduce gamification and check-in support plus expanded transport/admin APIs. Added DDL for checkins, badges and user_badges. New repositories: badgeRepository, userBadgeRepository, checkinRepository. New routes: admin badge management, admin transport (lines/platforms/stations), public transport endpoints, user checkins and stations endpoints, and user badges on /me. Services updated: adminService (badge CRUD & user assignment), userService (checkins, badge queries), authService (hasAdminRights). Minor package.json name update. These changes implement database, repo, service and route wiring for badges, user_badins and checkin features and additional transport admin routes.
This commit is contained in:
2026-09-23 02:09:39 +02:00
parent e5eccb77db
commit b03f5c91e6
22 changed files with 686 additions and 24 deletions
+47
View File
@@ -0,0 +1,47 @@
const express = require("express")
const adminService = require("../../../../services/adminService")
const router = express.Router({ mergeParams: true })
router.post("/", async (req, res) => {
const { name, icon, condition, description } = req.body
const badge = await adminService.createBadge({ name, icon, condition, description })
return res.status(201).json(badge)
})
router.patch("/:badgeId", async (req, res) => {
const { badgeId } = req.params
const updateData = req.body.data
const badge = await adminService.updateBadge({ badgeId, updateData })
return res.status(200).json(badge)
})
router.delete("/:badgeId", async (req, res) => {
const { badgeId } = req.params
await adminService.deleteBadge({ badgeId })
return res.sendStatus(204)
})
router.put("/user/:userId/:badgeId", async (req, res) => {
const { badgeId, userId } = req.params
const assignedBadge = await adminService.assignBadgeToUser({ badgeId, userId })
return res.status(200).json(assignedBadge)
})
router.delete("/user/:userId/:badgeId", async (req, res) => {
const { badgeId, userId } = req.params
await adminService.removeBadgeFromUser({ badgeId, userId })
return res.sendStatus(204)
})
router.get("/all", async (req, res) => {
const badges = await adminService.getAllBadges()
return res.status(200).json(badges)
})
router.get("/:badgeId", async (req, res) => {
const { badgeId } = req.params.badgeId
const badge = await adminService.getBadgeById({ badgeId })
return res.status(200).json(badge)
})
module.exports = router