-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/server/src/controllers/routeControllers/lap.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { BackendController } from "../BackendController/BackendController"; | ||
|
||
import { type Request, type Response } from "express"; | ||
|
||
import { createApplicationLogger } from "@/utils/logger"; | ||
|
||
export const getLapData = async (request: Request, response: Response) => { | ||
const backendController = request.app.locals | ||
.backendController as BackendController; | ||
|
||
const logger = createApplicationLogger( | ||
"lap.controller.ts", | ||
request, | ||
response, | ||
); | ||
|
||
try { | ||
const timestamp = new Date(request.params.timestamp); | ||
const lapData = await backendController.dynamoDB.getPacketData(timestamp); | ||
|
||
logger.info(`ENTRY - ${request.method} ${request.url}`); | ||
const data = { | ||
data: lapData, | ||
message: "OK", | ||
uptime: process.uptime() + " seconds", | ||
}; | ||
logger.info(`EXIT - ${request.method} ${request.url} - ${200}`); | ||
|
||
return response.status(200).json(data); | ||
} catch (err) { | ||
logger.error(`ERROR - ${request.method} ${request.url} - ${err.message}`); | ||
response.status(500).json({ message: "Server Error" }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import express from "express"; | ||
|
||
import * as controllers from "@/controllers/routeControllers/lap.controller"; | ||
|
||
const lapRouter = express.Router(); | ||
|
||
lapRouter.get("/lap", controllers.getLapData); | ||
|
||
export default lapRouter; |