@azure-utils/storybooks
Version:
Utils to upload and manage Storybooks via Azure Functions and storage.
26 lines (23 loc) • 712 B
text/typescript
import type {
HttpRequest,
HttpResponseInit,
InvocationContext,
} from "@azure/functions";
import { responseError } from "./response-utils";
export function validateBuildUploadZipBody(
request: HttpRequest,
context: InvocationContext
): HttpResponseInit | undefined {
const body = request.body;
if (!body) {
return responseError("Request body is required", context, 400);
}
const contentLength = request.headers.get("Content-Length");
if (!contentLength) {
return responseError("Content-Length header is required", context, 411);
}
if (parseInt(contentLength, 10) === 0) {
return responseError("Request body should have length > 0", context, 400);
}
return undefined;
}