1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-23 19:02:37 +01:00

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.
This commit is contained in:
Umimaso 2021-06-19 15:49:49 +01:00
parent f10df31f5c
commit 4c0c09c8bc
2 changed files with 6 additions and 5 deletions

View File

@ -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);

View File

@ -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)/
];