summary refs log tree commit diff
diff options
context:
space:
mode:
authoruurgothat <cckhmck@gmail.com>2021-11-17 22:28:22 +0300
committeruurgothat <cckhmck@gmail.com>2021-11-17 22:28:22 +0300
commit39aebb2cfc053c1cf8837738ac4154a454e44ff1 (patch)
treec39ffd799cad1f68ac954c8870d04169949854bc
parentMerge pull request #496 from fosscord/translation (diff)
downloadserver-39aebb2cfc053c1cf8837738ac4154a454e44ff1.tar.xz
Add instance route
-rw-r--r--api/src/middlewares/Authentication.ts1
-rw-r--r--api/src/routes/policies/instance/domains.ts16
-rw-r--r--api/src/routes/policies/instance/limits.ts11
-rw-r--r--api/src/routes/policies/instance/meta.ts12
-rw-r--r--util/src/entities/Config.ts6
5 files changed, 46 insertions, 0 deletions
diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts
index 59a181e6..e6df6eeb 100644
--- a/api/src/middlewares/Authentication.ts
+++ b/api/src/middlewares/Authentication.ts
@@ -11,6 +11,7 @@ export const NO_AUTHORIZATION_ROUTES = [
 	"/experiments",
 	"/-/readyz",
 	"/-/healthz",
+	"/policies/instance/",
 	/\/guilds\/\d+\/widget\.(json|png)/
 ];
 
diff --git a/api/src/routes/policies/instance/domains.ts b/api/src/routes/policies/instance/domains.ts
new file mode 100644
index 00000000..b68763cc
--- /dev/null
+++ b/api/src/routes/policies/instance/domains.ts
@@ -0,0 +1,16 @@
+import { Router, Request, Response } from "express";
+import { route } from "@fosscord/api";
+import { Config } from "@fosscord/util";
+import { config } from "dotenv"
+const router = Router();
+const { cdn } = Config.get();
+
+const IdentityForm = {
+    cdn: cdn.endpointPublic || process.env.CDN || "http://localhost:3001",
+}
+
+router.get("/",route({}), async (req: Request, res: Response) => {
+	res.json(IdentityForm)
+});
+
+export default router;
diff --git a/api/src/routes/policies/instance/limits.ts b/api/src/routes/policies/instance/limits.ts
new file mode 100644
index 00000000..912908b7
--- /dev/null
+++ b/api/src/routes/policies/instance/limits.ts
@@ -0,0 +1,11 @@
+import { Router, Request, Response } from "express";
+import { route } from "@fosscord/api";
+import { Config } from "@fosscord/util";
+const router = Router();
+const { limits } = Config.get();
+
+router.get("/",route({}), async (req: Request, res: Response) => {
+	res.json(limits)
+});
+
+export default router;
diff --git a/api/src/routes/policies/instance/meta.ts b/api/src/routes/policies/instance/meta.ts
new file mode 100644
index 00000000..7a998487
--- /dev/null
+++ b/api/src/routes/policies/instance/meta.ts
@@ -0,0 +1,12 @@
+import { Router, Request, Response } from "express";
+import { route } from "@fosscord/api";
+import { Config } from "@fosscord/util";
+
+const router = Router();
+const { general } = Config.get();
+
+router.get("/",route({}), async (req: Request, res: Response) => {
+	res.json(general)
+});
+
+export default router;
diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts
index cac5d4da..fd83bc5a 100644
--- a/util/src/entities/Config.ts
+++ b/util/src/entities/Config.ts
@@ -49,6 +49,9 @@ export interface ConfigValue {
 		endpointPrivate: string | null;
 	};
 	general: {
+		instanceName: string;
+		instanceDescription: string | null;
+		frontPage: string | null;
 		instanceId: string;
 	};
 	limits: {
@@ -180,7 +183,10 @@ export const DefaultConfigOptions: ConfigValue = {
 		endpointPublic: null,
 	},
 	general: {
+		instanceName: "Fosscord Instance",
+		instanceDescription: "This is a Fosscord instance made in pre-relase days",
 		instanceId: Snowflake.generate(),
+		frontPage: null
 	},
 	limits: {
 		user: {