Added migrations
This commit is contained in:
parent
4a16acc87e
commit
5b18009658
34 changed files with 929 additions and 154 deletions
72
cmd/main.go
72
cmd/main.go
|
|
@ -1,31 +1,36 @@
|
|||
package main
|
||||
|
||||
// @title 58team blog backend
|
||||
// @version 1.0
|
||||
// @description 58team blog's backend
|
||||
// @termsOfService http://swagger.io/terms/
|
||||
|
||||
// @contact.name API Support
|
||||
// @contact.url http://www.swagger.io/support
|
||||
// @contact.email support@swagger.io
|
||||
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
// @host localhost:8080
|
||||
// @BasePath /api/v1
|
||||
|
||||
// @securityDefinitions.basic BasicAuth
|
||||
// @title 58team blog backend
|
||||
// @version 1.0
|
||||
// @description 58team blog's backend
|
||||
// @termsOfService http://swagger.io/terms/
|
||||
// @contact.name API Support
|
||||
// @contact.url http://www.swagger.io/support
|
||||
// @contact.email support@swagger.io
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
// @host localhost:8080
|
||||
// @BasePath /api/v1
|
||||
// @securityDefinitions.basic BasicAuth
|
||||
|
||||
import (
|
||||
"58team_blog/docs"
|
||||
docs "58team_blog/docs"
|
||||
"58team_blog/internal/application/services"
|
||||
"58team_blog/internal/infrastructure"
|
||||
"58team_blog/internal/infrastructure/db"
|
||||
"58team_blog/internal/infrastructure/db/repo"
|
||||
"58team_blog/internal/interfaces"
|
||||
"log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/swaggo/files"
|
||||
"github.com/swaggo/gin-swagger"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
|
||||
// Swagger setup
|
||||
docs.SwaggerInfo.Title = "58team blog"
|
||||
docs.SwaggerInfo.Description = "This is blog 58team"
|
||||
docs.SwaggerInfo.Version = "1.0"
|
||||
|
|
@ -33,6 +38,33 @@ func main() {
|
|||
docs.SwaggerInfo.BasePath = "/api/v1/"
|
||||
docs.SwaggerInfo.Schemes = []string{"http", "https"}
|
||||
|
||||
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
// router.GET("/swagger/*any", func(c *gin.Context) {
|
||||
// path := c.Param("any")
|
||||
// if strings.HasPrefix(path, "/doc.json") {
|
||||
// c.File("docs/swagger.json")
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
// })
|
||||
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.URL("http://localhost:8080/swag/doc/doc.json")))
|
||||
router.StaticFile("/swag/doc/doc.json", "docs/swagger.json")
|
||||
|
||||
// Routes setup
|
||||
g := router.Group("/api/v1")
|
||||
|
||||
config, err := infrastructure.LoadConfig()
|
||||
if err != nil {
|
||||
log.Fatal("Load config error: ", err)
|
||||
}
|
||||
|
||||
d, err := db.DatabaseInit(*config)
|
||||
if err != nil {
|
||||
log.Fatal("Database error: ", err)
|
||||
}
|
||||
postRepository := repo.CreatePostRepository(d)
|
||||
|
||||
postService := services.CreatePostService(&postRepository)
|
||||
interfaces.BindPostAdmin(&postService, g)
|
||||
|
||||
router.Run(":8080")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue