mirror of
https://github.com/Ryujinx/Ryujinx-Ldn-Website.git
synced 2025-07-05 11:20:39 +00:00
* Switch to node package Setup environment for: - Typescript - express with ejs as the view engine * Apply prettier formatting * Read API stats from Redis * Apply prettier formatting * Add Dockerfile * Add environment variables for configuration to README.md * Log redis errors correctly * Connect to redis before executing requests * Rename json properties to match the current ones * Configure Redis error handler and client correctly * Remove workflow to fix pnpm dependencies GitHub supports pnpm for dependabot natively now: https://github.blog/changelog/2023-06-12-dependabot-version-updates-now-supports-pnpm/ * Add REDIS_SOCKET env var and prefer it over REDIS_URL * Add default.nix * Add SOCKET_PATH env var and prefer it over HOST and PORT * Bump website version * Add node symlink to output directory * Add DATA_PATH env var * Apply prettier formatting --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
47 lines
1 KiB
TypeScript
47 lines
1 KiB
TypeScript
import { Router } from "express";
|
|
import { redisClient } from "./app";
|
|
|
|
const router = Router();
|
|
|
|
router.get("/", async (req, res, next) => {
|
|
if (!redisClient.isOpen) {
|
|
await redisClient.connect();
|
|
}
|
|
|
|
const result = await redisClient.json.get("ldn");
|
|
|
|
if (result == null || typeof result != "object") {
|
|
return res.sendStatus(404);
|
|
}
|
|
|
|
return res.send(result);
|
|
});
|
|
|
|
router.get("/public_games", async (req, res, next) => {
|
|
let gameFilter = "";
|
|
|
|
if (req.query.titleid != null && (req.query.titleid as string)?.length > 0) {
|
|
gameFilter = req.query.titleid as string;
|
|
}
|
|
|
|
if (!redisClient.isOpen) {
|
|
await redisClient.connect();
|
|
}
|
|
|
|
const results = await redisClient.json.get("games");
|
|
|
|
if (results == null || typeof results != "object") {
|
|
return res.sendStatus(404);
|
|
}
|
|
|
|
const games = Object.entries(results).map(([_, game]) => game);
|
|
|
|
if (gameFilter.length > 0) {
|
|
return res.send(games.filter((game) => game.title_id === gameFilter));
|
|
}
|
|
|
|
return res.send(games);
|
|
});
|
|
|
|
export default router;
|