generated from azures04/Base-REST-API
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.
24 lines
847 B
JavaScript
24 lines
847 B
JavaScript
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 |