summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorUmimaso <git@umimaso.com>2021-06-19 15:49:49 +0100
committerUmimaso <git@umimaso.com>2021-06-19 15:49:49 +0100
commit4c0c09c8bc800a9f16e16c00804f0e9074cdf15d (patch)
tree1cdc6368935d0359fa30e9377a1aeb96b5431de4 /src
parentfeat: add widget endpoints (diff)
downloadserver-4c0c09c8bc800a9f16e16c00804f0e9074cdf15d.tar.xz
feat: add routing for unversioned api requests
Create new route for /api which can handle routing of unversioned
requests. Update regex for NO_AUTHORIZATION_ROUTES to support
unversioned requests.
Diffstat (limited to 'src')
-rw-r--r--src/Server.ts1
-rw-r--r--src/middlewares/Authentication.ts10
2 files changed, 6 insertions, 5 deletions
diff --git a/src/Server.ts b/src/Server.ts

index 5ae65918..452bc1fe 100644 --- a/src/Server.ts +++ b/src/Server.ts
@@ -94,6 +94,7 @@ export class FosscordServer extends Server { this.app = prefix; this.routes = await this.registerRoutes(path.join(__dirname, "routes", "/")); + app.use("/api", prefix); // allow unversioned requests app.use("/api/v8", prefix); this.app = app; this.app.use(ErrorHandler); diff --git a/src/middlewares/Authentication.ts b/src/middlewares/Authentication.ts
index b53632a8..4b0f2b38 100644 --- a/src/middlewares/Authentication.ts +++ b/src/middlewares/Authentication.ts
@@ -3,11 +3,11 @@ import { HTTPError } from "lambert-server"; import { checkToken, Config } from "@fosscord/server-util"; export const NO_AUTHORIZATION_ROUTES = [ - /^\/api\/v8\/auth\/login/, - /^\/api\/v8\/auth\/register/, - /^\/api\/v8\/webhooks\//, - /^\/api\/v8\/gateway/, - /^\/api\/v8\/experiments/, + /^\/api(\/v\d+)?\/auth\/login/, + /^\/api(\/v\d+)?\/auth\/register/, + /^\/api(\/v\d+)?\/webhooks\//, + /^\/api(\/v\d+)?\/gateway/, + /^\/api(\/v\d+)?\/experiments/, /^\/api(\/v\d+)?\/guilds\/\d+\/widget\.(json|png)/ ];