Spaces:
Sleeping
Sleeping
Update mod things
Browse files- src/mods/mods.ts +12 -4
src/mods/mods.ts
CHANGED
|
@@ -15,19 +15,26 @@ export class ModManager {
|
|
| 15 |
}
|
| 16 |
|
| 17 |
public async createModEndpoints(): Promise<void> {
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
});
|
| 23 |
|
| 24 |
this.server.get("/files/mods/:filename", async (req, res) => {
|
| 25 |
try {
|
| 26 |
const filename = req.params.filename;
|
| 27 |
|
|
|
|
|
|
|
| 28 |
const mod = mods.find(m => m.filename === filename);
|
| 29 |
|
| 30 |
if (!mod) {
|
|
|
|
| 31 |
res.status(404).send("Mod not found in index");
|
| 32 |
return;
|
| 33 |
}
|
|
@@ -39,6 +46,7 @@ export class ModManager {
|
|
| 39 |
});
|
| 40 |
|
| 41 |
if (!blob) {
|
|
|
|
| 42 |
res.status(404).send("Mod not found");
|
| 43 |
return;
|
| 44 |
}
|
|
|
|
| 15 |
}
|
| 16 |
|
| 17 |
public async createModEndpoints(): Promise<void> {
|
| 18 |
+
this.server.get("/mods/", async (_req, res) => {
|
| 19 |
+
try {
|
| 20 |
+
const mods = await this.getModList();
|
| 21 |
+
res.send(JSON.stringify(mods));
|
| 22 |
+
} catch (err) {
|
| 23 |
+
console.error("Failed to list mods:", err);
|
| 24 |
+
res.status(500).send("Failed to list mods");
|
| 25 |
+
}
|
| 26 |
});
|
| 27 |
|
| 28 |
this.server.get("/files/mods/:filename", async (req, res) => {
|
| 29 |
try {
|
| 30 |
const filename = req.params.filename;
|
| 31 |
|
| 32 |
+
const mods = await this.getModList();
|
| 33 |
+
|
| 34 |
const mod = mods.find(m => m.filename === filename);
|
| 35 |
|
| 36 |
if (!mod) {
|
| 37 |
+
console.warn(`Requested mod not in index: ${filename}`);
|
| 38 |
res.status(404).send("Mod not found in index");
|
| 39 |
return;
|
| 40 |
}
|
|
|
|
| 46 |
});
|
| 47 |
|
| 48 |
if (!blob) {
|
| 49 |
+
console.warn(`Blob missing for mod path: ${mod.path}`);
|
| 50 |
res.status(404).send("Mod not found");
|
| 51 |
return;
|
| 52 |
}
|