Skip to content

Commit

Permalink
remove process
Browse files Browse the repository at this point in the history
  • Loading branch information
jbolda committed Sep 12, 2024
1 parent 209ffa5 commit 1254dee
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/foundation/src/middleware/delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,13 @@ export function delayMiddleware(
const delayMax =
typeof delayResponses === "number" ? undefined : delayResponses?.maximum;

const minFromProcess = process.env.SIM_RESPONSE_DELAY_MIN
? process.env.SIM_RESPONSE_DELAY_MIN
: process.env.SIM_RESPONSE_DELAY;
const min = minFromProcess ? parseInt(minFromProcess, 10) : delayMin;

const maxFromProcess = process.env.SIM_RESPONSE_DELAY_MAX;
const max = maxFromProcess ? parseInt(maxFromProcess, 10) : delayMax;

return async function delayHandler(
request: Request,
response: Response,
next: NextFunction
) {
if (min || max) {
let timeoutDuration = calculateTimeoutDuration(min, max);
if (delayMin || delayMax) {
let timeoutDuration = calculateTimeoutDuration(delayMin, delayMax);
await new Promise<void>((resolve) => {
let timeoutHandle: NodeJS.Timeout | undefined = undefined;

Expand Down

0 comments on commit 1254dee

Please sign in to comment.