-
Notifications
You must be signed in to change notification settings - Fork 0
/
wire_gen.go
79 lines (74 loc) · 2.16 KB
/
wire_gen.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//+build !wireinject
package main
import (
"github.com/rwlist/rwcore/admin"
"github.com/rwlist/rwcore/article"
"github.com/rwlist/rwcore/auth"
"github.com/rwlist/rwcore/conf"
"github.com/rwlist/rwcore/cors"
"github.com/rwlist/rwcore/habr"
"github.com/rwlist/rwcore/habr/client"
"github.com/rwlist/rwcore/mod"
"github.com/rwlist/rwcore/mod/dbinit"
"github.com/rwlist/rwcore/router"
"github.com/rwlist/rwcore/srv"
)
// Injectors from wire.go:
func Initialize(filepath string) (App, func(), error) {
config, err := conf.New(filepath)
if err != nil {
return App{}, nil, err
}
srvConfig := conf.ProvideSrv(config)
middleware := cors.NewMiddleware()
jwtConfig := conf.ProvideJWT(config)
jwt := auth.NewJWT(jwtConfig)
authMiddleware := auth.NewMiddleware(jwt)
modConfig := conf.ProvideMongo(config)
provider, cleanup, err := mod.NewProvider(modConfig)
if err != nil {
return App{}, nil, err
}
modMiddleware := mod.NewMiddleware(provider)
mid := &router.Mid{
CORS: middleware,
Auth: authMiddleware,
DB: modMiddleware,
}
stdClaims, err := auth.NewStdClaims(jwtConfig)
if err != nil {
cleanup()
return App{}, nil, err
}
authAuth := auth.NewAuth(jwt, stdClaims)
controller := auth.NewController(authAuth, jwt, authMiddleware)
authRouter := auth.NewRouter(controller)
adminController := admin.NewController()
adminRouter := admin.NewRouter(adminController, authMiddleware)
service := article.NewService()
articleController := article.NewController(service)
articleMiddleware := article.NewMiddleware()
articleRouter := article.NewRouter(articleController, authMiddleware, articleMiddleware)
routes := &router.Routes{
Auth: authRouter,
Admin: adminRouter,
Articles: articleRouter,
}
routerRouter := router.New(mid, routes)
server := srv.New(srvConfig, routerRouter)
once := dbinit.NewOnce(provider)
clientClient := client.NewClient()
readerDailyTop := client.NewReaderDailyTop(clientClient)
habrService, cleanup2 := habr.NewService(readerDailyTop, provider)
app := App{
Server: server,
DbInit: once,
Habr: habrService,
}
return app, func() {
cleanup2()
cleanup()
}, nil
}