chec / cli Goto Github PK
View Code? Open in Web Editor NEWA command line interface for using the Chec API
Home Page: https://chec.io
License: BSD 3-Clause "New" or "Revised" License
A command line interface for using the Chec API
Home Page: https://chec.io
License: BSD 3-Clause "New" or "Revised" License
COMMANDS
help display help for chec
log Get full detail about a given log ID
login Log into your Chec.io account
logout Log out of your account
logs Show a summary of your API requests processed by Chec.io
register Register an account with Chec.io
request Run abstract API request
I think we could group these. They represent auth commands, and then functional commands. That might be a good start?
In case their API keys have changed or been cycled in the background, this might help them to get running again.
By default requests will be authorized with your production keys. We should allow a flag to let people run requests with their sandbox keys instead.
We'll need a request helper to authorize API calls from our commands. We can probably re-use a lot of the logic that exists already in the login-helper
login()
method.
Hello! When I login & run
$ chec request GET /v1/products > chec.json
I'm suprised to find the first line of output is - Processing...\n
before the JSON data starts.
Shouldn't this be sent to stderr
, so my shell redirect produces a valid JSON file?
If I run the logs
command before I've logged in, I get this error:
Error: Could not locate required credentials to subscribe to a log feed
at LogFeed.getConfiguration (~/dev/chec/chec-cli/src/helpers/log-feed.js:14:13)
at LogFeed.getChannel (~/dev/chec/chec-cli/src/helpers/log-feed.js:27:33)
at LogFeed.onLog (~/dev/chec/chec-cli/src/helpers/log-feed.js:22:10)
at LogsCommand.registerLogFeed (~/dev/chec/chec-cli/src/commands/logs.js:101:10)
at LogsCommand.run (~/dev/chec/chec-cli/src/commands/logs.js:53:10)
at LogsCommand._run (~/dev/chec/chec-cli/node_modules/@oclif/command/lib/command.js:44:31)
We could use a hook to ensure that you're logged in before running various commands, and show a friendly message like "You aren't logged in yet, run chec-cli login
then try again"
If I want to use chec request POST /v1/assets
to upload an asset, the file contents must be a base64 encoded string (for local uploads anyway). This easily exceeds bash's limit for length, so we could add a --file
argument (-f
short) to specify a file to load and provide as the request body. Maybe it could be JSON only for now.
If I were to set up multiple demo stores, I wouldn't necessarily want to have multiple sets of products seeded. If it were to ask to confirm whether I wanted this I could say no before it does this.
I'd set up my chec logs
command to watch for a while, then run some operations. I navigated into a couple of the log entries individually, then back to the list again between each. The second I went back to the list I got this error:
[2020-12-23 17:00:45] 402 rqst_16P556C38svK08771645 /v1/checkouts/chkt_4oGbZxYBrJRKKw
[2020-12-23 17:01:31] 402 rqst_16w0ud9vU6x708771691 /v1/checkouts/chkt_Mo1r6yqVAZXRe5
⠋ Listening for logs from Chec. Press "up" to navigate through the exisiting logs(node:20964) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 keypress listeners added to [ReadStream]. Use emitter.setMaxListeners() to increase limit
⠙ Listening for logs from Chec. Press "up" to navigate through the exisiting logs
So we can identify API requests from the CLI.
Something like User-Agent: chec/cli
for example
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.