Spaces:
Sleeping
Sleeping
Download backend/src/modules/analytics/analytics.controller.ts from moustafa7/protofolio: direct link, hf CLI and curl.
- Browser
- Download file 802 Bytes
-
https://huggingface.co/spaces/moustafa7/protofolio/resolve/main/backend/src/modules/analytics/analytics.controller.ts
- Command line
-
hf download hf://spaces/moustafa7/protofolio/backend/src/modules/analytics/analytics.controller.ts
-
curl -L -o analytics.controller.ts https://huggingface.co/spaces/moustafa7/protofolio/resolve/main/backend/src/modules/analytics/analytics.controller.ts
802 Bytes
| import { Response } from "express"; | |
| import { AnalyticsService } from "./analytics.service"; | |
| import { ApiResponse } from "../../utils/apiResponse"; | |
| import { AuthRequest } from "../../types"; | |
| const analyticsService = new AnalyticsService(); | |
| export class AnalyticsController { | |
| async track(req: any, res: Response) { | |
| const { page } = req.body; | |
| const visitorIp = req.ip || req.connection.remoteAddress; | |
| const userAgent = req.headers["user-agent"]; | |
| const referer = req.headers.referer; | |
| await analyticsService.track(page, visitorIp, userAgent, referer); | |
| return ApiResponse.success(res, null, "Tracked"); | |
| } | |
| async getDashboard(req: AuthRequest, res: Response) { | |
| const dashboard = await analyticsService.getDashboard(); | |
| return ApiResponse.success(res, dashboard); | |
| } | |
| } | |