-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (33 loc) · 907 Bytes
/
main.go
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
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"embed"
"flag"
"log"
notmuch "github.com/zenhack/go.notmuch"
home "github.com/jamesdury/attachments/internal/home"
app "github.com/jamesdury/attachments/internal/server"
email "github.com/jamesdury/attachments/pkg/notmuch"
)
//go:embed static/template/*
var embedDirTemplate embed.FS
//go:embed static/dist/*
var embedDirStatic embed.FS
func main() {
dbPath := flag.String("db", "", "Provide path to the notmuch database directory (contains the .notmuch directory)")
flag.Parse()
if *dbPath == "" {
log.Fatal("Database path not supplied")
}
db, err := notmuch.Open(*dbPath, notmuch.DBReadOnly)
if err != nil {
log.Fatal("Database unavailable")
}
app := app.Setup(
embedDirTemplate,
embedDirStatic,
)
emailService := email.NewService(email.NewRepo(db))
home.Router(app.Group("/"), emailService)
defer db.Close()
log.Fatal(app.Listen(":8080"))
}