Skip to content

feat(#6250): use fetch in couch-request#9746

Merged
dianabarsan merged 15 commits intomasterfrom
6250-use-fetch-in-couch-request
Jan 27, 2025
Merged

feat(#6250): use fetch in couch-request#9746
dianabarsan merged 15 commits intomasterfrom
6250-use-fetch-in-couch-request

Conversation

@dianabarsan
Copy link
Copy Markdown
Member

@dianabarsan dianabarsan commented Jan 15, 2025

Description

Removes request-promise-native.

#6250

Code review checklist

  • UI/UX backwards compatible: Test it works for the new design (enabled by default). And test it works in the old design, enable can_view_old_navigation permission to see the old design.
  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.

Compose URLs

If Build CI hasn't passed, these may 404:

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

Signed-off-by: Diana Barsan <barsan@medic.org>
Signed-off-by: Diana Barsan <barsan@medic.org>
Signed-off-by: Diana Barsan <barsan@medic.org>
Comment thread shared-libs/couch-request/test/couch-request.js Fixed
Comment thread shared-libs/couch-request/test/couch-request.js Fixed
Signed-off-by: Diana Barsan <barsan@medic.org>
- handing server sending JSON headers but no content
- double slash paths
- from data -> json

Signed-off-by: Diana Barsan <barsan@medic.org>
Signed-off-by: Diana Barsan <barsan@medic.org>
json: true,
body: { urns: ['tel:phone1'], text: 'message1', },
headers: { Accept: 'application/json', Authorization: 'Token customRapidPro' },
headers: { Authorization: 'Token customRapidPro' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Token customRapidPro" is used as [authorization header](1).
json: true,
body: { urns: ['tel:phone2'], text: 'message2', },
headers: { Accept: 'application/json', Authorization: 'Token customRapidPro' },
headers: { Authorization: 'Token customRapidPro' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Token customRapidPro" is used as [authorization header](1).
json: true,
qs: { broadcast: `broadcast${i}` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Token key" is used as [authorization header](1).
json: true,
qs: { broadcast: `ref2` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Token key" is used as [authorization header](1).
json: true,
qs: { broadcast: `ref4` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Token key" is used as [authorization header](1).
uri: '/api/v2/messages.json',
qs: { broadcast: `ref1` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Token key" is used as [authorization header](1).
uri: '/api/v2/messages.json',
qs: { broadcast: `ref2` },
headers: { Accept: 'application/json', Authorization: 'Token key' },
headers: { Authorization: 'Token key' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Token key" is used as [authorization header](1).
Signed-off-by: Diana Barsan <barsan@medic.org>
Signed-off-by: Diana Barsan <barsan@medic.org>
Signed-off-by: Diana Barsan <barsan@medic.org>
Signed-off-by: Diana Barsan <barsan@medic.org>
Signed-off-by: Diana Barsan <barsan@medic.org>
@dianabarsan dianabarsan marked this pull request as ready for review January 21, 2025 05:36
Signed-off-by: Diana Barsan <barsan@medic.org>
await couchRequest.post({
url: 'http://a:b@marvel.net:5984/a',
auth: { username: 'admin', password: '123456' },
headers: { authorization: 'Bearer something' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Bearer something" is used as [authorization header](1).
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: 'Bearer something',

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Bearer something" is used as [authorization header](1).
@dianabarsan dianabarsan requested a review from jkuester January 22, 2025 06:03
@dianabarsan
Copy link
Copy Markdown
Member Author

Hi @jkuester ! Would you mind with some feedback over here? Appreciate it!!!

@jkuester
Copy link
Copy Markdown
Contributor

👍 Will have a look asap, but might not be until Friday.

Copy link
Copy Markdown
Contributor

@jkuester jkuester left a comment

Choose a reason for hiding this comment

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

Send it! Just a few minor non-blocking comments.

(Also just have to say that I hate JS. With no type safety this kind of refactor is terrifying. AFICT you caught all the user > username, pass > password, and statusCode > status changes, but it is really hard to tell....)

Comment thread shared-libs/couch-request/src/couch-request.js
Comment thread shared-libs/couch-request/src/couch-request.js Outdated
Comment thread shared-libs/couch-request/src/couch-request.js Outdated
Comment thread api/src/auth.js Outdated
Signed-off-by: Diana Barsan <barsan@medic.org>
Signed-off-by: Diana Barsan <barsan@medic.org>
const opts = {
url: 'http://a:b@marvel.net:5984/a',
auth: { username: 'admin', password: '123456' },
headers: { authorization: 'Bearer something' },

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "Bearer something" is used as [authorization header](1).
Signed-off-by: Diana Barsan <barsan@medic.org>
@dianabarsan dianabarsan merged commit 2c5a640 into master Jan 27, 2025
@dianabarsan dianabarsan deleted the 6250-use-fetch-in-couch-request branch January 27, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants