DEPLOY: http://miniwp.orvinsavero.com/
- route:
POST /register
- request:
- body:
{ email: '[email protected]', password: 'secret' }
- body:
- response:
201
:{ _id: ObjectId(''), email: '[email protected]', password: 'HashedPassword' }
- error:
Validation Error
- Email is unique, so it is not allowed to have same email in database.
- Password is hashed with bcryptjs.
- route:
POST /login
- request:
- body
{ email: '[email protected]', password: 'secret' }
- body
- response:
201
:{ token: '...' }
- error:
404 not found
Token is generated from JWT package.
- route:
POST /google
- request:
- payload
{ email: '[email protected]' }
- payload
- response:
201
:{ token: '...' }
- error:
500 internal server error
- If Google email is present in database, user receive token that is generated from JWT package.
- If Google email is not present in database, Google email will be registered to database and password is randomly generated, then user automatically login and receive token that is generated from JWT package.
- route:
POST /home
- request
- headers
{ token }
- decoded
{id: _id}
- body
{ title, content, tags, created_at, image, UserId }
- headers
- response
201
:{ title content tags created_at image UserId }
- error:
Validation Error
- Token is decoded via JWT to get UserId.
- Multer is used to convert form data into object, then it is uploaded to google cloud storage and use the link from google cloud storage to google vision in order to get tags automatically.
- route:
GET /home
- request
- headers
{ token }
- decoded
{id: _id}
- query
{ myArticle }
- headers
- response
200
:{ title content tags created_at image UserId }
- error:
500 internal server error
- Token is decoded via JWT to get UserId.
- Query is used to find specific UserId.
- route:
DELETE /:id
- request
- headers
{ token }
- decoded
{id: _id}
- headers
- response
200
:{ _id: ObjectId('') }
- error:
401 not authorized
User can not delete Article that does not belongs to his/her, it is authorized in middleware.
- route:
PATCH /:id
- request
- headers
{ token }
- decoded
{id: _id}
- body
{ title, content, tag, image }
- headers
- response
201
:{ title content tags created_at image UserId }
- error:
401 not authorized
- User can not update Article that does not belongs to his/her, it is authorized in middleware.
- Multer is used to convert form data into object, then it is uploaded to google cloud storage and use the link from google cloud storage to google vision in order to get tags automatically.