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.

43 lines
792 B
Go

package main
import (
"log"
"os"
"os/exec"
"strings"
"github.com/aziis98/lupus-lite/routes"
"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()
server := routes.NewServer()
app.Use(logger.New())
app.Use(recover.New())
// Static files
app.Static("/", "./_frontend/dist")
app.Route("/", server.EventRoute)
app.Route("/", server.PageRoutes)
app.Route("/api", server.ApiRoutes)
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"))
}