-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
46 lines (36 loc) · 999 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
_ "log"
"os"
"talui/pkg/app"
"talui/pkg/database"
"talui/pkg/route"
"github.com/gofiber/fiber/v2/middleware/cors"
_ "github.com/go-sql-driver/mysql"
"github.com/joho/godotenv"
_ "github.com/joho/godotenv"
swagger "github.com/arsmn/fiber-swagger/v2"
// docs are generated by Swag CLI, you have to import them.
// replace with your own docs folder, usually "github.com/username/reponame/docs"
_ "talui/docs"
)
func main() {
fiberApp := app.CreateFiberApp()
_ = godotenv.Load(".env")
fiberApp.Use(cors.New())
fiberApp.Use(cors.New(cors.Config{
AllowOrigins: "*",
AllowMethods: "GET,POST,HEAD,PUT,DELETE,PATCH",
AllowHeaders: "",
}))
fiberApp.Get("/swagger/*", swagger.Handler) // default
mysqlUri := os.Getenv("MYSQL_URI")
database.ConnectMySQL(mysqlUri)
// middleware.RegisDb(fiberApp, db)
route.SetupRouter(fiberApp)
// port
port := os.Getenv("PORT")
fmt.Printf("starting server at port %s", port)
fiberApp.Listen(":" + port)
}