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.
39 lines
699 B
Go
39 lines
699 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()
|
|
app.Use(logger.New())
|
|
app.Use(recover.New())
|
|
|
|
// Static files
|
|
app.Static("/", "./_frontend/dist")
|
|
|
|
// Api routes
|
|
app.Route("/api", routes.Api)
|
|
|
|
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"))
|
|
}
|