From 39aebb2cfc053c1cf8837738ac4154a454e44ff1 Mon Sep 17 00:00:00 2001 From: uurgothat Date: Wed, 17 Nov 2021 22:28:22 +0300 Subject: [PATCH] Add instance route --- api/src/middlewares/Authentication.ts | 1 + api/src/routes/policies/instance/domains.ts | 16 ++++++++++++++++ api/src/routes/policies/instance/limits.ts | 11 +++++++++++ api/src/routes/policies/instance/meta.ts | 12 ++++++++++++ util/src/entities/Config.ts | 6 ++++++ 5 files changed, 46 insertions(+) create mode 100644 api/src/routes/policies/instance/domains.ts create mode 100644 api/src/routes/policies/instance/limits.ts create mode 100644 api/src/routes/policies/instance/meta.ts 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: {