mirror of
https://github.com/Ryujinx/Ryujinx-Ldn-Website.git
synced 2025-08-11 20:41:11 +00:00
Apply prettier formatting
This commit is contained in:
parent
09ee4e3ed8
commit
248861d8f1
37
src/api.ts
37
src/api.ts
|
@ -4,36 +4,35 @@ import { redisClient } from "./app";
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.get("/", async (req, res, next) => {
|
router.get("/", async (req, res, next) => {
|
||||||
const result = await redisClient.json.get("ldn");
|
const result = await redisClient.json.get("ldn");
|
||||||
|
|
||||||
if (result == null || typeof (result) != "object") {
|
if (result == null || typeof result != "object") {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.send(result);
|
return res.send(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/public_games", async (req, res, next) => {
|
router.get("/public_games", async (req, res, next) => {
|
||||||
let gameFilter = "";
|
let gameFilter = "";
|
||||||
|
|
||||||
if (req.query.titleid != null && (req.query.titleid as string)?.length > 0) {
|
if (req.query.titleid != null && (req.query.titleid as string)?.length > 0) {
|
||||||
gameFilter = req.query.titleid as string;
|
gameFilter = req.query.titleid as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const results = await redisClient.json.get("games");
|
const results = await redisClient.json.get("games");
|
||||||
|
|
||||||
if (results == null || typeof (results) != "object") {
|
if (results == null || typeof results != "object") {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
const games = Object.entries(results).map(([_, game]) => game);
|
const games = Object.entries(results).map(([_, game]) => game);
|
||||||
|
|
||||||
if (gameFilter.length > 0) {
|
if (gameFilter.length > 0) {
|
||||||
return res.send(games.filter((game) => game.title_id === gameFilter));
|
return res.send(games.filter((game) => game.title_id === gameFilter));
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.send(games);
|
return res.send(games);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import actuator from "express-actuator";
|
import actuator from "express-actuator";
|
||||||
import { createClient } from 'redis';
|
import { createClient } from "redis";
|
||||||
import winston from "winston";
|
import winston from "winston";
|
||||||
import apiRouter from "./api";
|
import apiRouter from "./api";
|
||||||
import { errorLogger, requestLogger } from "./middleware";
|
import { errorLogger, requestLogger } from "./middleware";
|
||||||
|
@ -26,7 +26,9 @@ export const redisClient = createClient({
|
||||||
readonly: true,
|
readonly: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
redisClient.on("error", (err: Error) => winston.error("An error occurred.", { source: "Redis client", error: err }));
|
redisClient.on("error", (err: Error) =>
|
||||||
|
winston.error("An error occurred.", { source: "Redis client", error: err })
|
||||||
|
);
|
||||||
|
|
||||||
// Init express server
|
// Init express server
|
||||||
export const app = express();
|
export const app = express();
|
||||||
|
|
Loading…
Reference in a new issue