Skip to content
Backend Repo for Backend Engineer.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
src
.gitignore
LICENSE
README.md
index.js
knexfile.js
package-lock.json
package.json

README.md

build-post-here-backend

Backend Repo for Backend Engineer.

ROUTES:

BASE URL: https://post-here.herokuapp.com/

POST /api/auth/register

Inputs:

  • username: (string) 128chars long.
  • password: (password) This will be hashed.
  {
  username: 'test',
  password:'test'
  }

Success Outputs

{
  "message": "Registration Successful",
  "token": "a token would appear here",
  "id": 1
}

Failure Outputs

  • msg(string) -> contains an error object converted into a string.

POST /api/auth/login

Inputs:

  • username: (string) 128chars long.
  • password: (password) This will be hashed.
  {
  username: 'test',
  password:'test'
  }

Success Outputs

{
  "message": "Login Successful",
  "token": "a token would appear here",
  "id": 1
}

Failure Outputs

  • msg(string) ->

POST /api/post

Input

{
  "title": "This is a title",
  "body": "This is the post",
  "image": "This is an image url"
}

Success Outputs

{
  "response": [
    {
      "rec": "dankmemes",
      "score": 0.36160451388367243
    },
    {
      "rec": "teenagers",
      "score": 0.19633690505618595
    },
    {
      "rec": "memes",
      "score": 0.17758563187085075
    },
    {
      "rec": "me_irl",
      "score": 0.08763629551358934
    },
    {
      "rec": "gaming",
      "score": 0.04070450903212839
    }
  ],
  "title": "check it take 2",
  "body": "it really works now srsly",
  "image": "tsrsly"
}

Failure Outputs

  • msg(string) ->

DELETE /api/auth/users

This endpoint is restricted to logged in users.

Inputs:

  • Request header (Javascript Object) that should contain the token.

Success Outputs

  • msg(string) -> contains a success message string

Failure Outputs

  • msg(string) ->

PUT /api/auth/users

This endpoint is restricted to logged in users.

Inputs:

  • Object with password
  • Request header (Javascript Object) that should contain the token.

Success Outputs

  • msg(string) -> contains a success message string

Failure Outputs

  • msg(string) ->
You can’t perform that action at this time.