-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e6d628
commit e5439ae
Showing
7 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package handler | ||
|
||
type ( | ||
loginRequest struct { | ||
Username string `json:"username"` | ||
Password string `json:"password"` | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package handler | ||
|
||
import "github.com/gofiber/fiber/v3" | ||
|
||
type ( | ||
errorResponse struct { | ||
Code int `json:"code"` | ||
Message string `json:"message"` | ||
} | ||
|
||
successResponse struct { | ||
Code int `json:"code"` | ||
Message string `json:"message"` | ||
Data interface{} `json:"data"` | ||
} | ||
) | ||
|
||
// sendErrorResponse generates and sends error response | ||
func sendErrorResponse(c fiber.Ctx, statusCode int, errorMessage string) error { | ||
response := errorResponse{ | ||
Code: statusCode, | ||
Message: errorMessage, | ||
} | ||
|
||
return c.Status(statusCode).JSON(response) | ||
} | ||
|
||
// sendSuccessResponse generates and sends success response with dynamic data | ||
func sendSuccessResponse(c fiber.Ctx, statusCode int, message string, data interface{}) error { | ||
response := successResponse{ | ||
Code: statusCode, | ||
Message: message, | ||
Data: data, | ||
} | ||
|
||
return c.Status(statusCode).JSON(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package ports | ||
|
||
import "github.com/voltgizerz/POS-restaurant/internal/app/entity" | ||
|
||
type IAuth interface { | ||
CreateToken(username string) (string, error) | ||
CreateToken(user *entity.User) (string, error) | ||
VerifyToken(tokenString string) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters