mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 09:07:46 +02:00
Scope portable import body limit
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
79684b3ad9
commit
7593fffb30
3 files changed
+17
-6
No files matched your search
@@ -1,11 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
DEFAULT_JSON_BODY_LIMIT,
|
||||
PORTABLE_JSON_BODY_LIMIT,
|
||||
PORTABLE_JSON_BODY_LIMIT_BYTES,
|
||||
} from "../http/body-limits.js";
|
||||
|
||||
describe("HTTP body limits", () => {
|
||||
it("keeps the global JSON parser at the established ceiling", () => {
|
||||
expect(DEFAULT_JSON_BODY_LIMIT).toBe("10mb");
|
||||
});
|
||||
|
||||
it("allows PAP-scale portable import JSON payloads", () => {
|
||||
expect(PORTABLE_JSON_BODY_LIMIT).toBe("64mb");
|
||||
expect(PORTABLE_JSON_BODY_LIMIT_BYTES).toBe(64 * 1024 * 1024);
|
||||
|
||||
+11
-6
@@ -59,7 +59,8 @@ import { pluginRegistryService } from "./services/plugin-registry.js";
|
||||
import { createHostClientHandlers } from "@paperclipai/plugin-sdk";
|
||||
import type { BetterAuthSessionResult } from "./auth/better-auth.js";
|
||||
import { createCachedViteHtmlRenderer } from "./vite-html-renderer.js";
|
||||
import { PORTABLE_JSON_BODY_LIMIT } from "./http/body-limits.js";
|
||||
import { DEFAULT_JSON_BODY_LIMIT, PORTABLE_JSON_BODY_LIMIT } from "./http/body-limits.js";
|
||||
import { COMPANY_IMPORT_API_PATH } from "./routes/company-import-paths.js";
|
||||
|
||||
type UiMode = "none" | "static" | "vite-dev";
|
||||
const FEEDBACK_EXPORT_FLUSH_INTERVAL_MS = 5_000;
|
||||
@@ -145,13 +146,17 @@ export async function createApp(
|
||||
},
|
||||
) {
|
||||
const app = express();
|
||||
const captureRawBody = (req: express.Request, _res: express.Response, buf: Buffer) => {
|
||||
(req as unknown as { rawBody: Buffer }).rawBody = buf;
|
||||
};
|
||||
|
||||
app.use(express.json({
|
||||
// Company import/export payloads can inline full portable packages.
|
||||
app.use(COMPANY_IMPORT_API_PATH, express.json({
|
||||
limit: PORTABLE_JSON_BODY_LIMIT,
|
||||
verify: (req, _res, buf) => {
|
||||
(req as unknown as { rawBody: Buffer }).rawBody = buf;
|
||||
},
|
||||
verify: captureRawBody,
|
||||
}));
|
||||
app.use(express.json({
|
||||
limit: DEFAULT_JSON_BODY_LIMIT,
|
||||
verify: captureRawBody,
|
||||
}));
|
||||
app.use(httpLogger);
|
||||
const privateHostnameGateEnabled = shouldEnablePrivateHostnameGuard({
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export const DEFAULT_JSON_BODY_LIMIT = "10mb";
|
||||
export const PORTABLE_JSON_BODY_LIMIT = "64mb";
|
||||
export const PORTABLE_JSON_BODY_LIMIT_BYTES = 64 * 1024 * 1024;
|
||||
Reference in new issue
Block a user