-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver.go
45 lines (36 loc) · 923 Bytes
/
server.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
package main
import (
"context"
"go-echo-starter/db"
"go-echo-starter/env"
"go-echo-starter/handler"
"go-echo-starter/store"
"go-echo-starter/validator"
firebase "firebase.google.com/go"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/labstack/gommon/log"
"google.golang.org/api/option"
)
func main() {
e := echo.New()
e.Validator = validator.NewValidator()
e.Logger.SetLevel(log.DEBUG)
e.Use(middleware.Logger())
api := e.Group("/api")
opt := option.WithCredentialsFile("firebase_secret_key.json")
app, err := firebase.NewApp(context.Background(), nil, opt)
if err != nil {
log.Fatal(err)
}
client, err := app.Auth(context.Background())
if err != nil {
log.Fatal(err)
}
as := store.NewAuthStore(client)
d := db.New(env.NewAppEnv())
us := store.NewUserStore(d)
h := handler.NewHandler(*as, *us)
h.Register(api)
e.Logger.Fatal(e.Start(":8000"))
}