-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (48 loc) · 1.2 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"log"
"os"
"github.com/nautilus/gateway"
"github.com/nautilus/graphql"
"com.thebeachmaster/nautilusgw/config"
"com.thebeachmaster/nautilusgw/server"
_ "github.com/joho/godotenv/autoload"
)
func main() {
log.Println("Starting Server...")
/// Configs
var cfg *config.Config
if os.Getenv("USE_FILE_CONFIG") == "true" {
appConfigPath := "./config/config"
cfgFile, err := config.LoadConfig(appConfigPath)
if err != nil {
log.Fatalf("LoadConfig Error: %s", err.Error())
}
pc, err := config.ParseConfig(cfgFile)
if err != nil {
log.Fatalf("ParseConfig Error: %s", err.Error())
}
cfg = pc
} else {
lc, err := config.LoadEnvConfig()
if err != nil {
log.Fatalf("ParseConfig Error: %s", err.Error())
}
cfg = lc
}
/// Gateway Init
// Load the endpoints here first before anything...
schemas, err := graphql.IntrospectRemoteSchemas(cfg.GraphQLEndpoints...)
if err != nil {
log.Fatalf("Schema loading error: %s", err.Error())
}
gw, err := gateway.New(schemas)
if err != nil {
log.Fatalf("Gateway initialization error: %s", err.Error())
}
/// Server Init
server := server.NewServer(cfg, gw)
if err = server.Run(); err != nil {
log.Fatal(err)
}
}