/
server.go
48 lines (40 loc) · 1.27 KB
/
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
46
47
48
package interfaces
import (
"github.com/m0t0k1ch1/metamask-login-sample/application"
appAuth "github.com/m0t0k1ch1/metamask-login-sample/application/auth"
appUser "github.com/m0t0k1ch1/metamask-login-sample/application/user"
"github.com/m0t0k1ch1/metamask-login-sample/infrastructure/auth/metamask"
cacheUser "github.com/m0t0k1ch1/metamask-login-sample/infrastructure/cache/user"
"github.com/m0t0k1ch1/metamask-login-sample/interfaces/server"
"github.com/m0t0k1ch1/metamask-login-sample/interfaces/server/handler"
)
func NewServer(conf *server.Config) *server.Server {
srv := server.New(newCore(conf))
srv.File("/", srv.Config.IndexFilePath)
srv.Static("/static", srv.Config.StaticDirPath)
handler.SetUp(srv.Base())
return srv
}
func newCore(conf *server.Config) *server.Core {
appCore := newAppCore(conf.App)
return &server.Core{
Config: conf,
Apps: &server.Apps{
Auth: appAuth.NewApplication(appCore),
User: appUser.NewApplication(appCore),
},
}
}
func newAppCore(conf *application.Config) *application.Core {
return &application.Core{
Services: &application.Services{
Auth: metamask.NewService(
conf.Auth.Secret,
conf.Auth.TokenExpiryDuration(),
),
},
Repositories: &application.Repositories{
User: cacheUser.NewRepository(),
},
}
}