Repository: expo/expo
File: packages/expo-updates/e2e/fixtures/project_files/maestro/updates-server/server.ts (TypeScript)

Code before:
    server.close();
    server = null;
    isRunning = false;
  }
  messages = [];
  responsesToServe = [];
  updateRequest = null;
  manifestToServe = null;
  manifestHeadersToServe = null;
  serveChannel = null;
  multipartResponseToServe = null;
  requestedStaticFiles = [];
  logEntries = [];
}

function getRequestedStaticFilesLength() {
  return requestedStaticFiles.length;
}

function consumeRequestedStaticFiles() {
  const returnArray = requestedStaticFiles;
  requestedStaticFiles = [];
  return returnArray;
}

app.use(express.json());
app.use(
  '/static',
  (
    req: { url: string; headers: Record<string, string | undefined> },
    res: any,
    next: () => void
  ) => {
    requestedStaticFiles.push(path.basename(req.url));
    next();
  }
);
app.use('/static', express.static(path.resolve(__dirname, '..', '.static')));

app.get(
  '/notify/:string',
  (
    req: { params: { string: any } },
    res: {
      set: (arg0: string, arg1: string) => void;
      json: (arg0: any) => void;
      send: (arg0: string) => void;
    }
  ) => {
    messages.push(req.params.string);
    res.set('Cache-Control', 'no-store');

Review comment (bug):
@Kudo @alanjhughes @wschurman wyt of this change?

I made this change because `downloadProgress` events are frequent and increase the log entries significantly [here](https://github.com/expo/expo/blob/c54eb1e0cbc0f09af9e4308ff76ed9dca457d90e/packages/expo-updates/ios/EXUpdates/UpdatesStateMachine.swift#L319) which was causing `basic_updateInvalidAssetHash.yml` test failure. With `downloadProgress` the log size is `150kb` (PayloadTooLargeError as default limit is 100kb in express middleware) and without is `80kb`, for that specific testcase. Another option would be to avoid `downloadProgress` logging or throttle it. I did that [here](https://github.com/expo/expo/pull/41069/changes/2e182d6d6e1f83d769ae4877fa333fa420b28204) but reverted

Code after:
    server.close();
    server = null;
    isRunning = false;
  }
  messages = [];
  responsesToServe = [];
  updateRequest = null;
  manifestToServe = null;
  manifestHeadersToServe = null;
  serveChannel = null;
  multipartResponseToServe = null;
  requestedStaticFiles = [];
  logEntries = [];
}

function getRequestedStaticFilesLength() {
  return requestedStaticFiles.length;
}

function consumeRequestedStaticFiles() {
  const returnArray = requestedStaticFiles;
  requestedStaticFiles = [];
  return returnArray;
}

app.use(express.json({ limit: '200kb' }));
app.use(
  '/static',
  (
    req: { url: string; headers: Record<string, string | undefined> },
    res: any,
    next: () => void
  ) => {
    requestedStaticFiles.push(path.basename(req.url));
    next();
  }
);
app.use('/static', express.static(path.resolve(__dirname, '..', '.static')));

app.get(
  '/notify/:string',
  (
    req: { params: { string: any } },
    res: {
      set: (arg0: string, arg1: string) => void;
      json: (arg0: any) => void;
      send: (arg0: string) => void;
    }
  ) => {
    messages.push(req.params.string);
    res.set('Cache-Control', 'no-store');