- Git clone
git clone [email protected]:simplif-ai/Backend.git
- Use this command to install all dependencies needed from the package.js
npm install
- Everything should be setup so you can run:
npm start
- You'll see a message on console "Listening to port 8000"
npm test
or
gulp
- install eslint globally
npm install -g eslint
- run linter
npm run lint
💡 Optional parameters are followed by a "?".
Receives:
{
userID: Integer,
feedback: String
}
Sends:
{
success: Boolean,
error?: String
}
Receives:
{
email: String,
password: String
}
Sends:
{
sucess: Boolean,
token: String,
error?: String
}
Receives:
{
file: (pdf, pptx, txt)
}
Sends:
{
success: Bool,
text: [String], //this is the same as what is returned from the summarizertext endpoint!
error?: String
}
Receives:
{
email: String,
newEmail?: String,
newName?: String
}
Sends:
{
sucess: Boolean,
error?: String
}
Receives:
{
email: String
}
Sends:
{
sucess: Boolean,
name: String,
email: String,
prefersEmailUpdates: Integer (0 or 1),
postCount: Integer
}
Receives:
{
darkMode: Integer (0 or 1),
userID: Integer
}
Sends:
success: Boolean,
error?: String
💡 If no googleCode is provided, this endpoint returns an authorizeURL. If a valid googleCode is provided, a googleToken is returned.
Receives:
googleCode?: String
Sends:
authorizeURL?: String,
success: Boolean,
googleToken?: String
Receives:
{
googleToken: String,
event: Object
}
//note: Not all paramers are necessary. Only need to send in summary, start, and end.
var event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2015-05-28T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2015-05-28T17:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': '[email protected]'},
{'email': '[email protected]'},
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
};
Sends:
{
success: Boolean,
eventID: String,
error: String
}
Receives:
{
title: String,
text: String,
googleToken: String
}
Sends:
{
fileID: String,
error?: String
}
Receives:
{
email: String,
prefersEmailUpdates: Integer
}
Sends:
{
success: Boolean,
error?: String
}
Receives:
{
URL: String,
}
Sends:
{
success: Bool,
text: [String], //this is the same as what is returned from the summarizertext endpoint!
error?: String
}
Receives:
{
googleToken: String,
fileID: String,
collaboratorEmail: String
}
Sends:
{
success: Boolean,
error?: String
}
Receives:
{
googleToken: String,
email: String
}
Sends:
{
profilePictureURL: String,
error?: String
}
Receives:
{
name: String,
googleToken: String
}
Sends:
{
fileID: String,
error?: String
}
Receives:
{
name: String,
email: String,
password: String,
phoneNumber: Integer,
prefersEmailUpdates: Integer (0 or 1)
}
Sends:
{
sucess: Boolean,
error?: String
}
Receives:
{
email: String
}
Sends:
{
sucess: Boolean,
error?: String
}
Receives:
{
email: String,
newPassword: String
}
Sends:
{
success: Boolean,
error?: String
}
Receives:
{
email: String
}
Sends:
{
success: Boolean,
error?: String
}
This is a post request for sending an email of the link to reset the password. An email is sent in the body of the request where the reset password link will be sent to it using nodemailer in nodejs.
Receives:
{
"email": "[email protected]",
"text": "This is the summary text saved by the user",
"name": "CS 307 Notes"
}
Sends:
{
success: "true",
error: "error saving to db"
}
Receives:
{
"noteId": 13,
"noteText": "Hi this is a note text"
}
Send:
{
success: "true",
error: "error saving to db"
}
This is a post request to save the text summary of the user to the db. A row is created in the notes table which has the name of name of the text, date, noteText(for any additional notes from user), and userId(the account of the user that saved the summary, obtained from email in the json object request). A row is created in to summary table which has the summaryText(the user saved, in the json object request), the noteId(from the notes table), and the brevity.
To send text to the summarizer Api to summarize(using the middleware endpoint):
- Make a post http-request on the endpoint path 'http://localhost:8000/sumarizertext'.
- Add the text to be sent in a json object as below:
var mock = "Hi this is Lena's mock text";
var json = {
'text': mock
}
- The body received from the request of the middleware endpoint is in a stringified JSON object
- Handle that summarized data recieved as needed
- The data that will sent back to your api that called the middleware should be parsed to a JSON object #Example An example of a get request of making an api that does a post request to send the text to the middleware endpoint, receives the strignifies JSON object of the summarized data from the middleware endpoint, then makes a callback to send that data back to the api that called the middleware. This example doesn't handle or make any changes to the summarized data, but it could be added.
app.get('/mocktext', function(req, res) {
var mock = "Hi this is Lena's mock text";
var json = {
'text': mock
}
console.log("json of text: " + json)
var options = {
url: 'http://localhost:8000/sumarizertext',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(json)
}
request.post(options, function(error, response, body){
res.send(JSON.parse(body));
})
})