change to api only handler and remove unused files, bring more structure

This commit is contained in:
Adrian Zürcher
2025-10-26 10:38:44 +01:00
parent b6988638c0
commit 8d8a1e3c33
13 changed files with 144 additions and 979 deletions

14
internal/utils/hash.go Normal file
View File

@@ -0,0 +1,14 @@
package utils
import "golang.org/x/crypto/bcrypt"
// Hash password
func HashPassword(password string) (string, error) {
b, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(b), err
}
// Check password
func CheckPassword(password, hash string) bool {
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) == nil
}

8
internal/utils/utils.go Normal file
View File

@@ -0,0 +1,8 @@
package utils
import "regexp"
func IsValidEmail(email string) bool {
re := regexp.MustCompile(`^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$`)
return re.MatchString(email)
}