23 lines
442 B
Go
23 lines
442 B
Go
package config
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.starryskymeow.cn/B309/datamarket/internal/repository"
|
|
"github.com/go-chi/jwtauth/v5"
|
|
)
|
|
|
|
type Config struct {
|
|
JWTAuth *jwtauth.JWTAuth
|
|
}
|
|
|
|
func New(repo *repository.Queries) (*Config, error) {
|
|
config := new(Config)
|
|
cfg, err := repo.GetConfig(context.Background())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
config.JWTAuth = jwtauth.New(cfg.JwtAlg, []byte(cfg.JwtSignKey), nil)
|
|
return config, nil
|
|
}
|