Skip to content

Commit

Permalink
Changelog: migration advice on beforeUpload.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed May 8, 2024
1 parent 2125400 commit 753a53b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,38 @@
- Depending on the type, only the parsers needed for certain endpoint are processed;
- This reverts changes on muting uploader logs related to non-eligible requests made in v18.5.2 (all eligible now).

```ts
import createHttpError from "http-errors";
import { createConfig } from "express-zod-api";

const before = createConfig({
server: {
upload: {
beforeUpload: ({ app, logger }) => {
app.use((req, res, next) => {
if (req.is("multipart/form-data") && !canUpload(req)) {
return next(createHttpError(403, "Not authorized"));
}
next();
});
},
},
},
});

const after = createConfig({
server: {
upload: {
beforeUpload: ({ request, logger }) => {
if (!canUpload(request)) {
throw createHttpError(403, "Not authorized");
}
},
},
},
});
```

## Version 18

### v18.5.2
Expand Down

0 comments on commit 753a53b

Please sign in to comment.