Download artifacts/api-server/src/index.ts from PVPPRO/Slayers: direct link, hf CLI and curl.
- Browser
- Download file 695 Bytes
-
https://huggingface.co/spaces/PVPPRO/Slayers/resolve/main/artifacts/api-server/src/index.ts
- Command line
-
hf download hf://spaces/PVPPRO/Slayers/artifacts/api-server/src/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/PVPPRO/Slayers/resolve/main/artifacts/api-server/src/index.ts
695 Bytes
| import { createServer } from "http"; | |
| import app from "./app"; | |
| import { logger } from "./lib/logger"; | |
| import { attachMultiplayer } from "./multiplayer/wsHandler.js"; | |
| 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}"`); | |
| } | |
| const server = createServer(app); | |
| attachMultiplayer(server); | |
| server.listen(port, () => { | |
| logger.info({ port }, "Server listening (HTTP + WebSocket)"); | |
| }); | |
| server.on("error", (err) => { | |
| logger.error({ err }, "Server error"); | |
| process.exit(1); | |
| }); | |