init project

This commit is contained in:
2025-03-19 13:47:29 +07:00
parent 80d1f95f66
commit f6a2cf3a5b
22 changed files with 677 additions and 24 deletions

View File

@@ -23,10 +23,10 @@ type service struct {
}
var (
host = os.Getenv("BLUEPRINT_DB_HOST")
port = os.Getenv("BLUEPRINT_DB_PORT")
user = os.Getenv("BLUEPRINT_DB_USER")
pass = os.Getenv("BLUEPRINT_DB_PASS")
host = os.Getenv("MONGODB_DEV_HOST")
port = os.Getenv("MONGODB_DEV_PORT")
user = os.Getenv("MONGODB_DEV_USER")
pass = os.Getenv("MONGODB_DEV_PASS")
)
func New(database string) Service {

View File

@@ -9,11 +9,13 @@ import (
"github.com/gin-gonic/gin"
"blueprint_fix/cmd/web"
"github.com/a-h/templ"
"io/fs"
"template_blueprint/cmd/web"
"github.com/coder/websocket"
patientHandler "template_blueprint/pkg/handlers/patient"
)
func (s *Server) RegisterRoutes() http.Handler {
@@ -21,8 +23,6 @@ func (s *Server) RegisterRoutes() http.Handler {
r.GET("/", s.HelloWorldHandler)
r.GET("/health", s.healthHandler)
r.GET("/websocket", s.websocketHandler)
staticFiles, _ := fs.Sub(web.Files, "assets")
@@ -36,6 +36,13 @@ func (s *Server) RegisterRoutes() http.Handler {
web.HelloWebHandler(c.Writer, c.Request)
})
api := r.Group("/api")
patient := api.Group("/patient")
{
patient.POST("/insertpatient", patientHandler.InsertPatient)
patient.GET("/getallpatient", patientHandler.GetAllPatient)
}
return r
}
@@ -46,10 +53,6 @@ func (s *Server) HelloWorldHandler(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
func (s *Server) healthHandler(c *gin.Context) {
c.JSON(http.StatusOK, s.db.Health())
}
func (s *Server) websocketHandler(c *gin.Context) {
w := c.Writer
r := c.Request

View File

@@ -9,7 +9,7 @@ import (
_ "github.com/joho/godotenv/autoload"
"blueprint_fix/internal/database"
"template_blueprint/internal/database"
)
type Server struct {