Implemented API Endpoints as asked and mocha test scripts for them. User authentication has been implemented using JSON Web Tokens. Have used MongoDB as the database to store user information. For JSON patching endpoint, I have used jsonpatch.js library. Have used Morgan library for Logging/Monitoring. Used prettifier atom plugin for ES6 linting.
Project is live at: https://rocky-depths-18228.herokuapp.com/
git clone https://github.com/prafful13/socialcops-task.git
cd socialcops-task
npm install
npm start
For testing, run: npm test
Resource Information
Request Method | POST |
Response Format | JSON |
Data Parameters
Name | Required | Description | Default Value | Example |
---|---|---|---|---|
name | required | User's name | Ravi | |
required | User's email id | [email protected] | ||
password | required | User's password | Ravispassword |
Example Request
POST /api/auth/register
Resource Information
Request Method | POST |
Response Format | JSON |
Data Parameters
Name | Required | Description | Default Value | Example |
---|---|---|---|---|
required | User's email id | [email protected] | ||
password | required | User's password | Ravispassword |
Example Request
POST /api/auth/login
Resource Information
Request Method | GET |
Response Format | JSON |
Example Request
GET /api/auth/logout
Resource Information
Request Method | POST |
Response Format | JSON |
Data Parameters
Name | Required | Description | Default Value | Example |
---|---|---|---|---|
Json object | required | Original json object to be patched | {"baz": "qux", "foo": "bar"} | |
Patch object | required | Patch Object containg various operations | [{ "op": "replace", "path": "/baz", "value": "boo" },{ "op": "add", "path": "/hello", "value": ["world"] },{ "op": "remove", "path": "/foo"}] |
Example Request
POST /api/jsonpatch/
Resource Information
Request Method | POST |
Response Format | IMAGE |
Data Parameters
Name | Required | Description | Default Value | Example |
---|---|---|---|---|
url | required | Image's public URL | https://upload.wikimedia.org/wikipedia/commons/c/c6/Sierpinski_square.jpg |
Example Request
POST /api/imgdown