Skip to content

Commit

Permalink
capping max note size to 10kb
Browse files Browse the repository at this point in the history
  • Loading branch information
Athlon1600 committed Apr 26, 2024
1 parent 0bd70ba commit dbf199b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions backend/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export class Server {

protected enablePost() {

// 10 kilobytes of text MAX!! - ~10K chars
// 10 kilobytes of text MAX!! - ~10K chars, 5-6 word pages
this.app.use(express.urlencoded({
extended: true,
limit: "100kb"
limit: "10kb"
}));

// Expects: Content-Type: "text/plain"
this.app.use(express.text({
limit: "100kb"
limit: "10kb"
}));
}

Expand Down Expand Up @@ -69,6 +69,14 @@ export class Server {

let msg = err.toString();

if (msg.includes("PayloadTooLargeError") || msg.includes("entity too large")) {

return res.status(413).json({
status: 413,
error: 'Note text limit reached'
});
}

return res.status(500).json({
status: 500,
error: msg
Expand Down

0 comments on commit dbf199b

Please sign in to comment.