remove unused go stuff
Some checks failed
Build / build (push) Failing after 6m2s

This commit is contained in:
Gustavo Maronato 2023-08-30 21:33:57 -03:00
parent 29ad94ed68
commit f06e933a80
Signed by: maronato
SSH Key Fingerprint: SHA256:2Gw7kwMz/As+2UkR1qQ/qYYhn+WNh3FGv6ozhoRrLcs
9 changed files with 7 additions and 30 deletions

View File

@ -96,7 +96,3 @@ func RenderUnauthorized(w http.ResponseWriter, r *http.Request) {
func RenderForbidden(w http.ResponseWriter, r *http.Request) {
RenderRender(w, r, ErrForbidden())
}
func RenderRendering(w http.ResponseWriter, r *http.Request, err error) {
RenderRender(w, r, ErrRendering(err))
}

View File

@ -20,8 +20,6 @@ const (
MinShortLength = 4
// MaxShortLength is the maximum length of the short URL.
MaxShortLength = 20
// ShortIDLength is the length of the short ID.
ShortIDLength = 16
)
type ShortService struct {
@ -50,7 +48,7 @@ func (s *ShortService) FindShort(ctx context.Context, name string) (*models.Shor
func (s *ShortService) FindShortByID(ctx context.Context, id string) (*models.Short, error) {
// Check if the ID is valid
if len(id) != ShortIDLength {
if !models.LooksLikeID(id) {
return &models.Short{}, errs.ErrInvalidShort
}

View File

@ -16,8 +16,6 @@ const (
TokenLength = 32
// TokenPrefix is the prefix of a token.
TokenPrefix = "gst_"
// DefaultTokenIDLength is the default length of a token ID.
TokenIDLength = 16
// MinTokenNameLength is the minimum length of a token name.
MinTokenNameLength = 4
// MaxTokenNameLength is the maximum length of a token name.
@ -60,7 +58,7 @@ func (s *TokenService) FindToken(ctx context.Context, value string) (*models.Tok
// FindTokenByID finds a token in the storage using its ID.
func (s *TokenService) FindTokenByID(ctx context.Context, id string) (*models.Token, error) {
// Check if the ID is valid
if len(id) != models.IDLength {
if !models.LooksLikeID(id) {
return &models.Token{}, errs.ErrInvalidTokenID
}

View File

@ -18,11 +18,6 @@ type UserModel struct {
Password string `bun:",notnull" json:"-"`
// CreatedAt is when the user was created (initialized by the storage)
CreatedAt time.Time `bun:",notnull,default:current_timestamp" json:"createdAt"`
// Shorts is the list of shorts created by the user
Shorts []*ShortModel `bun:"rel:has-many,join:id=user_id" json:"shorts,omitempty"`
// Tokens is the list of access tokens created by the user
Tokens []*TokenModel `bun:"rel:has-many,join:id=user_id" json:"tokens,omitempty"`
}
func (u *UserModel) toUser() *models.User {
@ -51,8 +46,6 @@ type ShortModel struct {
// UserID is the ID of the user that created the short
// This can be null if the short was deleted
UserID *string `json:"-"`
// User is the user that created the short
User *UserModel `bun:"rel:belongs-to,join:user_id=id" json:"user,omitempty"`
}
func (s *ShortModel) toShort() *models.Short {
@ -79,8 +72,6 @@ type TokenModel struct {
// UserID is the ID of the user that created the token
UserID *string `bun:",notnull" json:"-"`
// User is the user that created the token
User *UserModel `bun:"rel:belongs-to,join:user_id=id" json:"user,omitempty"`
}
func (t *TokenModel) toToken() *models.Token {
@ -109,8 +100,6 @@ type ShortLogModel struct {
// ShortID is the ID of the short that was accessed
ShortID string `bun:",notnull" json:"-"`
// Short is the short that was accessed
Short *ShortModel `bun:"rel:belongs-to,join:short_id=id" json:"short,omitempty"`
}
func (sl *ShortLogModel) toShortLog() *models.ShortLog {

View File

@ -12,3 +12,7 @@ const (
func NewID() string {
return randomutil.GenerateSecureToken(IDLength)
}
func LooksLikeID(id string) bool {
return len(id) == IDLength
}

View File

@ -2,10 +2,6 @@ package models
import "time"
const (
ShortIDLength = 16
)
type Short struct {
// ID is the unique identifier of the short.
ID string `json:"id"`

View File

@ -5,9 +5,7 @@ import (
"log/slog"
)
type NoOpHandler struct {
slog.Handler
}
type NoOpHandler struct{}
func NewNoOpHandler() *NoOpHandler {
return &NoOpHandler{}

View File

@ -25,7 +25,6 @@ type argonParams struct {
}
type ArgonHasher struct {
passwords.PasswordHasher
params *argonParams
}

View File

@ -11,7 +11,6 @@ import (
const defaultCost = 13
type BcryptHasher struct {
passwords.PasswordHasher
cost int
}