Node server for SlugNote
- node.js
- mongoDB
- redis
- Run
git clone https://*USER*@github.com/slugnote/slugnote.git - Run
npm installin the 'slugnote' directory
node server
Send an HTTP POST method to the server at the URI of the desired command with the body of the request being a valid JSON object (Like examples)
curl -k -H "content-type: application/json" -d "JSON OBJECT" https://slugnote.com:8080/URI
- -k
- Ignore the fact that we have a self-signed certificate (We should probably get a proper cert)
- -H "content-type: application/json"
- This cannot change. Basically just sets an HTTP header telling the server this is JSON
- -d "JSON OBJECT"
- Sets the body of the HTTP request. JSON OBJECT must be valid JSON and must be the JSON that corresponds with the correct request
- https://slugnote.com:8080/URI
- URI should be the URI of the request you're making. For example,
/user/create
- URI should be the URI of the request you're making. For example,
token/getttl
{
"authToken" : "uxoDiXpwq5TlGxt88fcPW4S+h4U9eDcCLQTaHY4vh/UT69LuYploxHI6TUOE+PrTquhQIagC5TKJjY6O+3gEGg=="
}
{
"status" : 200,
"call" : "getTokenTTL",
"data" : {
"ttl": 53020
}
}
curl -H "content-type: application/json" -d "{\"authToken\":\"uxoDiXpwq5TlGxt88fcPW4S+h4U9eDcCLQTaHY4vh/UT69LuYploxHI6TUOE+PrTquhQIagC5TKJjY6O+3gEGg==\"}" https://169.233.236.39/post/user/gettokenttl -k
note/create
{
"authToken" : "Gk1nJqj2X+IppQ7K0710EzUBcZKsq1+l3bXdfIMxP8w1L3b+rG2Uf4SIO+42UTGhF2G8XZNuJUyh/ipx1HTG4w==",
"noteUser" : "username",
"noteTime" : "2014-03-29:10:10",
"noteFormat" : "String, PDF, JPEG",
"noteData" : [ "Array" ],
"noteInfo" : {
"name" : "Example Note",
"description" : "This note is an example.",
"class" : {
"id" : 1234567,
"name" : "Class Name"
},
"term" : {
"id" : 012345,
"name" : "{Season} Semester"
},
"teacher" : {
"id" : 012345,
"name" : "First Last"
}
}
}
{
"status" : 200,
"call" : "createNote",
"data" : {
"noteId" : "533700001bd3b21d0eba3498"
}
note/info
{
"authToken" : "Gk1nJqj2X+IppQ7K0710EzUBcZKsq1+l3bXdfIMxP8w1L3b+rG2Uf4SIO+42UTGhF2G8XZNuJUyh/ipx1HTG4w==",
"noteId" : "533700001bd3b21d0eba3498"
}
{
"status" : 200,
"call" : "getNoteInfo",
"data" : {
"noteUser" : "username",
"noteTime" : "2014-03-29:10:10",
"noteFormat" : "String, PDF, JPEG",
"noteInfo" : {
"name" : "Example Note",
"description" : "This note is an example.",
"class" : {
"id" : 1234567,
"name" : "Class Name"
},
"term" : {
"id" : 012345,
"name" : "{Season} Semester"
},
"teacher" : {
"id" : 012345,
"name" : "First Last"
}
}
}
}
note/get
{
"authToken" : "Gk1nJqj2X+IppQ7K0710EzUBcZKsq1+l3bXdfIMxP8w1L3b+rG2Uf4SIO+42UTGhF2G8XZNuJUyh/ipx1HTG4w==",
"noteId" : "533700001bd3b21d0eba3498"
}
{
"status" : 200,
"call" : "getNote",
"data" : {
"noteUser" : "username",
"noteTime" : "2014-03-29:10:10",
"noteFormat" : "String, PDF, JPEG",
"noteData" : [ "Array" ],
"noteInfo" : {
"name" : "Example Note",
"description" : "This note is an example.",
"class" : {
"id" : 1234567,
"name" : "Class Name"
},
"term" : {
"id" : 012345,
"name" : "{Season} Semester"
},
"teacher" : {
"id" : 012345,
"name" : "First Last"
}
}
}
}
user/create
{
"userName" : "First Last",
"userEmail" : "abc@def.com",
"userPassword" : "password"
}
{
"status" : 200,
"call" : "createUser",
"data" : {
"authToken" : "Gk1nJqj2X+IppQ7K0710EzUBcZKsq1+l3bXdfIMxP8w1L3b+rG2Uf4SIO+42UTGhF2G8XZNuJUyh/ipx1HTG4w=="
"userId" : "533700001bd3b21d0eba3498"
}
}
user/get
{
"authToken" : "Gk1nJqj2X+IppQ7K0710EzUBcZKsq1+l3bXdfIMxP8w1L3b+rG2Uf4SIO+42UTGhF2G8XZNuJUyh/ipx1HTG4w==",
"userId" : "533700001bd3b21d0eba3498"
}
{
"status" : 200,
"call" : "getUserInfo",
"data" : {
"userId" : "533700001bd3b21d0eba3498",
"userEmail" : "abc@def.com",
"userName" : "First Last"
}
}
university/create
{
"authToken" : "Gk1nJqj2X+IppQ7K0710EzUBcZKsq1+l3bXdfIMxP8w1L3b+rG2Uf4SIO+42UTGhF2G8XZNuJUyh/ipx1HTG4w==",
"universityName" : "UC Santa Cruz"
}
{
"status" : 200,
"call" : "createUniversity",
"data" : {
"universityId" : "533700001bd3b21d0eba3498",
"universityName" : "UC Santa Cruz"
}
}
university/list
{
"authToken" : "Gk1nJqj2X+IppQ7K0710EzUBcZKsq1+l3bXdfIMxP8w1L3b+rG2Uf4SIO+42UTGhF2G8XZNuJUyh/ipx1HTG4w==",
"universityId" : "533700001bd3b21d0eba3498"
}
{
"status" : 200,
"call" : "getUniversityList",
"data" : {
"universityId" : "533700001bd3b21d0eba3498"
"array" : { [
"courseId" : "123958201bd3b21d0eba4521"
"courseName" : "CMPS 12B"
] }
}
}
- Successful return codes will be returned as code '200'
- Unsuccessful return codes will be returned in a range from '1001-1100', as specified below
Authentication Error, authToken invalid.
Lookup Error, objectId invalid.
Password creation failed, password invalid.
User lookup failed.
Note creation failed, unable to be saved.
Note lookup failed, objectId invalid.
Course lookup failed, objectId associated with Note returned invalid.
Term lookup failed, objectId associated with Note returned invalid.
Teacher lookup failed, objectId associated with Note returned invalid.
University creation failed, unable to be saved.
University lookup failed, objectId invalid.
Course list lookup failed.