Skip to content

SabiulSabit/Blog-REST-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog-API

.env file

Creat a .env file and add Environment Variable

 PORT=YOUR PORT (Default port is 8000)
 DATABASE=DB_URL
 JWT_SECRET=RANDOM_STRING

Create an User

Send a Post Request to:

Post: http://localhost:8000/api/signup

Body:

           {
              "name": "test1",
              "email": "[email protected]",
              "password": "test123"
           }    

User Login

Send a Post Request to:

Post: http://localhost:8000/api/singin

Body:

           {
              "name": "test1",
              "password": "test123"
           }    

Create a Post

Send a Post Request to:

Post: http://localhost:8000/api/post/create/:uesrId

Headers:

         Key: Authorization Value: Bearer YOUR_TOKEN
         Key: Content-Type  Value: application/json

Body:

           {
              "title": "First Post",
              "content": "This is the Content",
              "tags": ["a", "n", "sf"]
          }  

Update a Post

Send a Put Request to:

Put: http://localhost:8000/api/post/update/:postId/:userId

Headers:

         Key: Authorization Value: Bearer YOUR_TOKEN
         Key: Content-Type  Value: application/json

Body:

All are optional, you can set any of those or update all

         {
             "title": "First Post", 
             "content": "This is the Content",
             "tags": ["a", "n", "sf"]
         }  

Delete a Post

Send a Delete Request to:

Delete: http://localhost:8000/api/post/delete/:postId/:userId

Headers:

         Key: Authorization Value: Bearer YOUR_TOKEN
         Key: Content-Type  Value: application/json

Add Comment to a Post

Send a Post Request to:

Post: http://localhost:8000/api/comment/:postId/:userId

Headers:

         Key: Authorization Value: Bearer YOUR_TOKEN
         Key: Content-Type  Value: application/json

Body:

         {
             "comment": "Your Comment"
         }  

About

REST API for a Simple Blog

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published