Backend of the Face Detect Project, built with Node.js, Express.js, Knex.js and hosted using Heroku.
Password are safely encrytped using brcrypt.
- Clone the repo using
git clone https://github.com/AmplifiedHuman/face-detect-backend.git
- Install dependencies
npm install
- Setup environment variables, create a .env file with the following variables
API_KEY=
HOST=
USER=
PASSWORD=
DB=
- Start the development server
npm start
- API Link
Visit http://localhost:3001
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" }
- Code: 200
-
Error Response:
- Code: 401 UNAUTHORIZED
Content:{"Invalid Credentials"}
- Code: 401 UNAUTHORIZED
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" }
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:{"Unable to register user"}
- Code: 400 BAD REQUEST
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:
- Code: 200
Content: Please refer the Clarifai Docs
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:{"Unable to call image API"}
- Code: 400 BAD REQUEST
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" }
- Code: 200
-
Error Response:
- Code: 404 NOT FOUND
Content:{"Unable to get user"}
- Code: 404 NOT FOUND
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 }
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:{"Unable to update entries"}
- Code: 400 BAD REQUEST
Leave a Reply