bump github.com/Kichiyaki/ginlogrus and github.com/Kichiyaki/go-pg-logrus-query-logger/v10
This commit is contained in:
parent
7b9487fd8d
commit
5bd09500c1
12
go.mod
12
go.mod
|
@ -4,26 +4,34 @@ go 1.16
|
|||
|
||||
require (
|
||||
github.com/99designs/gqlgen v0.13.0
|
||||
github.com/Kichiyaki/gin-logrus v0.0.0-20210428175948-4f47ab6231a6
|
||||
github.com/Kichiyaki/go-pg-logrus-query-logger/v10 v10.0.0-20210428180109-fb97298564d9
|
||||
github.com/Kichiyaki/ginlogrus v0.0.0-20210502060406-bb0049cc40c4 // indirect
|
||||
github.com/Kichiyaki/go-pg-logrus-query-logger/v10 v10.0.0-20210502060056-ad595ba7b858
|
||||
github.com/agnivade/levenshtein v1.1.0 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/gin-contrib/cors v1.3.1
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/go-pg/pg/v10 v10.9.1
|
||||
github.com/go-playground/validator/v10 v10.5.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/uuid v1.2.0
|
||||
github.com/gosimple/slug v1.9.0
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/json-iterator/go v1.1.11 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/sethvargo/go-password v0.2.0
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/ugorji/go v1.2.5 // indirect
|
||||
github.com/vektah/gqlparser/v2 v2.1.0
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.1 // indirect
|
||||
go.opentelemetry.io/otel v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b
|
||||
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 // indirect
|
||||
golang.org/x/text v0.3.6 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
|
8
go.sum
8
go.sum
|
@ -2,10 +2,10 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
|||
github.com/99designs/gqlgen v0.13.0 h1:haLTcUp3Vwp80xMVEg5KRNwzfUrgFdRmtBY8fuB8scA=
|
||||
github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Kichiyaki/gin-logrus v0.0.0-20210428175948-4f47ab6231a6 h1:abarqFzXWxx4VElTTVWJch1u01Kf6T/zLip+Uv2yUf4=
|
||||
github.com/Kichiyaki/gin-logrus v0.0.0-20210428175948-4f47ab6231a6/go.mod h1:6ieK3YHhyNxjkbBUR3B1IsfXi+A+LeS0SEPV10iH/cg=
|
||||
github.com/Kichiyaki/go-pg-logrus-query-logger/v10 v10.0.0-20210428180109-fb97298564d9 h1:S/08K0AD4bXYeSPJKei8ZbumDy1JNARZsgYbNZgr9Tk=
|
||||
github.com/Kichiyaki/go-pg-logrus-query-logger/v10 v10.0.0-20210428180109-fb97298564d9/go.mod h1:ADHVWnGlWcRn1aGthuh7I1Lrn6zzsjkVJju151dXyDw=
|
||||
github.com/Kichiyaki/ginlogrus v0.0.0-20210502060406-bb0049cc40c4 h1:1fPLsfbM6DGZcpdV+IeD/52BP7tL33MoVh7FdUGj14g=
|
||||
github.com/Kichiyaki/ginlogrus v0.0.0-20210502060406-bb0049cc40c4/go.mod h1:PTGPHApaVoNA6eEC72vqvzKRhhSUQnHfh9uSho3rsXk=
|
||||
github.com/Kichiyaki/go-pg-logrus-query-logger/v10 v10.0.0-20210502060056-ad595ba7b858 h1:O7EPPY5lWaKbYB/5yJzE8WMesismUYuje7gOemo1UNo=
|
||||
github.com/Kichiyaki/go-pg-logrus-query-logger/v10 v10.0.0-20210502060056-ad595ba7b858/go.mod h1:ADHVWnGlWcRn1aGthuh7I1Lrn6zzsjkVJju151dXyDw=
|
||||
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
|
||||
github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs=
|
||||
github.com/agnivade/levenshtein v1.1.0 h1:n6qGwyHG61v3ABce1rPVZklEYRT8NFpCMrpZdBUbYGM=
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
envutils "github.com/zdam-egzamin-zawodowy/backend/pkg/utils/env"
|
||||
|
||||
gopglogrusquerylogger "github.com/Kichiyaki/go-pg-logrus-query-logger/v10"
|
||||
"github.com/Kichiyaki/go-pg-logrus-query-logger/v10"
|
||||
"github.com/go-pg/pg/v10"
|
||||
"github.com/go-pg/pg/v10/orm"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -25,12 +25,12 @@ func init() {
|
|||
orm.RegisterTable((*models.QualificationToProfession)(nil))
|
||||
}
|
||||
|
||||
func New(cfg *Config) (*pg.DB, error) {
|
||||
func Connect(cfg *Config) (*pg.DB, error) {
|
||||
db := pg.Connect(prepareOptions())
|
||||
|
||||
if cfg != nil {
|
||||
if cfg.LogQueries {
|
||||
db.AddQueryHook(gopglogrusquerylogger.QueryLogger{
|
||||
db.AddQueryHook(querylogger.Logger{
|
||||
Log: log,
|
||||
MaxQueryLength: 5000,
|
||||
})
|
||||
|
@ -70,19 +70,19 @@ func createSchema(db *pg.DB) error {
|
|||
FKConstraints: true,
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "createSchema")
|
||||
return errors.Wrap(err, "couldn't create the table")
|
||||
}
|
||||
}
|
||||
|
||||
total, err := tx.Model(modelsToCreate[0]).Where("role = ?", models.RoleAdmin).Count()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "createSchema")
|
||||
return errors.Wrap(err, "couldn't count admins")
|
||||
}
|
||||
if total == 0 {
|
||||
activated := true
|
||||
pswd, err := password.Generate(15, 4, 2, true, false)
|
||||
pswd, err := password.Generate(15, 6, 0, true, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "createSchema")
|
||||
return errors.Wrap(err, "couldn't generate a password for the new admin account")
|
||||
}
|
||||
email := "admin@admin.com"
|
||||
_, err = tx.
|
||||
|
|
6
main.go
6
main.go
|
@ -26,7 +26,7 @@ import (
|
|||
userrepository "github.com/zdam-egzamin-zawodowy/backend/internal/user/repository"
|
||||
userusecase "github.com/zdam-egzamin-zawodowy/backend/internal/user/usecase"
|
||||
|
||||
ginlogrus "github.com/Kichiyaki/gin-logrus"
|
||||
"github.com/Kichiyaki/ginlogrus"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/joho/godotenv"
|
||||
|
@ -51,7 +51,7 @@ func main() {
|
|||
BasePath: os.Getenv("FILE_STORAGE_PATH"),
|
||||
})
|
||||
|
||||
dbConn, err := db.New(&db.Config{
|
||||
dbConn, err := db.Connect(&db.Config{
|
||||
LogQueries: envutils.GetenvBool("LOG_DB_QUERIES"),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -184,7 +184,7 @@ func setupLogger() {
|
|||
func setupRouter() *gin.Engine {
|
||||
router := gin.New()
|
||||
|
||||
router.Use(ginlogrus.Logger(logrus.WithField("hostname", "api")), gin.Recovery())
|
||||
router.Use(ginlogrus.Logger(logrus.WithFields(map[string]interface{}{})), gin.Recovery())
|
||||
if mode.Get() == mode.DevelopmentMode {
|
||||
router.Use(cors.New(cors.Config{
|
||||
AllowOriginFunc: func(string) bool {
|
||||
|
|
Reference in New Issue