forked from SphericalKat/go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (30 loc) · 725 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
package main
import (
"fmt"
"log"
"github.com/SphericalKat/go-template/api/endpoints"
"github.com/SphericalKat/go-template/db"
"github.com/gofiber/fiber/v2"
"github.com/spf13/viper"
)
func healthCheck(c *fiber.Ctx) error {
return c.SendString("OK")
}
func main() {
// Set global configuration
viper.SetConfigName(".env")
viper.SetConfigType("env")
viper.AddConfigPath(".")
if err := viper.ReadInConfig(); err != nil {
log.Panicln(fmt.Errorf("fatal error config file: %s", err))
}
app := fiber.New()
app.Get("/", healthCheck)
// Run db migrations
log.Println("Running database migrations")
if err := db.Migrate(); err != nil {
log.Panic(err)
}
endpoints.MountRoutes(app)
app.Listen(":3000")
}