Skip to content

Commit ffe9f29

Browse files
authored
Merge 2364f91 into b5fe6e6
2 parents b5fe6e6 + 2364f91 commit ffe9f29

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

.github/API/request.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ middleware to transform `req.body` into a raw string:
120120
```ts
121121
import opine from "https://deno.land/x/opine@2.1.1/mod.ts";
122122

123+
import { readAll } from "https://deno.land/std@0.120.0/streams/conversion.ts";
124+
123125
const app = opine();
124126

125127
const bodyParser = async function (req, res, next) {
126-
const rawBody = await Deno.readAll(req.raw);
128+
const rawBody = await readAll(req.raw);
127129
const decodedBody = decoder.decode(rawBody);
128130

129131
req.body = decodedBody;

deps.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export { default as EventEmitter } from "https://deno.land/std@0.120.0/node/even
2626
export { Sha1 } from "https://deno.land/std@0.120.0/hash/sha1.ts";
2727
export {
2828
readableStreamFromReader,
29+
readAll,
2930
readerFromStreamReader,
3031
} from "https://deno.land/std@0.120.0/streams/conversion.ts";
3132

src/middleware/bodyParser/read.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type { NextFunction, OpineRequest, OpineResponse } from "../../types.ts";
3333
import {
3434
gunzip as createGunzip,
3535
inflate as createInflate,
36+
readAll,
3637
} from "../../../deps.ts";
3738
import { createError } from "../../utils/createError.ts";
3839

@@ -123,7 +124,7 @@ async function decodeContent(
123124

124125
let raw;
125126
try {
126-
raw = await Deno.readAll(req.body);
127+
raw = await readAll(req.body);
127128
} catch (err) {
128129
throw createError(400, err);
129130
}

test/units/middleware.basic.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { opine } from "../../mod.ts";
2-
import { expect, superdeno } from "../deps.ts";
2+
import { expect, readAll, superdeno } from "../deps.ts";
33
import { describe, it } from "../utils.ts";
44

55
describe("middleware", function () {
@@ -20,7 +20,7 @@ describe("middleware", function () {
2020

2121
app.use(async function (req, res) {
2222
res.set("Content-Type", "application/json; charset=utf-8");
23-
const raw = await Deno.readAll(req.body);
23+
const raw = await readAll(req.body);
2424
const data = (new TextDecoder()).decode(raw);
2525
res.end(data);
2626
});

0 commit comments

Comments
 (0)