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
+24
View File
@@ -0,0 +1,24 @@
const express = require("express")
const transportService = require("../../../../../services/transportService")
const router = express.Router({ mergeParams: true })
router.post("/", async (req, res) => {
const { code, name, backColorHex, textColorHex, transportTypeId } = req.body
const lines = await transportService.createLine({ code, name, backColorHex, textColorHex, transportTypeId })
return res.status(201).json(lines)
})
router.delete("/:lineId", async (req, res) => {
const { lineId } = req.params
await transportService.deleteLine({ lineId })
return res.sendStatus(204)
})
router.patch("/:lineId", async (req, res) => {
const { lineId } = req.params
const updateData = req.body.data
await transportService.updateLine({ lineId, updateData })
return res.sendStatus(200)
})
module.exports = router
+44
View File
@@ -0,0 +1,44 @@
const express = require("express")
const transportService = require("../../../../../services/transportService")
const router = express.Router({ mergeParams: true })
router.post("/", async (req, res) => {
const { direction, latitude, longitude, name, stationId, hasElevator, isPRM } = req.body
const lines = await transportService.createPlatform({ direction: direction || 0, latitude, longitude, name, stationId, hasElevator, isPRM })
return res.status(201).json(lines)
})
router.delete("/:platformId", async (req, res) => {
const { platformId } = req.params
await transportService.deletePlatform({ platformId })
return res.sendStatus(204)
})
router.post("/:platformId/line/:lineId", async (req, res) => {
const { platformId, lineId } = req.params
const { orderInLine, directionId } = req.body
const patchedPlatform = await transportService.addLineToPlatform({ platformId, lineId, orderInLine, directionId })
return res.status(201).json(patchedPlatform)
})
router.patch("/:platformId", async (req, res) => {
const { platformId } = req.params
const { hasElevator, isPRM } = req.body
const patchedPlatform = await transportService.updatePlatformAccessibility({ platformId, hasElevator, isPRM })
return res.status(200).json(patchedPlatform)
})
router.patch("/:platformLineId/:orderInLine", async (req, res) => {
const { platformLineId, orderInLine } = req.params
const patchedPlatform = await transportService.updatePlatformLineOrder({ platformLineId, orderInLine })
return res.status(200).json(patchedPlatform)
})
router.delete("/:platformId/:lineId", async (req, res) => {
const { lineId, platformId, directionId } = req.body
await transportService.removeLineFromPlatform({ lineId, platformId, directionId })
return res.sendStatus(204)
})
module.exports = router
+24
View File
@@ -0,0 +1,24 @@
const express = require("express")
const transportService = require("../../../../../services/transportService")
const router = express.Router({ mergeParams: true })
router.post("/", async (req, res) => {
const { name, description } = req.body
const lines = await transportService.createStation({ name, description })
return res.status(201).json(lines)
})
router.delete("/:stationId", async (req, res) => {
const { stationId } = req.params
await transportService.deleteStation({ stationId })
return res.status(204)
})
router.patch("/:stationId", async (req, res) => {
const { stationId } = req.params
const updateData = req.body.data
const patchedStation = await transportService.updateStation({ stationId, updateData })
return res.status(200).json({ patched: patchedStation })
})
module.exports = router