mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-18 01:54:23 +01:00
fix: handle production source failures and reduce ZIP work
This commit is contained in:
1 parent
bd7d6f0bef
commit
705f7c428a
16 files changed
+612
-86
No files matched your search
@@ -39,6 +39,7 @@ import config from "../config";
|
||||
import { resolveTrustProxy } from "./trustProxy";
|
||||
import { requestRateLimitKey } from "./rate-limit-key";
|
||||
import { createLogger, serializeError } from "../core/logger";
|
||||
import { serverOptions } from "./server-options";
|
||||
import { monitorRequests } from "../core/request-monitoring";
|
||||
import { startPerformanceMonitoring } from "../core/performance-monitoring";
|
||||
import { getAnonymizationPoolStats } from "../core/anonymization-pool";
|
||||
@@ -113,6 +114,7 @@ function indexResponse(req: express.Request, res: express.Response) {
|
||||
export default async function start() {
|
||||
const app = express();
|
||||
app.use(monitorRequests("api"));
|
||||
app.use(serverOptions);
|
||||
startPerformanceMonitoring("api", getAnonymizationPoolStats);
|
||||
app.set("query parser", "extended");
|
||||
app.use("/service", createReviewCapabilities(process.env.REVIEW_SERVICE_KEYS));
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
/** The asterisk request target asks about the server, not a session or route. */
|
||||
export const serverOptions: RequestHandler = (req, res, next) => {
|
||||
if (req.originalUrl !== "*") return next();
|
||||
if (req.method !== "OPTIONS") { res.status(400).json({ error: "invalid_request" }); return; }
|
||||
res.setHeader("Allow", "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS");
|
||||
res.status(204).end();
|
||||
};
|
||||
Reference in new issue
Block a user