main.go.tmpl

34 lines
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
package main

import (
	"embed"
	"<<.Module>>/<<.Dir>>/controllers"
	"<<.Module>>/internal/application"
	"<<.Module>>/internal/router"
	"<<.Module>>/internal/security"
<<- if .WithFrontend>>
	"<<.Module>>/internal/frontend"
	"<<.Module>>/internal/frontend/esbuild"
<<- end>>
)

//go:embed all:views
var views embed.FS

func main() {
	router.Listen(
		router.WithLogger(),
		security.New(security.WithNonce(), security.WithHeaders()),
		application.New(views,
			application.WithValue("theme", "dark"),
			application.WithValue("app_name", "<<.Name>>"),
<<- if .WithFrontend>>
			frontend.WithBundler(&esbuild.Config{
				Entry:   "<<.Dir>>/index.ts",
				Include: []string{"<<.Dir>>/components"},
			}),
<<- end>>
			application.WithController(controllers.Home()),
		),
	)
}