Skip to content

Latest commit

 

History

History
461 lines (315 loc) · 13.9 KB

File metadata and controls

461 lines (315 loc) · 13.9 KB

express-rest-api-boilerplate v0.0.0

Table of contents


Auth

Authenticate with Apple

Back to top

POST /auth/apple

Parameters - Parameter

Name Type Description
access_token String

Apple user accessToken.

Success response

Success response - Success 201

Name Type Description
token String

User access_token to be passed to other requests.

user Object

Current user's data.

Error response

Error response - Error 4xx

Name Type Description
401

Invalid credentials.

Authenticate with Email and Password

Back to top

POST /auth

Headers - Header

Name Type Description
Authorization String

Basic authorization with email and password.

Success response

Success response - Success 201

Name Type Description
token String

User access_token to be passed to other requests.

user Object

Current user's data.

Error response

Error response - Error 4xx

Name Type Description
401

Master access only or invalid credentials.

Authenticate with Facebook

Back to top

POST /auth/facebook

Parameters - Parameter

Name Type Description
access_token String

Facebook user accessToken.

Success response

Success response - Success 201

Name Type Description
token String

User access_token to be passed to other requests.

user Object

Current user's data.

Error response

Error response - Error 4xx

Name Type Description
401

Invalid credentials.

Authenticate with Github

Back to top

POST /auth/github

Parameters - Parameter

Name Type Description
access_token String

Github user accessToken.

Success response

Success response - Success 201

Name Type Description
token String

User access_token to be passed to other requests.

user Object

Current user's data.

Error response

Error response - Error 4xx

Name Type Description
401

Invalid credentials.

Authenticate with Google

Back to top

POST /auth/google

Parameters - Parameter

Name Type Description
access_token String

Google user accessToken.

Success response

Success response - Success 201

Name Type Description
token String

User access_token to be passed to other requests.

user Object

Current user's data.

Error response

Error response - Error 4xx

Name Type Description
401

Invalid credentials.

Authenticate with Vk

Back to top

POST /auth/vk

Parameters - Parameter

Name Type Description
access_token String

Vk user accessToken.

Success response

Success response - Success 201

Name Type Description
token String

User access_token to be passed to other requests.

user Object

Current user's data.

Error response

Error response - Error 4xx

Name Type Description
401

Invalid credentials.

User

Create user

Back to top

POST /users

Parameters - Parameter

Name Type Description
access_token String

Master access_token.

email String

User's email.

password String

User's password.

name String optional

User's name.

picture String optional

User's picture.

role String optional

User's role.

Default value: user
Allowed values: user,admin

Success response

Success response - Sucess 201

Name Type Description
user Object

User's data.

Error response

Error response - Error 4xx

Name Type Description
400 Object

Some parameters may contain invalid values.

401

Master access only.

409

Email already registered.

Delete user

Back to top

DELETE /users/:id

Parameters - Parameter

Name Type Description
access_token String

User access_token.

Success response

Success response - Success 204

Name Type Description
204

No Content.

Error response

Error response - Error 4xx

Name Type Description
401

Admin access only.

404

User not found.

Render users via HTML

Back to top

GET /users/html

Parameters - Parameter

Name Type Description
access_token String

User access_token.

q String optional

Query to search.

page Number optional

Page number.

Default value: 1
Size range: 1..30
limit Number optional

Amount of returned items.

Default value: 30
Size range: 1..100
sort String[] optional

Order of returned items.

Default value: -createdAt
fields String[] optional

Fields to be returned.

Success response

Success response - Success 200

Name Type Description
users Object[]

List of users.

Error response

Error response - Error 4xx

Name Type Description
400 Object

Some parameters may contain invalid values.

401

Admin access only.

Retrieve current user

Back to top

GET /users/me

Parameters - Parameter

Name Type Description
access_token String

User access_token.

Success response

Success response - Success 200

Name Type Description
user Object

User's data.

Retrieve user

Back to top

GET /users/:id

Success response

Success response - Success 200

Name Type Description
user Object

User's data.

Error response

Error response - Error 4xx

Name Type Description
404

User not found.

Retrieve users

Back to top

GET /users

Parameters - Parameter

Name Type Description
access_token String

User access_token.

q String optional

Query to search.

page Number optional

Page number.

Default value: 1
Size range: 1..30
limit Number optional

Amount of returned items.

Default value: 30
Size range: 1..100
sort String[] optional

Order of returned items.

Default value: -createdAt
fields String[] optional

Fields to be returned.

Success response

Success response - Success 200

Name Type Description
users Object[]

List of users.

Error response

Error response - Error 4xx

Name Type Description
400 Object

Some parameters may contain invalid values.

401

Admin access only.

Update password

Back to top

PUT /users/:id/password

Headers - Header

Name Type Description
Authorization String

Basic authorization with email and password.

Parameters - Parameter

Name Type Description
password String

User's new password.

Success response

Success response - Success 201

Name Type Description
user Object

User's data.

Error response

Error response - Error 4xx

Name Type Description
400 Object

Some parameters may contain invalid values.

401

Current user access only.

404

User not found.

Update user

Back to top

PUT /users/:id

Parameters - Parameter

Name Type Description
access_token String

User access_token.

name String optional

User's name.

picture String optional

User's picture.

Success response

Success response - Success 200

Name Type Description
user Object

User's data.

Error response

Error response - Error 4xx

Name Type Description
400 Object

Some parameters may contain invalid values.

401

Current user or admin access only.

404

User not found.