Skip to content

Commit

Permalink
fully remove v3 bot endpoints from existence
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Oct 23, 2023
1 parent 5cfb37f commit 322c153
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 78 deletions.
12 changes: 4 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PORT=8000
DEV=false
DEV=true

FIRESTORM_URL=https://url-to-firesto.rm
FIRESTORM_TOKEN=abcdefghijklmnopqrstuvwxyz
Expand All @@ -9,18 +9,14 @@ DB_IMAGE_ROOT=https://database.faithfulpack.net
VERBOSE=false
PURGE_PASSWORD=password123

DEV=true
# disable cache for dev
NO_CACHE=false

CORS=https://faithfulpack.net,https://webapp.faithfulpack.net,https://github.com
NO_CACHE=true

CLOUDFLARE_EMAIL=""
CLOUDFLARE_KEY=""
CLOUDFLARE_PASSWORD=""
CLOUDFLARE_EMAIL=""

CURSE_FORGE_API_KEY=""
CURSEFORGE_API_KEY=""

BOT_PASSWORD=test
WEBHOOK_URL=https://discord.com/api/webhooks/123456789123456789/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0
DISCORD_BOT_ENDPOINT=http://localhost:1234/
59 changes: 0 additions & 59 deletions src/errorSender.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import cors from "cors";

import * as dotenv from "dotenv";
import apiErrorHandler from "api-error-handler";
import sendError from "./errorSender";
import { RegisterRoutes } from "../build/routes";
import { ApiError } from "./v2/tools/ApiError";
import { AddonChangeController } from "./v2/controller/addonChange.controller";
Expand All @@ -18,10 +17,8 @@ import formHandler from "./v2/tools/FormHandler";
dotenv.config();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const DEV = (process.env.DEV || "false") === "true";
const NO_CACHE = process.env.NO_CACHE === "true";
const PORT = process.env.PORT || 8000;
const BOT_ENDPOINT = process.env.DISCORD_BOT_ENDPOINT;

firestorm.address(process.env.FIRESTORM_URL);
firestorm.token(process.env.FIRESTORM_TOKEN);
Expand Down Expand Up @@ -76,7 +73,6 @@ const options: UpdatedSwaggerUiOptions = {
app.listen(PORT, () => {
console.log(`DB is located at ${process.env.FIRESTORM_URL}`);
console.log(`Server is running at http://localhost:${PORT}`);
console.log(`Bot endpoint is set at ${BOT_ENDPOINT}`);
if (NO_CACHE) console.log(`Started with no cache`);
});

Expand Down Expand Up @@ -134,7 +130,6 @@ app.use(async (err: any, req: Request, res: Response, next: NextFunction): Promi
console.warn(warn, err.fields);

code = 422;
await sendError(code, err, req, Error().stack, warn);

res.status(422).json({
message: "Validation Failed",
Expand Down Expand Up @@ -189,9 +184,6 @@ app.use(async (err: any, req: Request, res: Response, next: NextFunction): Promi
finalError.message = err.response.data;
}

// send error to bot
await sendError(code, err, req, stack, message);

// unmodify error to hide details returned as api response
if (modified !== undefined) {
finalError.name = modified.name;
Expand Down
2 changes: 1 addition & 1 deletion src/v2/repository/firestorm/modpacks.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class ModpacksFirestormRepository implements ModpacksRepository {

public getThumbnail(id: number): Promise<string> {
return axios(`https://api.curseforge.com/v1/mods/${id}`, {
headers: { "x-api-key": process.env.CURSE_FORGE_API_KEY },
headers: { "x-api-key": process.env.CURSEFORGE_API_KEY },
}).then((res) => res.data.data.logo.thumbnailUrl);
}
}
4 changes: 2 additions & 2 deletions src/v2/repository/firestorm/mods.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class ModsFirestormRepository implements ModsRepository {

public getThumbnail(id: number): Promise<string> {
return axios(`https://api.curseforge.com/v1/mods/${id}`, {
headers: { "x-api-key": process.env.CURSE_FORGE_API_KEY },
headers: { "x-api-key": process.env.CURSEFORGE_API_KEY },
}).then((res) => {
const url = res?.data?.data?.logo?.thumbnailUrl;
if (url) {
Expand All @@ -28,7 +28,7 @@ export default class ModsFirestormRepository implements ModsRepository {

public getCurseForgeName(id: number): Promise<string> {
return axios(`https://api.curseforge.com/v1/mods/${id}`, {
headers: { "x-api-key": process.env.CURSE_FORGE_API_KEY },
headers: { "x-api-key": process.env.CURSEFORGE_API_KEY },
}).then((res) => {
const name = res?.data?.data?.name;
if (name) {
Expand Down

0 comments on commit 322c153

Please sign in to comment.