feat: added controller for new services
This commit is contained in:
32
server/src/controller/wifiLocationController.ts
Normal file
32
server/src/controller/wifiLocationController.ts
Normal 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;
|
Reference in New Issue
Block a user