Categorygithub.com/asakshat/go_blog
module
0.0.0-20240602231039-300004c834d9
Repository: https://github.com/asakshat/go_blog.git
Documentation: pkg.go.dev

# README

Blog Web App in GO (CRUD)

If you are just looking for routes click here API Routes

Instructions to Build and Run the Application

Prerequisites

  • Ensure Docker is installed on your machine. You can download Docker from here.

Steps to Run the Application locally

Step 1: Create a .env File

In the root directory of your project, create a .env file.

Step 2: Set Up Environment Variables

Add the following environment variables to the .env file:

SECRET_KEY="YOUR-SECRET-CODE"
DATABASE_URL="YOUR-DB-URL"

Example :-

  • DATABASE_URL according to docker-compose.yml file.
DATABASE_URL=postgres://myuser:mypassword@localhost:5432/mydatabase
SECRET_KEY=asdasd12asd1

Step 3: Run Docker Compose

Make sure you are in the root directory of the project folder.

Now run :

docker compose up

Now docker should create an image and run it as a container .

To stop you the container you can run:

docker compose down

You can also use Docker Desktop to run/stop containers without the CLI.

API Routes

  • URL = https://goblogpost-867025111c75.herokuapp.com

Authentication Routes

DescriptionRouteMethodController
Signup/api/user/signupPOSTcontrollers.Signup
Login with Cookies/api/user/loginPOSTcontrollers.Login
Logout and remove cookies/api/user/logoutPOSTcontrollers.Logout
Get logged in user/api/userGETcontrollers.User

Blog Routes

DescriptionRouteMethodController
Get all blog posts/api/blog/allGETcontrollers.GetAllPosts
Get blog post by ID/api/blog/:post_idGETcontrollers.GetPostWithIdHandler
Get all blog by User_ID/api/blog/all/:user_idGETcontrollers.GetPostWithIdHandler
Create blog post/api/blog/:user_idPOSTcontrollers.CreateBlog
Edit blog post/api/blog/edit/:user_id/:post_idPUTcontrollers.EditPost
Delete blog post/api/blog/delete/:user_id/:post_idDELETEcontrollers.DeletePost

Like Routes

DescriptionRouteMethodController
Like a blog post/api/blog/like/:user_id/:post_idPOSTcontrollers.LikePost
Unlike a blog post/api/blog/unlike/:user_id/:post_idPOSTcontrollers.UnlikePost

Comment Routes

DescriptionRouteMethodController
Post a comment on a blog/api/blog/comment/post/:user_id/:post_idPOSTcontrollers.PostComment
Edit a comment/api/blog/comment/edit/:user_id/:comment_idPUTcontrollers.EditComment
Delete a comment/api/blog/comment/delete/:user_id/:comment_idDELETEcontrollers.DeleteComment

# Packages

No description provided by the author
No description provided by the author