abernier / uest

https://www.npmjs.com/package/uest
9 stars 1 forks source link

request is deprecated #10

Open KenEucker opened 3 years ago

KenEucker commented 3 years ago

request/request#3142

Request has been deprecated. Can we get an update to replace this dependency?

abernier commented 3 years ago

I guess I should switch to another request library, one that supports cookies jar.

I have currently no time for a such re-write, but pull-request are really welcome :)

Since tests are already here, it should be easier not to break anything hopefully.

KenEucker commented 3 years ago

@abernier is there anything else besides supporting cookies jar that you can point out needs to be supported?

If I get the opportunity to translate my own experiences with got to this package I will look into running the tests and providing a PR.

abernier commented 3 years ago

@abernier is there anything else besides supporting cookies jar that you can point out needs to be supported?

  1. src/index.js

    Currently uest function is calling request with this signature:

    request(options, callback)

    as in: https://github.com/abernier/uest/blob/8fb4a17d79ce32426fae7f2f48f5868110e0da04/src/index.js#L68

    , defaulting options with some default values (baseUrl, jar, json): https://github.com/abernier/uest/blob/8fb4a17d79ce32426fae7f2f48f5868110e0da04/src/index.js#L33-L38

    =>

    implementing got in an adapter request function may be easier:

    function request(options, callback) {
      // ... use `got` inside
    }
  2. test/index.js

    I also rely on request to make HTTP requests to the express server in the tests.

    • I wouldn't touch to this file until 1. is complete and passes all the tests.
    • then, you could replace request with got into test/index.js also (but it is fine if we leave a devDependency to request for now :))

If I get the opportunity to translate my own experiences with got to this package I will look into running the tests and providing a PR.

This would be awesome !! 🙏 I would review it for sure and help!

abernier commented 3 years ago

Also, from this issue, it seems quite easy to add support for cookies jar to got with the same library tough-cookie request is using :

const got = require("got")
const { CookieJar } = require("tough-cookie")

cookieJar = new CookieJar()
client = got.extend({ cookieJar })

However, this issue is about a problem with tough-cookie@2.5 which is the version request is still using... Hopefully, if no breaking changes in tough-cookie@latest's API since, it shouldn't be harder than that.

🍪

abernier commented 3 years ago

Hi @KenEucker, do you need any help ?

KenEucker commented 3 years ago

@abernier I would collaborate, for sure. I was able to use got as a replacement in another package but my attempts to work the cookiejar into this package were not successful.