项目作者: etture

项目描述 :
RESTful API for acqua / acqua를 위한 RESTful API
高级语言: JavaScript
项目地址: git://github.com/etture/acqua-api.git
创建时间: 2018-08-18T08:02:59Z
项目社区:https://github.com/etture/acqua-api

开源协议:

下载


acqua

Short for ‘acquaintance’, acqua is a service for managing your acquaintances. Never forget anything about your friends, coworkers, and family again; make memos on acqua, and it will remind you of your friends’ details right before you meet them. Use the acqua calendar for additional functionality like schedule integration with your friends and reminders.

acqua API

한국어 버전

RESTful API for acqua

Server written in Node.js, database in MySQL

Deployed to Heroku, current URL: https://acqua-api.herokuapp.com

Android Client

React.js Web Client

Table of Contents

API Endpoints

API Description

Authentication

/api/auth/signup

  • HTTP method: POST
  • Endpoint for user to sign up
  • On success, parameters are saved to the users table in the database and a JWT token is returned
  • Request
    • Body
      1. {
      2. "email": "email address",
      3. "password": "password",
      4. "first_name": "first name",
      5. "last_name": "last name",
      6. "phone_number": "phone number"
      7. }
  • Response
    1. {
    2. "isSuccess": true,
    3. "user": {
    4. "id": 231
    5. "last_name": "Belfort",
    6. "first_name": "Jordan",
    7. "email": "apitest@gmail.com",
    8. "phone_number": "01049182881"
    9. }
    10. "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE0LCJpYXQiOjE1MzQ3NTI3MTAzMzF9.ZYo5qXNkGJ7l1rvCaKIYLknkUJNa3YjXT87Do-PyQZI"
    11. }

/api/auth/signin

  • HTTP method: POST
  • Endpoint for user to sign in
  • On success, a JWT token is returned
  • Request
    • Body
      1. {
      2. "email": "email address",
      3. "password": "password"
      4. }
  • Response
    1. {
    2. "isSuccess": true,
    3. "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjE0LCJpYXQiOjE1MzQ3NTI3MTAzMzF9.ZYo5qXNkGJ7l1rvCaKIYLknkUJNa3YjXT87Do-PyQZI"
    4. }

    User Entries

    /api/entries/get/:friend_id

  • HTTP method: GET
  • Return a list of memo entries written by user about other friends
  • user identified by JWT token provided in the header
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • URL
      • friend_id (entries table friend_id column :left_right_arrow: users table id column)
  • Response
    1. [
    2. {
    3. "id": 423,
    4. "user_id": 2,
    5. "friend_id": 8,
    6. "memo": "memo written by user 2 about user 8, blah blah...",
    7. "created_at": "2018-08-19T12:30:21.000Z",
    8. "last_modified": "2018-08-19T12:30:21.000Z"
    9. },
    10. {
    11. "id": 516,
    12. "user_id": 2,
    13. "friend_id": 8,
    14. "memo": "another memo written by user 2 about user 8, blah blah...",
    15. "created_at": "2018-08-20T06:32:17.000Z",
    16. "last_modified": "2018-08-20T06:32:17.000Z"
    17. },
    18. ...
    19. ]

/api/entries/post/:friend_id

  • HTTP method: POST
  • Save a memo entry written by user about friend to the database
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "memo": "memo about a friend"
      3. }
    • URL
      • friend_id (entries table friend_id column :left_right_arrow: users table id column)
  • Response
    1. {
    2. "isSuccess": true,
    3. "user_id": 2,
    4. "friend_id": 8,
    5. "entry_id": 610
    6. }

/api/entries/edit/:entry_id

  • HTTP method: PUT
  • Edit user‘s memo about friend using entry_id
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "memo": "edited memo"
      3. }
    • URL
      • entry_id (entries table id column)
  • Response
    1. {
    2. "isSuccess": true,
    3. "user_id": 15,
    4. "friend_id": 13,
    5. "entry_id": 9
    6. }

Friends List

/api/friends/get

  • HTTP method: GET
  • Return a list of user‘s friends
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
  • Response
    1. {
    2. "friends_list": [
    3. {
    4. "id": 7,
    5. "last_name": "Park",
    6. "first_name": "Mark",
    7. "email": "parkmark@gmail.com",
    8. "phone_number": "01099291028"
    9. },
    10. {
    11. "id": 9,
    12. "last_name": "Jong",
    13. "first_name": "Soon",
    14. "email": "jongsoon@gmail.com",
    15. "phone_number": "01012345678"
    16. },
    17. ...
    18. ]
    19. }

