import { Middleware } from "rjweb-server";
import { createLogger } from "../logger";

const log = createLogger("HTTP");

export const mainMiddleware = new Middleware<{}, {}>("Main Middleware", "1.0.0")
  .load(() => {
    log.info("Main middleware loaded");
  })
  .httpRequest(async (_config, _server, _context, ctr) => {
    if (ctr.url.method === "OPTIONS") {
      ctr.status(204).print("");
    }
  })
  .export();
