generated from azures04/Base-REST-API
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:
@@ -0,0 +1,22 @@
|
||||
const express = require("express")
|
||||
const userService = require("../../../../services/userService")
|
||||
const router = express.Router()
|
||||
|
||||
router.post("/", async (req, res) => {
|
||||
const { stationId, platformId, latitude, longitude, distance } = req.body
|
||||
const checkin = await userService.createCheckin({ distance, latitude, longitude, platformId, stationId, userId: req.user.id })
|
||||
return res.status(200).json(checkin)
|
||||
})
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
const { limit, offset } = req.query
|
||||
const checkins = await userService.getUserCheckins({ userId: req.user.id, limit, offset })
|
||||
return res.status(200).json(checkins)
|
||||
})
|
||||
|
||||
router.get("/count", async (req, res) => {
|
||||
const checkins = await userService.getUserCheckinsCount({ userId: req.user.id })
|
||||
return res.status(200).json(checkins)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
Reference in New Issue
Block a user