initial bullshit for federation v2

This commit is contained in:
Madeline
2023-09-26 01:22:40 +10:00
parent 8279cd05d6
commit c237247f89
37 changed files with 1310 additions and 121 deletions
+9 -33
View File
@@ -18,22 +18,21 @@
import {
Config,
Email,
initDatabase,
initEvent,
JSONReplacer,
registerRoutes,
Sentry,
WebAuthn,
ConnectionConfig,
ConnectionLoader,
Email,
JSONReplacer,
Sentry,
WebAuthn,
initDatabase,
initEvent,
registerRoutes,
setupMorganLogging,
} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { Server, ServerOptions } from "lambert-server";
import "missing-native-js-functions";
import morgan from "morgan";
import path from "path";
import { red } from "picocolors";
import { Authentication, CORS } from "./middlewares/";
import { BodyParser } from "./middlewares/BodyParser";
import { ErrorHandler } from "./middlewares/ErrorHandler";
@@ -79,23 +78,7 @@ export class SpacebarServer extends Server {
await Sentry.init(this.app);
WebAuthn.init();
const logRequests = process.env["LOG_REQUESTS"] != undefined;
if (logRequests) {
this.app.use(
morgan("combined", {
skip: (req, res) => {
let skip = !(
process.env["LOG_REQUESTS"]?.includes(
res.statusCode.toString(),
) ?? false
);
if (process.env["LOG_REQUESTS"]?.charAt(0) == "-")
skip = !skip;
return skip;
},
}),
);
}
setupMorganLogging(this.app);
this.app.set("json replacer", JSONReplacer);
@@ -147,13 +130,6 @@ export class SpacebarServer extends Server {
ConnectionLoader.loadConnections();
if (logRequests)
console.log(
red(
`Warning: Request logging is enabled! This will spam your console!\nTo disable this, unset the 'LOG_REQUESTS' environment variable!`,
),
);
return super.start();
}
}
+3 -3
View File
@@ -16,14 +16,14 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Router, Response, Request } from "express";
import { route } from "@spacebar/api";
import { getDatabase } from "@spacebar/util";
import { Datasource } from "@spacebar/util";
import { Request, Response, Router } from "express";
const router = Router();
router.get("/", route({}), (req: Request, res: Response) => {
if (!getDatabase()) return res.sendStatus(503);
if (!Datasource.isInitialized) return res.sendStatus(503);
return res.sendStatus(200);
});
+3 -3
View File
@@ -16,14 +16,14 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Router, Response, Request } from "express";
import { route } from "@spacebar/api";
import { getDatabase } from "@spacebar/util";
import { Datasource } from "@spacebar/util";
import { Request, Response, Router } from "express";
const router = Router();
router.get("/", route({}), (req: Request, res: Response) => {
if (!getDatabase()) return res.sendStatus(503);
if (!Datasource.isInitialized) return res.sendStatus(503);
return res.sendStatus(200);
});