-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (35 loc) · 859 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
39
40
41
42
43
44
45
package main
import (
"log"
"github.com/TheLoGgI/database"
"github.com/TheLoGgI/models"
"github.com/TheLoGgI/routes"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
)
const Port string = "3000"
func createServer() models.Server {
app := fiber.New()
database := database.GetMongoDatabase()
app.Use(cors.New(cors.Config{
AllowOrigins: "http://localhost:3001",
AllowHeaders: "Origin, Content-Type, Accept",
AllowCredentials: true,
}))
server := models.Server{
Database: database,
App: app,
}
return server
}
func main() {
// Create server
server := createServer()
// Routes
server.App.Static("/", "./static")
routes.Providers(server)
routes.Users(server)
// Listen for port
log.Printf("Starting server at port " + Port + "\n")
log.Fatal(server.App.Listen("127.0.0.1:" + Port))
}