diff --git a/assets/background.png b/assets/public/background.png similarity index 100% rename from assets/background.png rename to assets/public/background.png diff --git a/assets/checkLocale.js b/assets/public/checkLocale.js similarity index 100% rename from assets/checkLocale.js rename to assets/public/checkLocale.js diff --git a/assets/dff87c953f43b561d71fbcfe8a93a79a.png b/assets/public/dff87c953f43b561d71fbcfe8a93a79a.png similarity index 100% rename from assets/dff87c953f43b561d71fbcfe8a93a79a.png rename to assets/public/dff87c953f43b561d71fbcfe8a93a79a.png diff --git a/assets/endpoints.json b/assets/public/endpoints.json similarity index 100% rename from assets/endpoints.json rename to assets/public/endpoints.json diff --git a/assets/features.json b/assets/public/features.json similarity index 100% rename from assets/features.json rename to assets/public/features.json diff --git a/assets/fosscord-login.css b/assets/public/fosscord-login.css similarity index 100% rename from assets/fosscord-login.css rename to assets/public/fosscord-login.css diff --git a/assets/fosscord.css b/assets/public/fosscord.css similarity index 100% rename from assets/fosscord.css rename to assets/public/fosscord.css diff --git a/assets/openapi.json b/assets/public/openapi.json similarity index 100% rename from assets/openapi.json rename to assets/public/openapi.json diff --git a/assets/schemas.json b/assets/public/schemas.json similarity index 100% rename from assets/schemas.json rename to assets/public/schemas.json diff --git a/assets/user.css b/assets/public/user.css similarity index 100% rename from assets/user.css rename to assets/public/user.css diff --git a/src/api/middlewares/Translation.ts b/src/api/middlewares/Translation.ts index 741d6baf..c0b7a4b8 100644 --- a/src/api/middlewares/Translation.ts +++ b/src/api/middlewares/Translation.ts @@ -5,9 +5,11 @@ import i18nextMiddleware from "i18next-http-middleware"; import i18nextBackend from "i18next-node-fs-backend"; import { Router } from "express"; +const ASSET_FOLDER_PATH = path.join(__dirname, "..", "..", "..", "assets"); + export async function initTranslation(router: Router) { - const languages = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales")); - const namespaces = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales", "en")); + const languages = fs.readdirSync(path.join(ASSET_FOLDER_PATH, "locales")); + const namespaces = fs.readdirSync(path.join(ASSET_FOLDER_PATH, "locales", "en")); const ns = namespaces.filter((x) => x.endsWith(".json")).map((x) => x.slice(0, x.length - 5)); await i18next @@ -19,7 +21,7 @@ export async function initTranslation(router: Router) { fallbackLng: "en", ns, backend: { - loadPath: __dirname + "/../../locales/{{lng}}/{{ns}}.json" + loadPath: path.join(ASSET_FOLDER_PATH, "locales") + "/{{lng}}/{{ns}}.json", }, load: "all" }); diff --git a/src/api/routes/guilds/#guild_id/widget.png.ts b/src/api/routes/guilds/#guild_id/widget.png.ts index 721b59fb..c17d511e 100644 --- a/src/api/routes/guilds/#guild_id/widget.png.ts +++ b/src/api/routes/guilds/#guild_id/widget.png.ts @@ -34,7 +34,7 @@ router.get("/", route({}), async (req: Request, res: Response) => { const sizeOf = require("image-size"); // TODO: Widget style templates need Fosscord branding - const source = path.join(__dirname, "..", "..", "..", "..", "assets", "widget", `${style}.png`); + const source = path.join(__dirname, "..", "..", "..", "..", "..", "assets", "widget", `${style}.png`); if (!fs.existsSync(source)) { throw new HTTPError("Widget template does not exist.", 400); }