diff --git a/api/src/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts
index 2d9ccf57..2d9ccf57 100644
--- a/api/src/middlewares/Authentication.ts
+++ b/src/api/middlewares/Authentication.ts
diff --git a/api/src/middlewares/BodyParser.ts b/src/api/middlewares/BodyParser.ts
index 35db3c6f..35db3c6f 100644
--- a/api/src/middlewares/BodyParser.ts
+++ b/src/api/middlewares/BodyParser.ts
diff --git a/api/src/middlewares/CORS.ts b/src/api/middlewares/CORS.ts
index 20260cf9..20260cf9 100644
--- a/api/src/middlewares/CORS.ts
+++ b/src/api/middlewares/CORS.ts
diff --git a/api/src/middlewares/ErrorHandler.ts b/src/api/middlewares/ErrorHandler.ts
index 8a046e06..8a046e06 100644
--- a/api/src/middlewares/ErrorHandler.ts
+++ b/src/api/middlewares/ErrorHandler.ts
diff --git a/api/src/middlewares/RateLimit.ts b/src/api/middlewares/RateLimit.ts
index 47180b62..47180b62 100644
--- a/api/src/middlewares/RateLimit.ts
+++ b/src/api/middlewares/RateLimit.ts
diff --git a/api/src/middlewares/TestClient.ts b/src/api/middlewares/TestClient.ts
index 4fe631cb..a47ff396 100644
--- a/api/src/middlewares/TestClient.ts
+++ b/src/api/middlewares/TestClient.ts
@@ -7,11 +7,13 @@ import { Config } from "@fosscord/util";
import { AssetCacheItem } from "../util/entities/AssetCacheItem"
import { green } from "picocolors";
+const AssetsPath = path.join(__dirname, "..", "..", "..", "assets")
+
export default function TestClient(app: Application) {
const agent = new ProxyAgent();
//build client page
- let html = fs.readFileSync(path.join(__dirname, "..", "..", "client_test", "index.html"), { encoding: "utf8" });
+ let html = fs.readFileSync(path.join(AssetsPath, "index.html"), { encoding: "utf8" });
html = applyEnv(html);
html = applyInlinePlugins(html);
html = applyPlugins(html);
@@ -19,7 +21,7 @@ export default function TestClient(app: Application) {
//load asset cache
let newAssetCache: Map<string, AssetCacheItem> = new Map<string, AssetCacheItem>();
- let assetCacheDir = path.join(__dirname, "..", "..", "assets", "cache");
+ let assetCacheDir = path.join(AssetsPath, "cache");
if(process.env.ASSET_CACHE_DIR)
assetCacheDir = process.env.ASSET_CACHE_DIR
@@ -32,7 +34,7 @@ export default function TestClient(app: Application) {
newAssetCache = new Map<string, AssetCacheItem>(Object.entries(JSON.parse(rawdata.toString())));
}
- app.use("/assets", express.static(path.join(__dirname, "..", "..", "assets")));
+ app.use("/assets", express.static(path.join(AssetsPath)));
app.get("/assets/:file", async (req: Request, res: Response) => {
delete req.headers.host;
let response: FetchResponse;
@@ -113,7 +115,7 @@ function applyEnv(html: string): string {
function applyPlugins(html: string): string {
// plugins
- let files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "plugins"));
+ let files = fs.readdirSync(path.join(AssetsPath, "plugins"));
let plugins = "";
files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script src='/assets/plugins/${x}'></script>\n`; });
return html.replaceAll("<!-- plugin marker -->", plugins);
@@ -121,7 +123,7 @@ function applyPlugins(html: string): string {
function applyInlinePlugins(html: string): string{
// inline plugins
- let files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "inline-plugins"));
+ let files = fs.readdirSync(path.join(AssetsPath, "inline-plugins"));
let plugins = "";
files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script src='/assets/inline-plugins/${x}'></script>\n\n`; });
return html.replaceAll("<!-- inline plugin marker -->", plugins);
@@ -129,9 +131,9 @@ function applyInlinePlugins(html: string): string{
function applyPreloadPlugins(html: string): string{
//preload plugins
- let files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "preload-plugins"));
+ let files = fs.readdirSync(path.join(AssetsPath, "preload-plugins"));
let plugins = "";
- files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script>${fs.readFileSync(path.join(__dirname, "..", "..", "assets", "preload-plugins", x))}</script>\n`; });
+ files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script>${fs.readFileSync(path.join(AssetsPath, "preload-plugins", x))}</script>\n`; });
return html.replaceAll("<!-- preload plugin marker -->", plugins);
}
diff --git a/api/src/middlewares/Translation.ts b/src/api/middlewares/Translation.ts
index baabf221..64b03bf8 100644
--- a/api/src/middlewares/Translation.ts
+++ b/src/api/middlewares/Translation.ts
@@ -6,8 +6,8 @@ import i18nextBackend from "i18next-node-fs-backend";
import { Router } from "express";
export async function initTranslation(router: Router) {
- const languages = fs.readdirSync(path.join(__dirname, "..", "..", "locales"));
- const namespaces = fs.readdirSync(path.join(__dirname, "..", "..", "locales", "en"));
+ const languages = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales"));
+ const namespaces = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales", "en"));
const ns = namespaces.filter((x) => x.endsWith(".json")).map((x) => x.slice(0, x.length - 5));
await i18next
@@ -19,7 +19,7 @@ export async function initTranslation(router: Router) {
fallbackLng: "en",
ns,
backend: {
- loadPath: __dirname + "/../../locales/{{lng}}/{{ns}}.json"
+ loadPath: __dirname + "/../../../assets/locales/{{lng}}/{{ns}}.json"
},
load: "all"
});
diff --git a/api/src/middlewares/index.ts b/src/api/middlewares/index.ts
index f0c50dbe..f0c50dbe 100644
--- a/api/src/middlewares/index.ts
+++ b/src/api/middlewares/index.ts
|