32 lines
542 B
Go
32 lines
542 B
Go
package main
|
|
|
|
import (
|
|
"api/database"
|
|
"api/routes"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
|
)
|
|
|
|
func main() {
|
|
app := fiber.New(fiber.Config{
|
|
StrictRouting: true,
|
|
DisableStartupMessage: true,
|
|
})
|
|
|
|
app.Use(cors.New(cors.Config{
|
|
AllowCredentials: true,
|
|
}))
|
|
|
|
if err := database.ConnectDB(); err != nil {
|
|
panic("Could not connect to database")
|
|
}
|
|
|
|
routes.Setup(app)
|
|
|
|
log.Println("Server started in port " + os.Getenv("API_PORT"))
|
|
app.Listen(":" + os.Getenv("API_PORT"))
|
|
}
|