Closed dsebastien closed 3 years ago
As version 9.x of Nano doesn't use the request
library anymore then the requestDefaults
configuration is not the same. As it happens, axios & request both accept a "auth" object, so this code does work:
const Nano = require('.')
const nano = Nano({url: 'http://localhost:5984', requestDefaults: { auth: { username: 'MYUSER', password: 'MYPASS'}}})
nano.db.list().then(console.log)
so "it doesn't compile" is purely a Typescript thing easily solved by adding to the requestDefaultsOptions
interface.
Good news then. Thanks for looking into this.
Expected Behavior
Expected the following to still compile / work using nano with TypeScript:
Current Behavior
With 9.0.x installed, the above code fails to compile because the
auth
key does not exist anymore. After this commit: https://github.com/apache/couchdb-nano/commit/8655d40d213a3a3c2bd73d64953ce065628cbb12#diff-2dd1f9d8d0579eec00aede543000fb3cd7ee90d47953c9f4d2fb07353f7fa59eR19There is a new interface:
With a weird naming convention (camelCase instead of PascalCase) and with very basic types. The
auth
option does not seem to exist anymore and I couldn't find a lot of information about this change. Is it still possible to pass these somehow?Possible Solution
It would be nice for the new
requestDefaults
interface to be more complete and more clearly indicate which options can be passed (parameter names / types).In any case, being able to pass the authentication information once is also nice to have.
Steps to Reproduce (for bugs)
Upgrade to nano 9.0.x & compile using TypeScript
Context
Cannot centrally manage authentication for the nano http client.
Your Environment