face-detect-backend

Face Detect Backend

Backend of the Face Detect Project, built with Node.js, Express.js, Knex.js and hosted using Heroku.
Password are safely encrytped using brcrypt.

Installation

  1. Clone the repo using
git clone https://github.com/AmplifiedHuman/face-detect-backend.git
  1. Install dependencies
npm install
  1. Setup environment variables, create a .env file with the following variables

API_KEY=
HOST=
USER=
PASSWORD=
DB=
  1. Start the development server
npm start
  1. API Link
Visit http://localhost:3001

Endpoints

Login

Authenticate user given email and password

  • URL

    /login

  • Method:

    POST

  • Data Params

    { "email": "John@gmail.com", "password": "cookies" }

  • Success Response:

    • Code: 200
      Content: { "id": 16, "name": "John", "email": "John@gmail.com", "entries": "18", "joined": "2020-08-31T07:27:46.990Z" }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: {"Invalid Credentials"}

Register

Register user given email, name and password, user email must be unique.

  • URL

    /register

  • Method:

    POST

  • Data Params

    { "email": "Johny123@gmail.com", "password": "cookies", "name": "Johny" }

  • Success Response:

    • Code: 200
      Content: { "id": 30, "name": "Johny", "email": "Johny123@gmail.com", "entries": "0", "joined": "2020-09-10T07:15:07.586Z" }
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: {"Unable to register user"}

Face detection

Given image link, return face detection data.

  • URL

    /imageURL

  • Method:

    POST

  • Data Params

    { "input": "https://cdn.vox-cdn.com/thumbor/zcdhPZbwtnwiator3LCNdKmGihw=/1400x788/filters:format(png)/cdn.vox-cdn.com/uploads/chorus_asset/file/13762264/fake_ai_faces.png" }

  • Success Response:

  • Error Response:

    • Code: 400 BAD REQUEST
      Content: {"Unable to call image API"}

User infomation

Given id, get basic user information

  • URL

    /profile/:id

  • Method:

    GET

  • URL Params

    Required:

    id=[string]

  • Success Response:

    • Code: 200
      Content: { "id": 30, "name": "Johny", "email": "Johny123@gmail.com", "entries": "1", "joined": "2020-09-10T07:15:07.586Z" }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: {"Unable to get user"}

Update Image Entry

Given id, updated entries of the current user, returns the updated count.

  • URL

    /image

  • Method:

    PUT

  • Data Params

    { "id": "30" }

  • Success Response:

    • Code: 200
      Content: { 1 }
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: {"Unable to update entries"}

Visit original content creator repository
https://github.com/jsn-t/face-detect-backend

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *