-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (30 loc) · 886 Bytes
/
main.go
File metadata and controls
39 lines (30 loc) · 886 Bytes
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
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"os"
"main/handlers"
"main/repository"
"main/services"
)
func main() {
repos := repository.InitRepo(os.Getenv("DB_CONNECTION"))
repos.Migrate()
user := services.NewUsers(repos)
outHandler := handlers.NewOutHandlers(repos, user)
inHandler := handlers.NewInHandlers(repos, user)
app := fiber.New()
app.Use(logger.New())
app.Use(cors.New(cors.Config{
AllowOrigins: "http://localhost:3000,http://127.0.0.1:3000",
AllowMethods: "GET,POST,HEAD,PUT,DELETE,PATCH,OPTIONS",
AllowHeaders: "Origin, Content-Type, Accept, Authorization",
ExposeHeaders: "Content-Length",
AllowCredentials: true,
}))
initRoutes(app, inHandler, outHandler)
if err := app.Listen(":8080"); err != nil {
panic(err)
}
}