-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
42 lines (33 loc) · 845 Bytes
/
app.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
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/raliqala/golang-fibre-boilerplate/src/config"
"github.com/raliqala/golang-fibre-boilerplate/src/database"
"github.com/raliqala/golang-fibre-boilerplate/src/routes"
)
func main() {
fibreConfig := fiber.Config{
ServerHeader: config.Config("APP_NAME"),
}
app := fiber.New(fibreConfig)
// default routes
app.Get("/", func(c *fiber.Ctx) error {
return c.Status(fiber.StatusOK).JSON(fiber.Map{
"success": true,
"message": "All good here!.. 🚀 ",
})
})
// app config
app.Use(cors.New())
port := config.Config("PORT")
// postgres, mongodb
database.DBConnection("postgres")
// routes
routes.RouteSetup(app)
conErr := app.Listen(":" + port)
// connection error
if conErr != nil {
panic(conErr)
}
}