/api/friends/add

  • HTTP method: `POST’
  • Add a friend for user
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "friend_id": "friend_id"
      3. }
  • Response
    1. {
    2. "isSuccess": true,
    3. "friend_id": 8
    4. }

/api/friends/nickname/:friend_id

  • HTTP method: PUT
  • Edit friend‘s nickname to be displayed to user
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "nickname": "new nickname"
      3. }
    • URL
      • friend_id (friends table friend_id column :left_right_arrow: users table id column)
  • Response
    1. {
    2. "isSuccess": true,
    3. "friend_id": 7,
    4. "nickname": "Wolverine"
    5. }

User Profile

/api/profiles/self

  • HTTP method: GET
  • Return own user‘s complete profile information
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
  • Response
    1. {
    2. "basic_profile": {
    3. "id": 116,
    4. "last_name": "Lee",
    5. "first_name": "Paul",
    6. "email": "paul@gmail.com",
    7. "phone_number": "01031887610"
    8. },
    9. "expanded_profile": {
    10. "gender": "male",
    11. "birthday": null,
    12. "profile_picture": null,
    13. "high_school": "Walnut High School",
    14. "university_name": "Emory University",
    15. "university_major": "Computer Science",
    16. "graduate_masters_name": null,
    17. "graduate_masters_major": null,
    18. "graduate_phd_name": null,
    19. "graduate_phd_major": null
    20. },
    21. "work_history": [
    22. {
    23. "id": 231,
    24. "user_id": 116,
    25. "status": "current",
    26. "company": "Twitter",
    27. "position": "Developer",
    28. "start_date": "2017-06-20T15:00:00.000Z",
    29. "end_date": null
    30. },
    31. {
    32. "id": 182,
    33. "user_id": 116,
    34. "status": "past",
    35. "company": "Samsung",
    36. "position": "Intern",
    37. "start_date": "2015-11-22T15:00:00.000Z",
    38. "end_date": null
    39. },
    40. ...
    41. ]
    42. "current_work": [
    43. {
    44. "id": 231,
    45. "user_id": 16,
    46. "status": "current",
    47. "company": "Twitter",
    48. "position": "Developer",
    49. "start_date": "2017-06-20T15:00:00.000Z",
    50. "end_date": null
    51. },
    52. ...
    53. ]
    54. }

/api/profiles/:user_id

  • HTTP method: GET
  • Return another user‘s complete profile information
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • URL
      • user_id (users table id column :left_right_arrow: profiles table user_id column :left_right_arrow: works table user_id column)
  • Response
    1. {
    2. "basic_profile": {
    3. "id": 116,
    4. "last_name": "Lee",
    5. "first_name": "Paul",
    6. "email": "paul@gmail.com",
    7. "phone_number": "01031887610"
    8. },
    9. "expanded_profile": {
    10. "gender": "male",
    11. "birthday": null,
    12. "profile_picture": null,
    13. "high_school": "Walnut High School",
    14. "university_name": "Emory University",
    15. "university_major": "Computer Science",
    16. "graduate_masters_name": null,
    17. "graduate_masters_major": null,
    18. "graduate_phd_name": null,
    19. "graduate_phd_major": null
    20. },
    21. "work_history": [
    22. {
    23. "id": 231,
    24. "user_id": 116,
    25. "status": "current",
    26. "company": "Twitter",
    27. "position": "Developer",
    28. "start_date": "2017-06-20T15:00:00.000Z",
    29. "end_date": null
    30. },
    31. {
    32. "id": 182,
    33. "user_id": 116,
    34. "status": "past",
    35. "company": "Samsung",
    36. "position": "Intern",
    37. "start_date": "2015-11-22T15:00:00.000Z",
    38. "end_date": null
    39. },
    40. ...
    41. ]
    42. "current_work": [
    43. {
    44. "id": 231,
    45. "user_id": 16,
    46. "status": "current",
    47. "company": "Twitter",
    48. "position": "Developer",
    49. "start_date": "2017-06-20T15:00:00.000Z",
    50. "end_date": null
    51. },
    52. ...
    53. ]
    54. }

/api/profiles/basic/self

  • HTTP method: GET
  • Return basic, private profile information about own user
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
  • Response
    1. {
    2. "id": 231
    3. "last_name": "Belfort",
    4. "first_name": "Jordan",
    5. "email": "apitest@gmail.com",
    6. "phone_number": "01049182881"
    7. }

/api/profiles/basic/:user_id

  • HTTP method: GET
  • Return basic, private profile information about another user
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • URL
      • user_id (users table id column)
  • Response
    1. {
    2. "id": 231
    3. "last_name": "Belfort",
    4. "first_name": "Jordan",
    5. "email": "apitest@gmail.com",
    6. "phone_number": "01049182881"
    7. }

/api/profiles/basic/update

  • HTTP method: PUT
  • Update own user‘s basic, private profile information, except for password
  • For each request parameter, if the update parameter is true, the item is updated to value; if false, the item is not updated
  • updatedItems in the response contains only items that were updated
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "last_name": {
      3. "update": true or false,
      4. "value": "updated value"
      5. },
      6. "first_name": {
      7. "update": true or false,
      8. "value": "updated value"
      9. },
      10. "email": {
      11. "update": true or false,
      12. "value": "updated value"
      13. },
      14. "phone_number": {
      15. "update": true or false,
      16. "value": "updated value"
      17. }
      18. }
  • Response
    1. {
    2. "isSuccess": true,
    3. "updatedItems": {
    4. "last_name": "Kim",
    5. "first_name": "Chulsoo",
    6. "email": "chulsoo@gmail.com"
    7. "phone_number": "01012345678"
    8. }
    9. }

/api/profiles/basic/update_pw

  • HTTP method: PUT
  • Update own user‘s password
  • Receive original password and new password as parameters
  • If the original password matches, place the request; otherwise, an error occurs
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "old_password": "original password",
      3. "new_password": "new password"
      4. }
  • Response
    1. {
    2. "isSuccess": true
    3. }

/api/profiles/profile/self

  • HTTP method: GET
  • Return own user‘s public profile information
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
  • Response
    1. {
    2. "user_id": 13,
    3. "gender": "female",
    4. "birthday": null,
    5. "profile_picture": null,
    6. "high_school": "Centennial High School",
    7. "university_name": "Korea University",
    8. "university_major": "Computer Science",
    9. "graduate_masters_name": null,
    10. "graduate_masters_major": null,
    11. "graduate_phd_name": null,
    12. "graduate_phd_major": null
    13. }

/api/profiles/profile/:user_id

  • HTTP method: GET
  • Return another user‘s public profile information
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • URL
      • user_id (profiles table user_id column :left_right_arrow: users table id column)
  • Response
    1. {
    2. "user_id": 13,
    3. "gender": "female",
    4. "birthday": null,
    5. "profile_picture": null,
    6. "high_school": "Centennial High School",
    7. "university_name": "Korea University",
    8. "university_major": "Computer Science",
    9. "graduate_masters_name": null,
    10. "graduate_masters_major": null,
    11. "graduate_phd_name": null,
    12. "graduate_phd_major": null
    13. }

/api/profiles/profile/update

  • HTTP method: PUT
  • Update own user‘s public profile information
  • For each request parameter, if the update parameter is true, the item is updated to value; if false, the item is not updated
  • updatedItems in the response contains only items that were updated
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "gender": {
      3. "update": true or false,
      4. "value": "updated value"
      5. },
      6. "birthday": {
      7. "update": true or false,
      8. "value": "updated value"
      9. },
      10. "profile_picture": {
      11. "update": true or false,
      12. "value": "updated value"
      13. },
      14. "high_school": {
      15. "update": true or false,
      16. "value": "updated value"
      17. },
      18. "university_name": {
      19. "update": true or false,
      20. "value": "updated value"
      21. },
      22. "university_major": {
      23. "update": true or false,
      24. "value": "updated value"
      25. },
      26. "graduate_masters_name": {
      27. "update": true or false,
      28. "value": "updated value"
      29. },
      30. "graduate_masters_major": {
      31. "update": true or false,
      32. "value": "updated value"
      33. },
      34. "graduate_phd_name": {
      35. "update": true or false,
      36. "value": "updated value"
      37. },
      38. "graduate_phd_major": {
      39. "update": true or false,
      40. "value": "updated value"
      41. }
      42. }
  • Response
    1. {
    2. "isSuccess": true,
    3. "updatedItems": {
    4. "gender": "male",
    5. "birthday": "1994-07-18",
    6. "profile_picture": "path/images/1923812.png",
    7. "high_school": "Los Osos High School",
    8. "university_name": "Brown University",
    9. "university_major": "Anthropology",
    10. "graduate_masters_name": "Harvard University",
    11. "graduate_masters_major": "Political Science",
    12. "graduate_phd_name": "Yale University",
    13. "graduate_phd_major": "Economics"
    14. }
    15. }

/api/profiles/work/self

  • HTTP method: GET
  • Return own user‘s work history information
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
  • Response
    1. {
    2. "work_history": [
    3. {
    4. "id": 231,
    5. "user_id": 16,
    6. "status": "current",
    7. "company": "Google",
    8. "position": "Developer",
    9. "start_date": "2017-06-20T15:00:00.000Z",
    10. "end_date": null
    11. },
    12. {
    13. "id": 320,
    14. "user_id": 16,
    15. "status": "past",
    16. "company": "Samsung",
    17. "position": "Intern",
    18. "start_date": "2015-11-22T15:00:00.000Z",
    19. "end_date": null
    20. },
    21. ...
    22. ],
    23. "current_work": [
    24. {
    25. "id": 231,
    26. "user_id": 16,
    27. "status": "current",
    28. "company": "Google",
    29. "position": "Developer",
    30. "start_date": "2017-06-20T15:00:00.000Z",
    31. "end_date": null
    32. },
    33. ...
    34. ]
    35. }

/api/profiles/work/:user_id

  • HTTP method: GET
  • Return another user‘s work history information
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • URL
      • user_id (works table user_id column :left_right_arrow: users table id column)
  • Response
    1. {
    2. "work_history": [
    3. {
    4. "id": 231,
    5. "user_id": 16,
    6. "status": "current",
    7. "company": "Google",
    8. "position": "Developer",
    9. "start_date": "2017-06-20T15:00:00.000Z",
    10. "end_date": null
    11. },
    12. {
    13. "id": 320,
    14. "user_id": 16,
    15. "status": "past",
    16. "company": "Samsung",
    17. "position": "Intern",
    18. "start_date": "2015-11-22T15:00:00.000Z",
    19. "end_date": null
    20. },
    21. ...
    22. ],
    23. "current_work": [
    24. {
    25. "id": 231,
    26. "user_id": 16,
    27. "status": "current",
    28. "company": "Google",
    29. "position": "Developer",
    30. "start_date": "2017-06-20T15:00:00.000Z",
    31. "end_date": null
    32. },
    33. ...
    34. ]
    35. }

/api/profiles/work/add

  • HTTP method: POST
  • Add a new item to user‘s work history
  • company, position, start_date are required parameters
  • end_date can be included if work has ended, in which case the ended parameter should be set to true and value provided. status is set to past automatically.
  • If work is ongoing, set ended to false and leave value empty. status is set to current automatically.
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "company": "company name",
      3. "position": "job position",
      4. "start_date": "starting date",
      5. "end_date": {
      6. "ended": true or false,
      7. "value": "ending date if work ended"
      8. }
      9. }
  • Response
    1. {
    2. "isSuccess": true,
    3. "work": {
    4. "id": 118,
    5. "user_id": 165,
    6. "company": "JP Morgan",
    7. "position": "Financial Analyst",
    8. "start_date": "2016-08-01",
    9. "end_date": "2018-06-01",
    10. "status": "past"
    11. }
    12. }

/api/profiles/work/update/:item_id

  • HTTP method: PUT
  • Update own user‘s work history information
  • Whenever both of, or either one of, start_date and end_date are updated, it must be checked that start_date is not later than end_date. If the conditions are not met, an error message is returned.
  • Only items that have been updated are shown in the response
  • Request
    • Header
      1. {
      2. "authorization": "JWT token"
      3. }
    • Body
      1. {
      2. "company": {
      3. "update": true or false,
      4. "value": "updated value"
      5. },
      6. "position": {
      7. "update": true or false,
      8. "value": "updated value"
      9. },
      10. "start_date": {
      11. "update": true or false,
      12. "value": "updated value"
      13. },
      14. "end_date": {
      15. "update": true or false,
      16. "value": "updated value"
      17. }
      18. }
    • URL
      • item_id (works table id column)
  • Response
    1. {
    2. "isSuccess": true,
    3. "work_updated": {
    4. "id": "12",
    5. "user_id": 15,
    6. "company": "Hyundai Motors",
    7. "position": "Marketer",
    8. "start_date": "2017-06-13",
    9. "end_date": null,
    10. "status": "current"
    11. }
    12. }

Database Schema

Database Schema