- Gin Framework
- Postgres
- GORM
- Golang JWT (https://github.com/golang-jwt/jwt)
- Godotenv (https://github.com/joho/godotenv)
- Validation (https://github.com/go-playground/validator)
- Slug (https://github.com/gosimple/slug)
- Clone the repo
- Run the command
go mod download
- Rename the .env.example file to .env
- Create a database in postgres
- Change the DNS value in .env file
- Run the command
go run db/migrate/migrate.go
(Drop existing tables and recreate those) - Check your database, tables should be available
- Run the project using the command
go run main.go
- Test the application in Postman
- http://localhost:3000/api/signup (Signup)
{
"name": "John Doe",
"email": "[email protected]",
"password": "123456"
}
- http://localhost:3000/api/login (Login)
{
"email": "[email protected]",
"password": "123456"
}
- http://localhost:3000/api/logout (Logout)
- http://localhost:3000/api/categories/create (Create category)
{
"name": "National"
}
- http://localhost:3000/api/categories (Get all category)
- http://localhost:3000/api/categories/1/edit (Edit category)
- http://localhost:3000/api/categories/1/update (Update category)
{
"name": "Sports"
}
- http://localhost:3000/api/categories/1/delete (Soft delete a category)
- http://localhost:3000/api/categories/all-trash (Get all trashed category)
- http://localhost:3000/api/categories/delete-permanent/1 (Delete a trashed category permanently)
- http://localhost:3000/api/posts/create (Create post)
{
"title": "Awesome post",
"body": "This is the awesome post details",
"categoryId": 1
}
- http://localhost:3000/api/posts (Get all post)
- http://localhost:3000/api/posts/1/show (Show a single post)
- http://localhost:3000/api/posts/1/edit (Edit post)
- http://localhost:3000/api/posts/1/update (Update post)
{
"title": "Hello World",
"body": "This is the hello world post details",
"categoryId": 1
}
- http://localhost:3000/api/posts/1/delete (Soft delete a post)
- http://localhost:3000/api/posts/all-trash (Get all trashed post)
- http://localhost:3000/api/posts/delete-permanent/1 (Delete a trashed post permanently)
- http://localhost:3000/api/posts/1/comment/store (Comment on a post)
{
"postId": 1,
"body": "This is a comment"
}
- http://localhost:3000/api/posts/1/comment/1/edit (Edit a comment)
- http://localhost:3000/api/posts/1/comment/1/update (Update a comment)
{
"postId": 1,
"body": "This is a updated comment"
}
- http://localhost:3000/api/posts/1/comment/1/delete (Delete a comment)