Removed useless files from domain/

This commit is contained in:
PB
2025-10-20 17:10:05 +02:00
parent ce20b2cc18
commit ddbb8bea25
6 changed files with 0 additions and 95 deletions

View File

@@ -1,9 +0,0 @@
package definition
type ErrorResponse struct {
Error string `json:"error"`
}
func Error(err string) *ErrorResponse {
return &ErrorResponse{err}
}

View File

@@ -1,18 +0,0 @@
package entity
import "time"
type User struct {
ID int `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
CreateDate time.Time `json:"create_date"`
ModifyDate time.Time `json:"modify_date"` // FIXME: zero-value issue
}
var TestUser = &User{
ID: 1,
Username: "test",
Password: "test",
CreateDate: time.Now(),
}

View File

@@ -1 +0,0 @@
package handler

View File

@@ -1,10 +0,0 @@
package handler
import (
"github.com/gofiber/fiber/v2"
)
func SecretHandler(c *fiber.Ctx) error {
return nil
}

View File

@@ -1,20 +0,0 @@
package app
import (
"log"
)
const AppName = "identity-service"
func Panic(v ...any) {
log.Panicln(AppName+":", v)
}
func Panicf(format string, v ...any) {
log.Panicf(AppName+": "+format, v...)
}
func Panicln(v ...any) {
v = append([]any{AppName + ":"}, v...)
log.Panicln(v...)
}

View File

@@ -1,37 +0,0 @@
package middleware
import (
"os"
"github.com/gofiber/fiber/v2"
jwt "github.com/gofiber/jwt/v2"
)
// JWTProtected func for specify routes group with JWT authentication.
// See: https://github.com/gofiber/jwt
func JWTProtected() func(*fiber.Ctx) error {
// Create config for JWT authentication middleware.
config := jwt.Config{
SigningKey: []byte(os.Getenv("JWT_SECRET_KEY")),
ContextKey: "jwt", // used in private routes
ErrorHandler: jwtError,
}
return jwt.New(config)
}
func jwtError(c *fiber.Ctx, err error) error {
// Return status 400 Bad Request and failed authentication error.
if err.Error() == "Missing or malformed JWT" {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": true,
"msg": err.Error(),
})
}
// Return status 401 Unauthorized and failed authentication error.
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
"error": true,
"msg": err.Error(),
})
}