Code #
1package main
2
3import (
4 "os"
5
6 "github.com/a-h/templ/examples/counter/db"
7 "github.com/a-h/templ/examples/counter/handlers"
8 "github.com/a-h/templ/examples/counter/services"
9 "github.com/a-h/templ/examples/counter/session"
10 "github.com/akrylysov/algnhsa"
11 "golang.org/x/exp/slog"
12)
13
14func main() {
15 // Create handlers.
16 log := slog.New(slog.NewJSONHandler(os.Stdout))
17 s, err := db.NewCountStore(os.Getenv("TABLE_NAME"), os.Getenv("AWS_REGION"))
18 if err != nil {
19 log.Error("failed to create store", slog.Any("error", err))
20 os.Exit(1)
21 }
22 cs := services.NewCount(log, s)
23 h := handlers.New(log, cs)
24
25 // Add session middleware.
26 sh := session.NewMiddleware(h)
27
28 // Start Lambda.
29 algnhsa.ListenAndServe(sh, nil)
30}