This is the boilerplate for creating an API server in AdonisJs, it comes pre-configured with.
- Bodyparser
- Authentication
- authorise,
- signup,
- verify email,
- forgot password,
- resend email verification,
- refresh token,
- me (current user info except password),
- my tokens (current user's auth tokens)
- CORS
- Lucid ORM
- Migrations and seeds
- Translations
Use the adonis command to install the blueprint
adonis new starter --blueprint=amitkhare/adonis-jwt-api-starter
or manually clone the repo and then run npm install
.
- Setup database configs in
ROOT/.env
- Setup Mail server config in
ROOT/.env
- [optional] Set
APP_SUPERADMIN_EMAIL
inROOT/.env
[ This will ensure bypass email varification for this email address.]
Feel free to change
ROOT/.env
PORT, APP_* or any other variable according to your needs.
Run the following command to run startup migrations.
adonis migration:run
adonis serve --dev
method | endpoint | request | response | needs auth |
---|---|---|---|---|
POST | /api/auth/authorise | [email, password] | jwt and refresh token | no |
POST | /api/auth/signup | [username, email, password] | jwt and refresh token | no |
GET | /api/auth/revoke/token | { refreshToken=< TOKEN >, isRevokeAll=true/false, isRemove=true/false } | message | yes |
POST | /api/auth/resend/email/verification/code | [email] | message | no |
POST | /api/auth/forgot/password | [email] | message/ sends email | no |
POST | /api/auth/reset/password | [token, password] | message | no |
POST | /api/auth/refresh/token | [refresh_token] | jwt and new refresh token | no |
POST | /api/auth/update/password | [password, newPassword] | message | yes |
POST | /api/auth/update/email | [password, email] | message | yes |
POST | /api/auth/assign/role | [userId, role] | message | yes (Super Admin) |
POST | /api/auth/remove/user/:id | [id] | message | yes (Super Admin) |
GET | /api/auth/users | ?page=1 (query param) | paginated users list | yes (Manager Level) |
GET | /api/auth/toggle/user/ban/:id | [id] | message | yes (Super Admin) |
GET | /api/auth/confirm/email/:token | token (as param) | message | no |
GET | /api/auth/me | NONE | Current User Info except password | yes |
GET | /api/auth/my/tokens | NONE | Current User Tokens | yes |
method | endpoint | request | response | needs auth |
---|---|---|---|---|
GET | /api/auth/view/confirm/email/:token | NONE | HTML View | no |
GET | /api/auth/view/reset/password/:token | NONE | HTML View | no |
method | endpoint | request | response | needs auth |
---|---|---|---|---|
GET | /api/profile | NONE | user profile | yes |
POST | /api/profile/update | [first_name, last_name] | message | yes(verified) |
POST | /api/profile/update/avatar | file[avatar] | message | yes(verified) |
method | endpoint | request | response | needs auth |
---|---|---|---|---|
GET | /api/logs | ?page=1 (query param) | Paginated Logs | yes |
GET | /api/logs/remove/:id | id (as param) | message (remove log by id) | yes [admin level] |
GET | /api/logs/clear/all | NONE | message (clears all logs) | yes [admin level] |
- Authorise
- Signup
- revokeToken
- Forgot Password
- Verify Email
- Resend Email
- Refresh Token
- List User Tokens
- Level Based Restriction middleware
-
jwtAuth
(All authenticated users) -
JwtAuthVerified
(Only verified users) -
jwtAuthMember
(Member level and followings ) -
jwtAuthModerator
(Moderator level and followings ) -
jwtAuthManager
(Manager level and followings ) -
jwtAuthAdmin
(Admin and Super Admin only) -
jwtAuthSuperAdmin
(Super Admin only)
-
- User Details (except password)
- Update Email
- Update Password
- Assign auth level to user
- List Users
- Remove User
- Toggle User Ban
- Translations
- Profile
- Update Profile
- Auto fetch avatar during user signup (with email)
- Update Avatar