Skip to content

Commit 8cbee59

Browse files
committed
Add doc comments, style tweaks
1 parent d78f807 commit 8cbee59

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

packages/multipart-parser/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This is the changelog for [`multipart-parser`](https://github.com/mjackson/remix-the-web/tree/main/packages/multipart-parser). It follows [semantic versioning](https://semver.org/).
44

5+
## HEAD
6+
7+
- Add doc comments on custom error classes
8+
59
## v0.10.0 (2025-06-13)
610

711
This release represents a major refactoring and simplification of this library from a `async`/promise-based architecture to a generator that suspends the parser as parts are found.

packages/multipart-parser/examples/bun/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { MultipartParseError, parseMultipartRequest } from '@mjackson/multipart-parser';
22
import tmp from 'tmp';
33

4-
let server = Bun.serve({
4+
const server = Bun.serve({
55
port: 3000,
66
async fetch(request) {
77
if (request.method === 'GET') {

packages/multipart-parser/examples/node/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { MultipartParseError, parseMultipartRequest } from '@mjackson/multipart-
66

77
const PORT = 3000;
88

9-
let server = http.createServer(async (req, res) => {
9+
const server = http.createServer(async (req, res) => {
1010
if (req.method === 'GET') {
1111
res.writeHead(200, { 'Content-Type': 'text/html' });
1212
res.end(`

packages/multipart-parser/src/lib/multipart.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,29 @@ import { readStream } from './read-stream.ts';
44
import type { SearchFunction, PartialTailSearchFunction } from './buffer-search.ts';
55
import { createSearch, createPartialTailSearch } from './buffer-search.ts';
66

7+
/**
8+
* The base class for errors thrown by the multipart parser.
9+
*/
710
export class MultipartParseError extends Error {
811
constructor(message: string) {
912
super(message);
1013
this.name = 'MultipartParseError';
1114
}
1215
}
1316

17+
/**
18+
* An error thrown when the maximum allowed size of a header is exceeded.
19+
*/
1420
export class MaxHeaderSizeExceededError extends MultipartParseError {
1521
constructor(maxHeaderSize: number) {
1622
super(`Multipart header size exceeds maximum allowed size of ${maxHeaderSize} bytes`);
1723
this.name = 'MaxHeaderSizeExceededError';
1824
}
1925
}
2026

27+
/**
28+
* An error thrown when the maximum allowed size of a file is exceeded.
29+
*/
2130
export class MaxFileSizeExceededError extends MultipartParseError {
2231
constructor(maxFileSize: number) {
2332
super(`File size exceeds maximum allowed size of ${maxFileSize} bytes`);

0 commit comments

Comments
 (0)