feat: added controller for new services

This commit is contained in:
2025-01-11 12:13:34 +01:00
parent 5a5dcb6334
commit 7b9c6ae5b8
6 changed files with 86 additions and 36 deletions

View File

@ -0,0 +1,32 @@
import express, { Request, Response } from "express";
import { container } from "tsyringe";
import { WifiLocationService } from "../services/wifiLocationService";
const wifiLocationService = container.resolve(WifiLocationService);
const router = express.Router();
router.get("/", async (req: Request, res: Response) => {
try {
const wifiLocations = await wifiLocationService.getAllWifiLocations();
res.status(200).json(wifiLocations);
} catch (error) {
console.log(error);
res.status(500).json({ error: "Error retrieving wifi location" });
}
});
router.delete("/:id", async (req: Request, res: Response) => {
try {
const { id } = req.params;
const deleted = await wifiLocationService.deleteWifiLocation(id);
if (!deleted) {
res.status(404).json({ error: "Wifi Location not found" });
return;
}
res.status(204).send();
} catch (error) {
res.status(500).json({ error: "Error deleting wifi location" });
}
});
export default router;