This is a solution to the problem posed here.
It's written in Node.js using the Express.js framework and a PostgeSQL database and hosted on Heroku.
Database migration files are located here.
curl https://vast-bayou-6783.herokuapp.com/user -d "email=bennett@gmail.com&first=bennett&last=hiles"
https://vast-bayou-6783.herokuapp.com/user/1
A credit looks like:
curl https://vast-bayou-6783.herokuapp.com/user/1/tx -d "amount=20"
A debit looks like:
curl https://vast-bayou-6783.herokuapp.com/user/1/tx -d "amount=-10"
https://vast-bayou-6783.herokuapp.com/user/1/tx
- varchar(120) should be able to handle enough characters for email (same for first and last name)
- "it should fail" (from the problem description) is handled by the application returning with an error message
- Create tests
- Return error status codes when errors occur
- When you create a new user the API response should be the new record as a JSON object
- Throw an error for invalid email addresses
- /user/:id/tx for a user that doesn't exist should return an error instead of an empty array