generated from nhcarrigan/template
03b6c847b3
## Summary - Adds a new **Debug** tab to the game UI with two self-service tools for players with broken save state - **Force Unlocks**: scans the player's save and grants any zones, quests, bosses, and exploration areas they've earned but that are still locked — shows a breakdown of what was unlocked (or reports nothing needed fixing) - **Hard Reset**: wipes progress back to a fresh save (preserving lifetime stats), guarded behind a confirmation modal to prevent accidental clicks ## Files added - `apps/api/src/routes/debug.ts` — two POST endpoints (`/force-unlocks`, `/hard-reset`) - `apps/web/src/components/game/debugPanel.tsx` — the Debug tab UI - `apps/web/src/components/ui/confirmationModal.tsx` — reusable confirmation modal ## Files modified - `apps/api/src/index.ts` — registers the debug router - `packages/types/src/interfaces/api.ts` — adds `ForceUnlocksResponse` type - `packages/types/src/index.ts` — exports the new type - `apps/web/src/api/client.ts` — adds `forceUnlocks()` and `debugHardReset()` API calls - `apps/web/src/context/gameContext.tsx` — wires both functions into game context - `apps/web/src/components/game/gameLayout.tsx` — adds the Debug tab - `apps/web/src/styles.css` — styles for action buttons, cards, result messages, and confirmation modal ✨ This PR was created with help from Hikari~ 🌸 Reviewed-on: #65 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
80 lines
2.4 KiB
TypeScript
80 lines
2.4 KiB
TypeScript
/**
|
|
* @file Entry point for the Elysium API server.
|
|
* @copyright nhcarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
import { serve } from "@hono/node-server";
|
|
import { Hono } from "hono";
|
|
import { cors } from "hono/cors";
|
|
import { logger as honoLogger } from "hono/logger";
|
|
import { aboutRouter } from "./routes/about.js";
|
|
import { apotheosisRouter } from "./routes/apotheosis.js";
|
|
import { authRouter } from "./routes/auth.js";
|
|
import { bossRouter } from "./routes/boss.js";
|
|
import { craftRouter } from "./routes/craft.js";
|
|
import { debugRouter } from "./routes/debug.js";
|
|
import { exploreRouter } from "./routes/explore.js";
|
|
import { frontendRouter } from "./routes/frontend.js";
|
|
import { gameRouter } from "./routes/game.js";
|
|
import { leaderboardRouter } from "./routes/leaderboards.js";
|
|
import { prestigeRouter } from "./routes/prestige.js";
|
|
import { profileRouter } from "./routes/profile.js";
|
|
import { transcendenceRouter } from "./routes/transcendence.js";
|
|
import { logger } from "./services/logger.js";
|
|
|
|
const app = new Hono();
|
|
|
|
app.use("*", honoLogger());
|
|
app.use(
|
|
"*",
|
|
cors({
|
|
allowHeaders: [ "Authorization", "Content-Type" ],
|
|
allowMethods: [ "GET", "POST", "PUT", "DELETE", "OPTIONS" ],
|
|
origin: process.env.CORS_ORIGIN ?? "http://localhost:5173",
|
|
}),
|
|
);
|
|
|
|
app.route("/about", aboutRouter);
|
|
app.route("/debug", debugRouter);
|
|
app.route("/fe", frontendRouter);
|
|
app.route("/auth", authRouter);
|
|
app.route("/game", gameRouter);
|
|
app.route("/boss", bossRouter);
|
|
app.route("/explore", exploreRouter);
|
|
app.route("/craft", craftRouter);
|
|
app.route("/prestige", prestigeRouter);
|
|
app.route("/transcendence", transcendenceRouter);
|
|
app.route("/apotheosis", apotheosisRouter);
|
|
app.route("/leaderboards", leaderboardRouter);
|
|
app.route("/profile", profileRouter);
|
|
|
|
app.get("/health", (context) => {
|
|
return context.json({ status: "ok" });
|
|
});
|
|
|
|
app.onError((error, context) => {
|
|
void logger.error(
|
|
"hono_unhandled_error",
|
|
error instanceof Error
|
|
? error
|
|
: new Error(String(error)),
|
|
);
|
|
return context.json({ error: "Internal server error" }, 500);
|
|
});
|
|
|
|
const port = Number(process.env.PORT ?? 3001);
|
|
|
|
try {
|
|
serve({ fetch: app.fetch, port: port }, () => {
|
|
process.stdout.write(`Elysium API running on port ${String(port)}\n`);
|
|
});
|
|
} catch (error) {
|
|
void logger.error(
|
|
"server_startup",
|
|
error instanceof Error
|
|
? error
|
|
: new Error(String(error)),
|
|
);
|
|
}
|