Skip to content

its-nedum/rails-jwt-authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authenticate Your Rails API with JWT

This is the Rails API for my Hashnode blog post with the above title

Find the blog post on Hashnode: https://itsnedum.hashnode.dev/authenticate-your-rails-api-with-jwt

Features

User

  • Create user
  • Login user

Post

  • Create post
  • Read post
  • Update post
  • Delete post

Authentication

All the post routes was authenticated with JWT

Installation

Clone repo to your local machine:

git clone https://github.com/its-nedum/rails-jwt-authentication.git

Install dependencies and run locally

install GemFile

    bundle install

Create Users and Posts table

    rails db:migrate

Now start the rails server:

    rails s

API Routes

HTTP VERB ENDPOINT FUNCTIONALITY
POST /api/v1/users Create user account
POST /api/v1/login Login a user
GET /api/v1/posts Return all blog posts
POST /api/v1/posts Create a blog post
GET /api/v1/posts/:id Return a single post
PATCH / PUT /api/v1/posts/:id Update a blog post
DELETE /api/v1/posts/:id Delete a blog post