add 2021 discord frontend support. i cant imagine hosting a web server and not using it proper use
Some checks failed
Nix build / build-nix (push) Has been cancelled
Some checks failed
Nix build / build-nix (push) Has been cancelled
This commit is contained in:
parent
49bc2be9bb
commit
d8c7bf1546
@ -22,6 +22,7 @@ import { Request, Response, Router } from "express";
|
||||
import { Server, ServerOptions } from "lambert-server";
|
||||
import morgan from "morgan";
|
||||
import path from "path";
|
||||
import express from "express";
|
||||
import { red } from "picocolors";
|
||||
import { initInstance } from "./util/handlers/Instance";
|
||||
|
||||
@ -90,18 +91,7 @@ export class SpacebarServer extends Server {
|
||||
await initTranslation(api);
|
||||
|
||||
this.routes = await registerRoutes(this, path.join(__dirname, "routes", "/"));
|
||||
|
||||
// 404 is not an error in express, so this should not be an error middleware
|
||||
// this is a fine place to put the 404 handler because its after we register the routes
|
||||
// and since its not an error middleware, our error handler below still works.
|
||||
// Emma [it/its] @ Rory& - the _ is required now, as pillarjs throw an error if you don't pass a param name now
|
||||
api.use("*_", (req: Request, res: Response) => {
|
||||
res.status(404).json({
|
||||
message: "404 endpoint not found",
|
||||
code: 0,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
this.app = app;
|
||||
|
||||
//app.use("/__development", )
|
||||
@ -113,8 +103,8 @@ export class SpacebarServer extends Server {
|
||||
app.use("/api", api); // allow unversioned requests
|
||||
|
||||
app.use("/imageproxy/:hash/:size/:url", ImageProxy);
|
||||
|
||||
app.get("/", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")));
|
||||
// for the 2021 discord frontend, can be replaced with anything else, just respect the way this file is structured
|
||||
app.use("/assets", express.static(path.join(PUBLIC_ASSETS_FOLDER, "client")));
|
||||
|
||||
app.get("/verify-email", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "verify.html")));
|
||||
|
||||
@ -125,8 +115,10 @@ export class SpacebarServer extends Server {
|
||||
app.get("/_spacebar/api/openapi.json", (req, res) => {
|
||||
res.sendFile(path.join(ASSETS_FOLDER, "openapi.json"));
|
||||
});
|
||||
|
||||
// current well-known location
|
||||
|
||||
app.use("*_", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")));
|
||||
|
||||
// current well-known location (new commit 22 nov 2025 from spacebar)
|
||||
app.get("/.well-known/spacebar", (req,res)=>{
|
||||
res.json({
|
||||
api: Config.get().api.endpointPublic
|
||||
@ -161,7 +153,7 @@ export class SpacebarServer extends Server {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
this.app.use(ErrorHandler);
|
||||
|
||||
ConnectionLoader.loadConnections();
|
||||
|
||||
Reference in New Issue
Block a user