-
Notifications
You must be signed in to change notification settings - Fork 1
Programming Phase II
This was a pretty productive week and we are finally done with all the changes related to the backend of the sugarizer server. We have made tons of new updates and tried to include as many features as we can. So finally, the API routes look as follows:
// Register auth API
app.post('/login', auth.login);
app.post('/signup', auth.signup);
// Register activities list API
app.get("/api/v1/activities", activities.findAll);
app.get("/api/v1/activities/:id", activities.findById);
// Register users API
app.get("/api/v1/users", users.findAll);
app.get("/api/v1/users/:uid", users.findById);
app.post("/api/v1/users", users.addUser);
app.put("/api/v1/users/:uid", users.updateUser);
app.delete("/api/v1/users/:uid", users.removeUser);
// Register stats API
app.get("/api/v1/stats", stats.findAll);
app.post("/api/v1/stats", stats.addStats);
app.delete("/api/v1/stats", stats.deleteStats);
// Register journal API
app.get("/api/v1/journal", journal.findAll);
app.get("/api/v1/journal/:jid", journal.findJournalContent);
app.post("/api/v1/journal/:jid", journal.addEntryInJournal);
app.put("/api/v1/journal/:jid", journal.updateEntryInJournal);
app.delete("/api/v1/journal/:jid", journal.removeInJournal);
We will talk about few important changes in the following section of the blog.
[GET] /api/v1/journal will result in
[
{
"_id": "5946d4fc9f0e36686c50a548",
"shared": true
},
{
"_id": "5946ecbc11e5015e72953751",
"shared": false
}
]Similarly, [GET] /api/v1/journal?type=shared will result in
[
{
"_id": "5946ecbc11e5015e72953751",
"shared": true
}
][GET] /api/v1/journal/5946ecbc11e5015e72953751 will result in entries in this format. Filters, sorting and field limiting can be applied subsequently to get more desired results.
{
"entries":[
{
"metadata":{
"title":"Read me !",
"title_set_by_user":"0",
"activity":"org.france.PaintActivity",
"activity_id":"caa97e48-d33c-470a-99e9-495ff02afe01",
"creation_time":1423341000747,
"timestamp":1423341066909,
"file_size":0,
"user_id":"536dd30aadcd557f2a9d648b",
"buddy_name":"Sugarizer server",
"buddy_color":{
"stroke":"#005FE4",
"fill":"#FF2B34"
}
},
"objectId":"4837240f-bf78-4d22-b936-3db96880f0a0"
},
{
"metadata":{
"title":"Physics JS Activity",
"title_set_by_user":"0",
"activity":"org.olpg-france.physicsjs",
"activity_id":"43708a15-f48e-49b1-85ef-da4c1419b364",
"creation_time":1436003632237,
"timestamp":1436025389565,
"file_size":0,
"user_id":"536dd30aadcd557f2a9d648b",
"buddy_name":"Lionel",
"buddy_color":{
"stroke":"#00A0FF",
"fill":"#F8E800"
}
},
"objectId":"2acbcd69-aa14-4273-8a9f-47642b41ad9d"
}
],
"offset":0,
"limit":10,
"total":2,
"links":{
}
}[GET] /api/v1/journal/5946ecbc11e5015e72953751?sort=-timestamp&fields=text,metadata&aid=org.france.PaintActivity
{
"entries":[
{
"metadata":{
"title":"Read me !",
"title_set_by_user":"0",
"activity":"org.france.PaintActivity",
"activity_id":"caa97e48-d33c-470a-99e9-495ff02afe01",
"creation_time":1423341000747,
"timestamp":1423341066909,
"file_size":0,
"user_id":"536dd30aadcd557f2a9d648b",
"buddy_name":"Sugarizer server",
"buddy_color":{
"stroke":"#005FE4",
"fill":"#FF2B34"
}
},
"text": "content of the entry",
"objectId":"4837240f-bf78-4d22-b936-3db96880f0a0"
}
],
"offset":0,
"limit":10,
"total":1,
"links":{
}
}More details will be available about each route probably by next week when we are done with the documentation of the API.
Stay Tuned!