-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (35 loc) · 881 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 (
"log"
"os"
"github.com/incrypt0/cokut-server/fire"
"github.com/incrypt0/cokut-server/handler2"
"github.com/incrypt0/cokut-server/handler2/middleware"
"github.com/incrypt0/cokut-server/router"
"github.com/incrypt0/cokut-server/store"
"github.com/incrypt0/cokut-server/workers"
)
func main() {
log.SetFlags(log.Llongfile)
// Initialize Firebase
app, err := fire.InitFire()
if err != nil {
log.Panic(err)
}
fireAuthMWare := middleware.FireAuthMiddleware(app)
// Connect to mongo
w := workers.New()
s := store.NewStore("meals", "users", "orders", "restaurants", w)
// echo instance
r := router.New()
// Main Echo Handler
h := handler2.NewHandler(s, fireAuthMWare)
h.Register(r)
// Server Start
PORT := os.Getenv("PORT")
if PORT == "" {
log.Println("PORT is empty")
PORT = "4000"
}
r.Logger.Fatal(r.Start(":" + PORT))
}