-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 697 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
package main
import (
"flag"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"go-shortfile/router"
"go-shortfile/utils"
"log"
"net/http"
"strconv"
)
func main() {
utils.InitLogger()
app := fiber.New()
app.Use(cors.New())
var port int
flag.IntVar(&port, "port", 3000, "The port to listen on")
flag.Parse()
//Api Endpoints
router.AddRouters(app)
app.Use("/", filesystem.New(filesystem.Config{
Root: http.Dir("./frontend/dist"),
}))
utils.Log.Info("Starting fiber on port: " + strconv.Itoa(port))
err := app.Listen(":" + strconv.Itoa(port))
if err != nil {
log.Fatalln(err.Error())
}
}