Spaces:
Sleeping
Sleeping
Download api-server/src/index.ts from o134/operation-cycle: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/o134/operation-cycle/resolve/main/api-server/src/index.ts
- Command line
-
hf download hf://spaces/o134/operation-cycle/api-server/src/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/o134/operation-cycle/resolve/main/api-server/src/index.ts
1.12 kB
| import app from "./app"; | |
| import { logger } from "./lib/logger"; | |
| const rawPort = process.env["PORT"]; | |
| if (!rawPort) { | |
| throw new Error( | |
| "PORT environment variable is required but was not provided.", | |
| ); | |
| } | |
| const port = Number(rawPort); | |
| if (Number.isNaN(port) || port <= 0) { | |
| throw new Error(`Invalid PORT value: "${rawPort}"`); | |
| } | |
| app.listen(port, (err) => { | |
| if (err) { | |
| logger.error({ err }, "Error listening on port"); | |
| process.exit(1); | |
| } | |
| logger.info({ port }, "Server listening"); | |
| // Phase 5: Start daily deadline checking & scheduling | |
| import("./lib/deadline-checker.js") | |
| .then(async ({ checkDeadlines, scheduleDailyCheck }) => { | |
| logger.info("Initializing Phase 5 Deadline Checker..."); | |
| try { | |
| const sent = await checkDeadlines(); | |
| logger.info({ sent }, "Startup deadline check completed."); | |
| } catch (checkErr) { | |
| logger.error({ err: checkErr }, "Startup deadline check failed"); | |
| } | |
| scheduleDailyCheck(); | |
| }) | |
| .catch((importErr) => { | |
| logger.error({ err: importErr }, "Failed to import deadline-checker module"); | |
| }); | |
| }); | |