hackoverflow


Create a User

  • URL </users/register>

  • Method: POST

  • URL Params
    None

  • Data Params Required:

    username=[string]
    email=[string]
    password=[string]

  • Success Response:

    • Code: 201
      Content:
          {
              "_id": "5df5edc025ea7741e11ecf19",
              "username": "john",
              "email": "john@mail.com",
              "password": "$2a$10$AtPx6DnLKlnCkjJPBIH7wuCQHVbgdl.2O3NsmMXcnVszILKOEbf22",
              "createdAt": "2019-12-18T08:24:32.268Z",
              "updatedAt": "2019-12-18T08:24:32.268Z",
              "__v": 0
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "email/username already registered" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Log In

  • URL </users/login>

  • Method: POST

  • URL Params
    None

  • Data Params Required:

    email=[string]
    password=[string]

  • Success Response:

    • Code: 200
      Content:
      {
          "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkZjVlZGMwMjVlYTc3NDFlMTFlY2YxOSIsImVtYWlsIjoiam9obkBtYWlsLmNvbSIsImlhdCI6MTU3NjM5ODM4OCwiZXhwIjoxNTc2Mzk4OTg4fQ.FqgruQlO2zaV2YflLBghYg5PrfqAhkMhbVJX39n9ho0"
      }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Email and/or password incorrect" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Get all questions

  • URL </questions>

  • Method: GET

  • URL Params
    access_token=[string]

  • Data Params
    None

  • Success Response:

    • Code: 200
      Content:
      [
          {
              "category": "Javascript",
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb4977e10ae2403c158289",
              "title": "How to Add, Delete new Columns in Sequelize CLI",
              "description": "I've just started using Sequelize and Sequelize CLI\n\nSince it's a development time, there are a frequent addition and deletion of columns. What the best the method to add a new column to an existing model?\n\nFor example, I want to a new column 'completed' to Todo model. I'll add this column to models/todo.js. Whats the next step?\n\nI tried sequelize db:migrate\n\nnot working: \"No migrations were executed, database schema was already up to date.\"",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          },
          {
              "category": "Javascript",
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb49c8e10ae2403c15828a",
              "title": "how to get request path with express req object",
              "description": "I'm using express + node.js and I have a req object, the request in the browser is /account but when I log req.path I get '/' --- not '/account'.",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "createdAt": "2019-12-19T09:58:32.930Z",
              "updatedAt": "2019-12-19T09:58:32.930Z",
              "__v": 0
          }
      ]
  • Error Response:

    • Code: 401 Unauthorized
      Content: { error : "You must log in first" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Post a question

  • URL </questions>

  • Method: POST

  • URL Params
    access_token=[string]

  • Data Params Required: title=[string]
    description=[string]
    category=[string]

  • Success Response:

    • Code: 201
      Content:
          {
              "category": "Javascript",
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb4977e10ae2403c158289",
              "title": "How to Add, Delete new Columns in Sequelize CLI",
              "description": "I've just started using Sequelize and Sequelize CLI\n\nSince it's a development time, there are a frequent addition and deletion of columns. What the best the method to add a new column to an existing model?\n\nFor example, I want to a new column 'completed' to Todo model. I'll add this column to models/todo.js. Whats the next step?\n\nI tried sequelize db:migrate\n\nnot working: \"No migrations were executed, database schema was already up to date.\"",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
  • Error Response:

    • Code: 401
      Content: { error : "You must log in first" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Get a question

  • URL </questions/{id}>

  • Method: GET

  • URL Params
    access_token=[string]

  • Data Params
    None

  • Success Response:

    • Code: 200
      Content:
          {
              "category": "Javascript",
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb4977e10ae2403c158289",
              "title": "How to Add, Delete new Columns in Sequelize CLI",
              "description": "I've just started using Sequelize and Sequelize CLI\n\nSince it's a development time, there are a frequent addition and deletion of columns. What the best the method to add a new column to an existing model?\n\nFor example, I want to a new column 'completed' to Todo model. I'll add this column to models/todo.js. Whats the next step?\n\nI tried sequelize db:migrate\n\nnot working: \"No migrations were executed, database schema was already up to date.\"",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Question not found" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Delete a question

  • URL </questions/{id}>

  • Method: DELETE

  • URL Params
    access_token=[string]

  • Data Params
    None

  • Success Response:

    • Code: 200
      Content:
          {
              "message": "Question successfully deleted."
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Question not found" }
    • Code: 401 Unauthorized
      Content: { error : "Unauthorized process" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Update a question

  • URL </questions/{id}>

  • Method: PATCH

  • URL Params
    access_token=[string]

  • Data Params
    Options: title=[string]
    description=[string]
    category=[string]

  • Success Response:

    • Code: 200
      Content:
          {
              "category": "Javascript",
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb4977e10ae2403c158289",
              "title": "How to Add, Delete new Columns in Sequelize CLI",
              "description": "I've just started using Sequelize and Sequelize CLI\n\nSince it's a development time, there are a frequent addition and deletion of columns. What the best the method to add a new column to an existing model?\n\nFor example, I want to a new column 'completed' to Todo model. I'll add this column to models/todo.js. Whats the next step?\n\nI tried sequelize db:migrate\n\nnot working: \"No migrations were executed, database schema was already up to date.\"",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Question not found" }
    • Code: 401 Unauthorized
      Content: { error : "Unauthorized process" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Vote a question

  • URL </questions/vote/{id}>

  • Method: PATCH

  • URL Params
    access_token=[string]

  • Data Params
    Required: type=[string(upvotes/downvotes)]

  • Success Response:

    • Code: 200
      Content:
          {
              "category": "Javascript",
              "upvotes": ["oqr91wdwe78casv61r1"],
              "downvotes": [],
              "_id": "5dfb4977e10ae2403c158289",
              "title": "How to Add, Delete new Columns in Sequelize CLI",
              "description": "I've just started using Sequelize and Sequelize CLI\n\nSince it's a development time, there are a frequent addition and deletion of columns. What the best the method to add a new column to an existing model?\n\nFor example, I want to a new column 'completed' to Todo model. I'll add this column to models/todo.js. Whats the next step?\n\nI tried sequelize db:migrate\n\nnot working: \"No migrations were executed, database schema was already up to date.\"",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Question not found" }
    • Code: 401 Unauthorized
      Content: { error : "Unauthorized process" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Filter questions

  • URL </questions/filter/{category}>

  • Method: GET

  • URL Params
    access_token=[string]

  • Data Params
    None

  • Success Response:

    • Code: 200
      Content:
          {
              "category": "Javascript",
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb4977e10ae2403c158289",
              "title": "How to Add, Delete new Columns in Sequelize CLI",
              "description": "I've just started using Sequelize and Sequelize CLI\n\nSince it's a development time, there are a frequent addition and deletion of columns. What the best the method to add a new column to an existing model?\n\nFor example, I want to a new column 'completed' to Todo model. I'll add this column to models/todo.js. Whats the next step?\n\nI tried sequelize db:migrate\n\nnot working: \"No migrations were executed, database schema was already up to date.\"",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          },
          {
              "category": "Javascript",
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb49c8e10ae2403c15828a",
              "title": "how to get request path with express req object",
              "description": "I'm using express + node.js and I have a req object, the request in the browser is /account but when I log req.path I get '/' --- not '/account'.",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "createdAt": "2019-12-19T09:58:32.930Z",
              "updatedAt": "2019-12-19T09:58:32.930Z",
              "__v": 0
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Category not found" }
    • Code: 401 Unauthorized
      Content: { error : "Unauthorized process" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Get all answers with question ID

  • URL </answers/{id}>

  • Method: GET

  • URL Params
    access_token=[string]

  • Data Params
    None

  • Success Response:

    • Code: 200
      Content:
      [
          {
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb47ava9oc7g8158289",
              "title": "Sequelize",
              "description": "After having a bit of a play myself, you should use:console.log(req.originalUrl)",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "QuestionId": "5dfb4977e10ae2403c158289",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          },
          {
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb47ava9oc7g8158289",
              "title": "Sequelize",
              "description": "After having a bit of a play myself, you should use:console.log(req.originalUrl)",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "QuestionId": "5dfb4977e10ae2403c158289",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
      ]
  • Error Response:

    • Code: 401 Unauthorized
      Content: { error : "You must log in first" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Post an answer

  • URL </answers>

  • Method: POST

  • URL Params
    access_token=[string]

  • Data Params Required: title=[string]
    description=[string]
    QuestionId=[string]

  • Success Response:

    • Code: 201
      Content:
          {
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb47ava9oc7g8158289",
              "title": "Sequelize",
              "description": "After having a bit of a play myself, you should use:console.log(req.originalUrl)",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "QuestionId": "5dfb4977e10ae2403c158289",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
  • Error Response:

    • Code: 401
      Content: { error : "You must log in first" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Get an answer

  • URL </answers/answer/{id}>

  • Method: GET

  • URL Params
    access_token=[string]

  • Data Params
    None

  • Success Response:

    • Code: 200
      Content:
          {
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb47ava9oc7g8158289",
              "title": "Sequelize",
              "description": "After having a bit of a play myself, you should use:console.log(req.originalUrl)",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "QuestionId": "5dfb4977e10ae2403c158289",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Answer not found" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Delete an answer

  • URL </answers/{id}>

  • Method: DELETE

  • URL Params
    access_token=[string]

  • Data Params
    None

  • Success Response:

    • Code: 200
      Content:
          {
              "message": "Answer successfully deleted."
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Answer not found" }
    • Code: 401 Unauthorized
      Content: { error : "Unauthorized process" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Update an answer

  • URL </answers/{id}>

  • Method: PATCH

  • URL Params
    access_token=[string]

  • Data Params
    Options: title=[string]
    description=[string]

  • Success Response:

    • Code: 200
      Content:
          {
              "upvotes": [],
              "downvotes": [],
              "_id": "5dfb47ava9oc7g8158289",
              "title": "Sequelize",
              "description": "After having a bit of a play myself, you should use:console.log(req.originalUrl)",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "QuestionId": "5dfb4977e10ae2403c158289",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Answer not found" }
    • Code: 401 Unauthorized
      Content: { error : "Unauthorized process" }
    • Code: 500 Internal Server Error
      Content: { error : error }

Vote an answer

  • URL </answers/vote/{id}>

  • Method: PATCH

  • URL Params
    access_token=[string]

  • Data Params
    Required: type=[string(upvotes/downvotes)]

  • Success Response:

    • Code: 200
      Content:
          {
              "upvotes": [],
              "downvotes": ["oqr91wdwe78casv61r1"],
              "_id": "5dfb47ava9oc7g8158289",
              "title": "Sequelize",
              "description": "After having a bit of a play myself, you should use:console.log(req.originalUrl)",
              "UserId": "5dfa34c1e1cab51aa2a4a52c",
              "QuestionId": "5dfb4977e10ae2403c158289",
              "createdAt": "2019-12-19T09:57:11.295Z",
              "updatedAt": "2019-12-19T09:57:11.295Z",
              "__v": 0
          }
  • Error Response:

    • Code: 400 Bad Request
      Content: { error : "Answer not found" }
    • Code: 401 Unauthorized
      Content: { error : "Unauthorized process" }
    • Code: 500 Internal Server Error
      Content: { error : error }