feat: added controller for new services
This commit is contained in:
35
server/src/controller/wifiLocationHistoryController.ts
Normal file
35
server/src/controller/wifiLocationHistoryController.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import express, { Request, Response } from "express";
|
||||
import { container } from "tsyringe";
|
||||
import { WifiLocationHistoryService } from "../services/wifiLocationHistoryService";
|
||||
|
||||
const wifiLocationHistoryService = container.resolve(
|
||||
WifiLocationHistoryService
|
||||
);
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/", async (req: Request, res: Response) => {
|
||||
try {
|
||||
const wifiLocationHistory =
|
||||
await wifiLocationHistoryService.getAllWifiLocationHistories();
|
||||
res.status(200).json(wifiLocationHistory);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Error retrieving wifi location history" });
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/:id", async (req: Request, res: Response) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const wifiLocationHistory =
|
||||
await wifiLocationHistoryService.getWifiLocationHistoryById(id);
|
||||
if (!wifiLocationHistory) {
|
||||
res.status(404).json({ error: "Wifi location history not found" });
|
||||
return;
|
||||
}
|
||||
res.status(200).json(wifiLocationHistory);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Error retrieving wifi location history" });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
Reference in New Issue
Block a user