-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (47 loc) · 1.51 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
package main
import (
"fmt"
"net/http"
"time"
"github.com/WestCoastOpenSource/GameStore/api"
"github.com/WestCoastOpenSource/GameStore/api/client"
"github.com/WestCoastOpenSource/GameStore/pkg/auth"
"github.com/WestCoastOpenSource/GameStore/pkg/clock"
"github.com/WestCoastOpenSource/GameStore/pkg/logger"
"github.com/WestCoastOpenSource/GameStore/pkg/storage"
cache "github.com/patrickmn/go-cache"
)
func main() {
saveSystem := storage.LocalDisk{
File: "gamestore_client_",
Directory: "/var/log/gamestore/",
}
logSystem := logger.FileSystemLogs{Save: &saveSystem}
router := api.GameStoreRouter{
HTTPHandler: http.NewServeMux(),
FacebookClient: newFacebookClient(logSystem),
ServerClient: newServerClient(logSystem),
}
router.CreateRoutes()
fmt.Println("GameStore running on port :3000")
if err := http.ListenAndServe(":3000", router.HTTPHandler); err != nil {
fmt.Printf(err.Error())
}
}
func newServerClient(logs logger.FileSystemLogs) *client.ServerClient {
server := client.ServerClient{Logger: logs}
server.Clock = clock.ServerClock{}
return &server
}
func newFacebookClient(logs logger.FileSystemLogs) *client.FacebookClient {
facebookConfig := auth.FacebookAuthConfig{}
facebookConfig.Create()
facebook := client.FacebookClient{
AuthConfig: &facebookConfig,
Cache: cache.New(60*time.Minute, 30*time.Second),
Logger: logs,
SuccessTemplate: "./templates/login_success.html",
FailureTemplate: "./templates/login_failure.html",
}
return &facebook
}