File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,38 @@ const defaults: ParseOptions = {
35
35
castTypes : true
36
36
}
37
37
38
+ /**
39
+ * Parses `multipart/form-data` body and returns an object with the data of that body
40
+ *
41
+ * @param request HTTP IncomingMessage object
42
+ * @param options Parser options
43
+ *
44
+ * Simplest usage example:
45
+ *
46
+ * ```js
47
+ * import {createServer} from "http"
48
+ * import {parse} from "then-busboy"
49
+ *
50
+ * const handler = (req, res) => parse(req)
51
+ * .then(async body => {
52
+ * const result = []
53
+ *
54
+ * for (const [path, value] of body) {
55
+ * result.push([path, isFile(value) ? await value.text() : value])
56
+ * }
57
+ *
58
+ * res.setHeader("Content-Type", "application/json")
59
+ * res.end(JSON.stringify(Body.json(result)))
60
+ * })
61
+ * .catch(error => {
62
+ * res.statusCode = error.status || 500
63
+ * res.end(error.message)
64
+ * })
65
+ *
66
+ * createServer(handler)
67
+ * .listen(2319, () => console.log("Server started on http://localhost:2319"))
68
+ * ```
69
+ */
38
70
export const parse = (
39
71
request : IncomingMessage ,
40
72
options : ParseOptions = { }
You can’t perform that action at this time.
0 commit comments