-
Notifications
You must be signed in to change notification settings - Fork 1
API
#CRUD Endpoints
All database models have 4 endpoints (Create, Read, Update, Delete). The model 'transaction' is used in the examples below, but any of the other models (budget, envelope, profile) can be substituted. You must be logged in in order to gain access to the end points.
###CREATE
- POST /transaction
- REQUIRES = a JSON object in request body
- RETURNS = id of newly created object
###READ
- GET /transaction/:id
- REQUIRES = id of an object as request parameter (passed in through the url)
- RETURNS = JSON encoded object
###UPDATE
- PUT /transaction/:id
- REQUIRES = id of an object as request parameter, and JSON object in request body
- RETURNS = 200 response if successful
###DELETE
- DELETE /transaction/:id
- REQUIRES = id of an object as request parameter
- RETURNS = 200 response if successful
- GET /envelopes/:budgetId
- returns list of envelopes
[
{
"_id": "54ff81ace7fec44828cdd34d",
"budgetId": "54ff55b55b9b572c0cac3d87",
"name": "Groceries",
"budgetAmount": 100,
"currentAmount": 100,
"__v": 0
},...
]
- GET /transactions /:envelopeId
- returns list of transactions
[
{
"_id": "54ff7ad2fd8b32fc13cec3d6",
"envelopeId": "54ff7a5ffd8b32fc13cec3d4",
"amount": 10,
"entity": "no clue",
"type": "sometype",
"__v": 0,
"createdOn": "2015-03-10T23:14:26.971Z",
"occuredOn": "2015-03-10T23:14:26.970Z"
},...
]
#Other Endpoints ###REGISTER USER
-
POST /register
-
REQUIRES = json object formatted like the example below
-
RETURNS = On success, redirects to homepage. On failure, gives json encoded array of reasons for failure
Example json register object
{
"name": "Richard Dick",
"email" : "budgettogetrich@gmail.com",
"password" : "budget4lyfe",
"confirmPassword" : "budget4lyfe",
"username" : "coolest_user_ever"
}
Example failed register response (list of json objects describing errors)
[
{
"param": "email",
"msg": "E-mail address is already in-use",
"value": "budgettogetrich@gmail.com"
}
]
###LOGIN USER
-
POST /login
-
REQUIRES = json object formatted like the example below
-
RETURNS = json user object on success (200 status code), Unauthorized on failure (401 status code)
Example of login object
{
"email" : "budgettogetrich@gmail.com",
"password" : "budget4lyfe"
}
Successful response for login
{
"user": {
"_id": "54dabb77b3aa32d4145238af",
"name": "Richard Dick",
"email": "budgettogetrich@gmail.com",
"username": "coolest_user_ever",
"__v": 0,
"provider": "local",
"roles": [
"authenticated"
]
},
"redirect": false
}
###OAuths
- GET /auth/facebook
- GET /auth/google