main.go
package main
import (
"embed"
"os"
"strings"
"github.com/readysite/readysite/hosting/controllers"
"github.com/readysite/readysite/pkg/application"
"github.com/readysite/readysite/pkg/application/emailers"
"github.com/readysite/readysite/pkg/frontend"
"github.com/readysite/readysite/pkg/frontend/esbuild"
)
//go:embed views
var views embed.FS
//go:embed all:emails
var emails embed.FS
func main() {
// Select emailer based on environment
var emailer application.Emailer
if key := os.Getenv("RESEND_API_KEY"); key != "" {
emailer = emailers.NewResend(emails, key, "ReadySite Hosting <noreply@theskyscape.com>", nil)
} else {
emailer = emailers.NewLogger(emails, nil)
}
application.Serve(views,
application.WithValue("theme", "dark"),
application.WithEmailer(emailer),
application.WithFunc("upper", strings.ToUpper),
frontend.WithBundler(&esbuild.Config{
Entry: "frontend/index.js",
Include: []string{"frontend"},
}),
application.WithController(controllers.Home()),
application.WithController(controllers.Auth()),
application.WithController(controllers.Billing()),
application.WithController(controllers.Settings()),
application.WithController(controllers.Sites()),
)
}