Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Replace request with undici (Node's official fetch package), update dependencies, patch vulnerabilities #155

Merged
merged 2 commits into from
Dec 12, 2022

Conversation

eyelidlessness
Copy link
Contributor

More details in the commit notes.

The [request](https://www.npmjs.com/package/request) library has been deprecated for some time. This change:

1. Replaces use of request (the library) with the `request` function from [undici](https://github.com/nodejs/undici), which has been adopted by Node to provide an implementation of the now-standard [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) web API. This `request` API is almost but not quite identical to `fetch`, but undici's `fetch` is not available for some of our currently supported Node versions.

2. Refactors the three very similar dev-facing API endpoints provided by enketo-transformer's `app.js`. This isn't strictly necessary but it was easier to reason about than applying the same changes repeatedly, and...

3. ... caught/fixed a bug where the POST handler always returned a 400 Bad Request for valid POST bodies with an `xform` property.
Note: express was _downgraded_ to address a vulnerability in its qs subdependency. I don't expect any compatibility issues, and its usage here is dev-only. I also added types for express to validate this.
Copy link
Contributor

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quickly verified that I could track every bit of functionality in the factoring out of common code. Using undici feels like the right choice. I see no issue with downgrading express.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants