You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
661 B
Go

package main
import (
"log"
"os"
"os/exec"
"strings"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
)
func main() {
mode := os.Getenv("MODE")
app := fiber.New()
app.Use(logger.New())
app.Use(recover.New())
// Static files
app.Static("/", "./frontend/dist")
// Api routes
app.Route("/api", mountApiRoutes)
if strings.HasPrefix(mode, "dev") {
log.Printf(`Running dev server for frontend: "npm run dev"`)
err := (exec.Command("sh", "-c", "cd frontend/ && npm run dev").Start())
if err != nil {
log.Fatal(err)
}
}
log.Fatal(app.Listen(":4000"))
}