feat(frontend): working Discord login + signup
This commit is contained in:
parent
0e72097346
commit
c8b5b7e2c2
24 changed files with 287 additions and 119 deletions
|
@ -7,12 +7,9 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
|
||||
"codeberg.org/u1f320/pronouns.cc/backend/log"
|
||||
"emperror.dev/errors"
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v4"
|
||||
"github.com/jackc/pgx/v4/log/zapadapter"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"github.com/mediocregopher/radix/v4"
|
||||
"github.com/minio/minio-go/v7"
|
||||
|
@ -38,15 +35,7 @@ type DB struct {
|
|||
}
|
||||
|
||||
func New() (*DB, error) {
|
||||
pgxCfg, err := pgxpool.ParseConfig(os.Getenv("DATABASE_URL"))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "parsing config")
|
||||
}
|
||||
pgxCfg.ConnConfig.LogLevel = pgx.LogLevelDebug
|
||||
pgxCfg.ConnConfig.Logger = zapadapter.NewLogger(log.Logger)
|
||||
|
||||
pool, err := pgxpool.ConnectConfig(context.Background(), pgxCfg)
|
||||
// pool, err := pgxpool.Connect(context.Background(), os.Getenv("DATABASE_URL"))
|
||||
pool, err := pgxpool.Connect(context.Background(), os.Getenv("DATABASE_URL"))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "creating postgres client")
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func (f Field) Validate() string {
|
|||
|
||||
// UserFields returns the fields associated with the given user ID.
|
||||
func (db *DB) UserFields(ctx context.Context, id xid.ID) (fs []Field, err error) {
|
||||
sql, args, err := sq.Select("*").From("user_fields").Where("user_id = ?", id).OrderBy("id").ToSql()
|
||||
sql, args, err := sq.Select("id", "name", "entries").From("user_fields").Where("user_id = ?", id).OrderBy("id").ToSql()
|
||||
if err != nil {
|
||||
return fs, errors.Wrap(err, "building sql")
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func (db *DB) SetUserFields(ctx context.Context, tx pgx.Tx, userID xid.ID, field
|
|||
|
||||
// MemberFields returns the fields associated with the given member ID.
|
||||
func (db *DB) MemberFields(ctx context.Context, id xid.ID) (fs []Field, err error) {
|
||||
sql, args, err := sq.Select("*").From("member_fields").Where("member_id = ?", id).OrderBy("id").ToSql()
|
||||
sql, args, err := sq.Select("id", "name", "entries").From("member_fields").Where("member_id = ?", id).OrderBy("id").ToSql()
|
||||
if err != nil {
|
||||
return fs, errors.Wrap(err, "building sql")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue