feat: reworked ttn webhook endpoint logic

This commit is contained in:
2025-01-03 02:01:55 +01:00
parent ffdb644700
commit 62847f569d
17 changed files with 273 additions and 356 deletions

View File

@ -1,6 +1,6 @@
import express, { Request, Response } from "express";
import { TtnGatewayReceptionService } from "../services/ttnGatewayReceptionService";
import { container } from "tsyringe";
import { TtnGatewayReceptionService } from "../services/ttnGatewayReceptionService";
const ttnGatewayReceptionService = container.resolve(
TtnGatewayReceptionService
@ -35,7 +35,7 @@ router.get("/:id", async (req: Request, res: Response) => {
router.post("/", async (req: Request, res: Response) => {
try {
const newGatewayReception =
await ttnGatewayReceptionService.createGatewayReception(req.body);
await ttnGatewayReceptionService.createTtnGatewayReception(req.body);
res.status(201).json(newGatewayReception);
} catch (error) {
res.status(500).json({ error: "Error creating gateway reception" });
@ -46,7 +46,10 @@ router.put("/:id", async (req: Request, res: Response) => {
try {
const { id } = req.params;
const updatedGatewayReception =
await ttnGatewayReceptionService.updateGatewayReception(id, req.body);
await ttnGatewayReceptionService.updateGatewayReception({
...req.body,
ttn_gateway_reception_id: id,
});
if (!updatedGatewayReception) {
res.status(404).json({ error: "Gateway reception not found" });
return;