Spaces:
Sleeping
Sleeping
| // Express server for Hugging Face Spaces deployment | |
| import express from "express"; | |
| import statsHandler from "./api/index.js"; | |
| import pinHandler from "./api/pin.js"; | |
| import topLangsHandler from "./api/top-langs.js"; | |
| import gistHandler from "./api/gist.js"; | |
| import wakatimeHandler from "./api/wakatime.js"; | |
| const app = express(); | |
| const PORT = process.env.PORT || 7860; | |
| // Mount all API handlers | |
| app.get("/api", statsHandler); | |
| app.get("/api/pin", pinHandler); | |
| app.get("/api/top-langs", topLangsHandler); | |
| app.get("/api/gist", gistHandler); | |
| app.get("/api/wakatime", wakatimeHandler); | |
| // Health check endpoint | |
| app.get("/health", (req, res) => { | |
| res.status(200).json({ status: "ok" }); | |
| }); | |
| // Root endpoint | |
| app.get("/", (req, res) => { | |
| res.status(200).json({ | |
| message: "GitHub Readme Stats on Hugging Face Spaces", | |
| endpoints: [ | |
| "/api - Generate stats card", | |
| "/api/pin - Generate pinned repo card", | |
| "/api/top-langs - Generate top languages card", | |
| "/api/gist - Generate gist card", | |
| "/api/wakatime - Generate WakaTime stats card" | |
| ], | |
| docs: "https://github.com/anuraghazra/github-readme-stats" | |
| }); | |
| }); | |
| app.listen(PORT, () => { | |
| console.log(`Server running on port ${PORT}`); | |
| }); | |