Spaces:
Runtime error
Runtime error
File size: 1,916 Bytes
cd8bd0a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import { NextResponse } from "next/server";
import { deriveDefaultPlan } from "@omniroute/open-sse/services/compression/deriveDefaultPlan";
import { getCompressionSettings } from "@/lib/db/compression";
import { requireManagementAuth } from "@/lib/api/requireManagementAuth";
import { buildErrorBody } from "@omniroute/open-sse/utils/error";
// The default compression pipeline is no longer editable here. It is DERIVED from the
// per-engine toggle map (see open-sse deriveDefaultPlan). This route is a read-only shim:
// - GET → returns the derived default plan for the live config.
// - PUT/POST → rejected with a deprecation error (edit engines via /api/settings/compression).
const DEPRECATION_STATUS = 410;
const DEPRECATION_MESSAGE =
"The default compression pipeline is now derived from the engines map. " +
"Edit engines at /api/settings/compression.";
export async function GET(request: Request) {
const authError = await requireManagementAuth(request);
if (authError) return authError;
const config = await getCompressionSettings();
const plan = deriveDefaultPlan(config.engines ?? {}, config.enabled !== false);
// Shape kept compatible with prior consumers: `pipeline` is the ordered list of
// { engine, intensity? } steps, plus the effective `mode`.
return NextResponse.json({
mode: plan.mode,
pipeline: plan.stackedPipeline,
derived: true,
});
}
function deprecationResponse() {
return NextResponse.json(buildErrorBody(DEPRECATION_STATUS, DEPRECATION_MESSAGE), {
status: DEPRECATION_STATUS,
});
}
export async function PUT(request: Request) {
const authError = await requireManagementAuth(request);
if (authError) return authError;
return deprecationResponse();
}
export async function POST(request: Request) {
const authError = await requireManagementAuth(request);
if (authError) return authError;
return deprecationResponse();
}
|