-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (52 loc) · 1.22 KB
/
main.go
File metadata and controls
60 lines (52 loc) · 1.22 KB
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
package main
import (
"encoding/json"
"externos.io/AccountsServer/auth"
"externos.io/AccountsServer/db"
"externos.io/AccountsServer/server"
"fmt"
"github.com/eXtern-OS/AMS"
beatrix "github.com/eXtern-OS/Beatrix"
tm "github.com/eXtern-OS/TokenMaster"
"github.com/gin-gonic/gin"
"log"
"os"
)
type Config struct {
BeatrixToken string `json:"beatrix-token"`
BeatrixChannel string `json:"beatrix-channelID"`
MongoURI string `json:"mongo-uri"`
SQLURI string `json:"sql-uri"`
WebsiteURL string `json:"website_url"`
}
func LoadConfig() Config {
var config Config
configFile, err := os.Open("ams-credentials.json")
if err != nil {
log.Panic(err)
}
jsonParser := json.NewDecoder(configFile)
err = jsonParser.Decode(&config)
fmt.Println(config)
err = configFile.Close()
if err != nil {
log.Panic(err)
}
return config
}
func Init(cx Config, r *gin.Engine) {
beatrix.Init("AccountsServer", cx.BeatrixToken, cx.BeatrixChannel)
AMS.Init(cx.MongoURI, cx.SQLURI)
tm.Init(cx.MongoURI)
db.Init(cx.MongoURI)
auth.Init()
server.Init(r, cx.WebsiteURL)
}
func main() {
r := gin.Default()
cx := LoadConfig()
r.LoadHTMLGlob("static/*.html")
r.Static("/assets", "./static/assets")
Init(cx, r)
r.Run(":80")
}