mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor: 🚚 Organize code into sub-packages, instead of a single large package
This commit is contained in:
parent
79742f47dc
commit
a6d3ebbeef
366 changed files with 942 additions and 833 deletions
20
packages/api/middlewares/boundary-check.ts
Normal file
20
packages/api/middlewares/boundary-check.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { ApiError } from "@versia/kit";
|
||||
import { createMiddleware } from "hono/factory";
|
||||
|
||||
export const boundaryCheck = createMiddleware(async (context, next) => {
|
||||
// Checks that FormData boundary is present
|
||||
const contentType = context.req.header("content-type");
|
||||
|
||||
if (
|
||||
contentType?.includes("multipart/form-data") &&
|
||||
!contentType.includes("boundary")
|
||||
) {
|
||||
throw new ApiError(
|
||||
400,
|
||||
"Missing FormData boundary",
|
||||
"You are sending a request with a multipart/form-data content type but without a boundary. Please include a boundary in the Content-Type header. For more information, visit https://stackoverflow.com/questions/3508338/what-is-the-boundary-in-multipart-form-data",
|
||||
);
|
||||
}
|
||||
|
||||
await next();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue