-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (28 loc) · 684 Bytes
/
main.go
File metadata and controls
39 lines (28 loc) · 684 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 (
"log"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/inabatatkanova/Software-engineering/database"
"github.com/inabatatkanova/Software-engineering/router"
)
func CreateServer() *fiber.App {
app := fiber.New()
return app
}
func main() {
// connect to PSQL
database.ConnectToDB()
app := CreateServer()
app.Use(cors.New(cors.Config{
AllowOrigins: "http://localhost:3000",
AllowHeaders: "Origin, Content-Type, Accept",
AllowCredentials: true,
}))
router.SetupRoutes(app)
//404 handler
app.Use(func(c *fiber.Ctx) error {
return c.SendStatus(404)
})
log.Fatal(app.Listen(":8000"))
}