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
- Create user
- Login user
- Create post
- Read post
- Update post
- Delete post
All the post routes was authenticated with JWT
Clone repo to your local machine:
git clone https://github.com/its-nedum/rails-jwt-authentication.git
install GemFile
bundle install
Create Users and Posts table
rails db:migrate
Now start the rails server:
rails s
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 |