Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glynnbird/ccurllib
Utility library for ccurl
https://github.com/glynnbird/ccurllib
Last synced: about 1 month ago
JSON representation
Utility library for ccurl
- Host: GitHub
- URL: https://github.com/glynnbird/ccurllib
- Owner: glynnbird
- License: apache-2.0
- Created: 2019-08-23T10:30:56.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-31T10:45:18.000Z (4 months ago)
- Last Synced: 2024-10-01T15:41:28.705Z (about 2 months ago)
- Language: JavaScript
- Size: 202 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ccurllib
Utilities for the ccurl utility to provide:
- simple HTTPS request utility.
- api key cache persisted on user's disk## Usage
```js
const cc = require('ccurllib')
const opts = {
url: 'https://myapi.myserver.com/_all_docs',
qs: {
limit: 4
},
headers: {
myheader: 'x'
},
method: 'get'
}
const response = await cc.request(opts)
// {
// status: 200,
// result: [ '_replicator', 'aaa', 'aardvark', 'alerts1' ]
// }
```or for a Node.js stream:
```js
const responseStream = await cc.requestStream(opts)
```or if doing IAM requests, simply add an environment variable `IAM_API_KEY`. The library will only exchange the IAM key for an access token if we don't have one cached or the cached one has expired.
Cached tokens are stored in `.ccurl/keycache.json`. Simply remove this file to invalidate all cache keys.