Code Monkey home page Code Monkey logo

adonis-jwt-api-starter's Introduction

Welcome to AdonisJS JWT

This is the boilerplate for creating an API server in AdonisJs, it comes pre-configured with.

  1. Bodyparser
  2. 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)
  3. CORS
  4. Lucid ORM
  5. Migrations and seeds
  6. Translations

Setup

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.

Configs

  • Setup database configs in ROOT/.env
  • Setup Mail server config in ROOT/.env
  • [optional] Set APP_SUPERADMIN_EMAIL in ROOT/.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.

Migrations

Run the following command to run startup migrations.

adonis migration:run

Run

adonis serve --dev

AUTH API Endpoints

Endpoints with JSON response

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

Endpoints with HTML View

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

PROFILE API Endpoints

Endpoints with JSON response

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)

LOG API Endpoints

Endpoints with JSON response

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]

FEATURES/ TODO

AUTH endpoint

  • 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 endpoint

  • Profile
  • Update Profile
  • Auto fetch avatar during user signup (with email)
  • Update Avatar

adonis-jwt-api-starter's People

Contributors

amitkhare avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.