-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (48 loc) · 1.21 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"log"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/compress"
"github.com/gofiber/fiber/v3/middleware/cors"
flogger "github.com/gofiber/fiber/v3/middleware/logger"
"github.com/gofiber/template/html/v2"
"minetest-skin-server/auth"
"minetest-skin-server/database"
"minetest-skin-server/routes"
"minetest-skin-server/utils"
)
func main() {
// Check for OptiPNG installation
if utils.ConfigOptipngEnabled {
optipngPresent := utils.OptiPNGPresent()
if optipngPresent {
log.Println("OptiPNG found")
} else {
log.Fatalln("OptiPNG not found")
}
}
// Connection to Database
log.Println("Connecting to Database...")
database.ConnectDB()
// Initialize Auth
log.Println("Initializing Auth...")
auth.Initialize()
// Create template engine
engine := html.New("./", ".gohtml")
// Init Web Server
app := fiber.New(fiber.Config{
AppName: "Minetest Skin Server",
CaseSensitive: false,
Views: engine,
})
// Enable CORS
app.Use(cors.New())
// Log requests
app.Use(flogger.New())
// Compress responses
app.Use(compress.New(compress.Config{
Level: compress.LevelDefault,
}))
routes.SetupRoutes(app)
log.Fatalln(app.Listen(":8080"))
}