Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli client [DO NOT MERGE] #65

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

cli client [DO NOT MERGE] #65

wants to merge 18 commits into from

Conversation

pcgeek86
Copy link
Contributor

@pcgeek86 pcgeek86 commented Sep 26, 2016

  • Separate dealership REST API into dealership.js
  • Moved dbutils.js to its own, shared directory, and updated references
  • Started CLI client to call REST APIs, using Python Click library

@wallnerryan could you help me figure out what's causing this error when POST'ing to /dealerships?

This is the PowerShell call that I'm using, sending a simple JSON payload in the HTTP body.

Invoke-RestMethod -Uri http://localhost:8000/dealerships -Method POST `
  -Body ([PSCustomObject]@{ 
    name = 'asdf'; 
    phone = '555-555-5556'; 
    addr = '123 street' } | ConvertTo-Json) `
  -Headers @{ 'Content-Type' = 'application/json' }

image

@pcgeek86 pcgeek86 changed the title API enhancements API enhancements [DO NOT MERGE] Sep 26, 2016
rdb.table('Dealership').insert(req.body).run(conn);
conn.close();
});
res.send({message: 'hello'})
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like leftovers? If the insert was a success the endpoint should return a success message or json object that has "success" or "failure" etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed -- this is just there until I can figure out what the bug is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually, it will return HTTP 201 (Created).

@@ -0,0 +1,16 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this file @pcgeek86 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmmm, good question. I presume this is coming from Visual Studio Code. Here's an article that talks about it:

https://code.visualstudio.com/docs/languages/javascript

I can remove it from the repo, although it might make sense to leave it. We could both benefit from it, if we use VSCode, although it obviously isn't a requirement. Looks like it mainly provides Intellisense hints to VSCode.

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets remove it, since its really not source code the particular the the app, but the specific developer.

…ook like connection close before query was finished
@wallnerryan
Copy link
Contributor

@pcgeek86 should work now.

$:-> curl -H "Content-Type: application/json" -X POST -d '{"name": "asdfg", "phone": "555-555-5555", "addr": "1234 Main St." }' localhost:8000/dealerships
{"message":"hello"}$:->

Logs from front end container

Creating a new dealership
{ name: 'asdf', phone: '555-555-5555', addr: '123 Main St.' }
Dealership name is asdf
Connecting to RethinkDB
{ deleted: 0,
  errors: 0,
  generated_keys: [ 'a7430c19-6576-4e51-85b1-b20ab51af630' ],
  inserted: 1,
  replaced: 0,
  skipped: 0,
  unchanged: 0 }

@wallnerryan
Copy link
Contributor

@pcgeek86 you can merge in master to this branch, master is updated against new FH instance and slaves use new cli now. So should build correctly without FH/cli specific issues

@wallnerryan
Copy link
Contributor

I will be working on this to update the APIs, then merge in. Once done, I will merge the APIs back into #75 so we can write more tests and merge those in.

@wallnerryan
Copy link
Contributor

Renaming this now that #75 is merged. This PR can now get rid of any API related things because #75 included it.

@wallnerryan wallnerryan changed the title API enhancements [DO NOT MERGE] cli client [DO NOT MERGE] Oct 11, 2016
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.

2 participants