Skip to content
Myr

parse-body.ts

This file

Path

test/helpers/parse-body.ts

9 lines · 321 bytes · TypeScript

Last changed by

Require Node.js 22Sindre Sorhusbefore adoptionf1da0fc

History of this file

Take it

The walk stopped after 200 commits: lines older than 37fc250 point at it.

Require Node.js 22Sindre Sorhusbefore adoptionf1da0fc

line 1why, one step back
1import {text} from 'node:stream/consumers';

Add retry count to `afterResponse` and `beforeError` hooks (#763)Sindre Sorhusbefore adoption37fc250

lines 2–4why, one step back
2import type {Request} from 'express';
34export const parseJsonBody = async <T = any>(request: Request): Promise<T> => {

Require Node.js 22Sindre Sorhusbefore adoptionf1da0fc

lines 5–6why, one step back
5 const body = await text(request);
6 return JSON.parse(body) as T;

Add retry count to `afterResponse` and `beforeError` hooks (#763)Sindre Sorhusbefore adoption37fc250

lines 7–8why, one step back
7};
8

Require Node.js 22Sindre Sorhusbefore adoptionf1da0fc

line 9why, one step back
9export const parseRawBody = async (request: Request): Promise<string> => text(request);