-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (31 loc) · 865 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
package main
import (
"database/sql"
"log"
"github.com/kokoichi206/account-book-api/api"
"github.com/kokoichi206/account-book-api/auth"
db "github.com/kokoichi206/account-book-api/db/sqlc"
"github.com/kokoichi206/account-book-api/util"
"go.uber.org/zap"
_ "github.com/lib/pq"
)
func main() {
config, err := util.LoadConfig(".")
if err != nil {
log.Fatal("cannot load config:", err)
}
conn, err := sql.Open(config.DBDriver, config.DBSource)
if err != nil {
log.Fatal("Cannot connect to db: ", err)
}
querier := db.New(conn)
manager := auth.NewManager(querier)
logger := util.InitLogger()
// globalで上記設定を使えるようにする。
zap.ReplaceGlobals(logger)
server := api.NewServer(config, querier, manager, logger)
err = server.Start(config.ServerAddress)
if err != nil {
log.Fatal("cannot start server:", err)
}
}