added: auth methods
This commit is contained in:
parent
a176522bbb
commit
28da81ea59
5 changed files with 223 additions and 44 deletions
45
cmd/main.go
45
cmd/main.go
|
|
@ -8,6 +8,8 @@ import (
|
|||
"merch-parser-api/internal/api/user"
|
||||
"merch-parser-api/internal/app"
|
||||
"merch-parser-api/internal/interfaces"
|
||||
"merch-parser-api/internal/provider/auth"
|
||||
"merch-parser-api/internal/provider/token"
|
||||
"merch-parser-api/internal/router"
|
||||
"merch-parser-api/pkg/db"
|
||||
"merch-parser-api/pkg/utils"
|
||||
|
|
@ -15,45 +17,58 @@ import (
|
|||
|
||||
// @Title Merch Parser
|
||||
// @BasePath /api/v2
|
||||
// @Version 2.0.0-alpha
|
||||
// @Version 2.0.0-alpha
|
||||
// @SecurityDefinitions.apikey BearerAuth
|
||||
// @In header
|
||||
// @Name Authorization
|
||||
// @Description Введите "Bearer {your_token}" для аутентификации
|
||||
// @Description Введите "Bearer {your_token}" для аутентификации
|
||||
func main() {
|
||||
log.Debug("Starting merch-parser-api")
|
||||
//setup config
|
||||
//c := config.NewConfig()
|
||||
c := config.DevConfig()
|
||||
ctx := context.Background()
|
||||
|
||||
//log level
|
||||
config.LogSetup(c.AppConf.LogLvl)
|
||||
|
||||
database, err := db.Connection(c)
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("Main | Error connecting to database")
|
||||
}
|
||||
|
||||
_ = database
|
||||
//base providers
|
||||
jwtProvider := token.NewJWT(token.Deps{
|
||||
SecretKey: c.JWTConf.Secret,
|
||||
Issuer: c.JWTConf.Issuer,
|
||||
AccessExpire: c.JWTConf.AccessExpire,
|
||||
RefreshExpire: c.JWTConf.RefreshExpire,
|
||||
})
|
||||
log.Debug("JWT provider initialized")
|
||||
|
||||
utilsProvider := utils.NewUtils()
|
||||
log.Debug("Utils provider initialized")
|
||||
|
||||
//deps providers
|
||||
routerHandler := router.NewRouter(router.Deps{
|
||||
ApiPrefix: c.AppConf.ApiPrefix,
|
||||
GinMode: c.AppConf.GinMode,
|
||||
TokenProv: jwtProvider,
|
||||
})
|
||||
log.Debug("Router handler initialized")
|
||||
|
||||
//base providers
|
||||
//jwtProv := token.NewJWT(token.Deps{
|
||||
// SecretKey: c.JWTConf.Secret,
|
||||
// Issuer: c.JWTConf.Issuer,
|
||||
// AccessExpire: c.JWTConf.AccessExpire,
|
||||
// RefreshExpire: c.JWTConf.RefreshExpire,
|
||||
//})
|
||||
|
||||
utilsProv := utils.NewUtils()
|
||||
|
||||
//deps providers
|
||||
authProvider := auth.NewHandler(auth.Deps{
|
||||
DB: database,
|
||||
JwtProvider: jwtProvider,
|
||||
Utils: utilsProvider,
|
||||
})
|
||||
log.Debug("Auth provider initialized")
|
||||
|
||||
//register app modules
|
||||
users := user.NewHandler(user.Deps{
|
||||
Auth: authProvider,
|
||||
DB: database,
|
||||
Utils: utilsProv,
|
||||
Utils: utilsProvider,
|
||||
})
|
||||
|
||||
//collect modules
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue