From 85a83b6659ad9e08bbbad4fa30b231add2a57e0a Mon Sep 17 00:00:00 2001 From: Annisa Rachmadiyanti Date: Tue, 18 Nov 2025 14:31:13 +0700 Subject: [PATCH] Perbaikan Swagger dan ke DB Prod SIMRS --- docker-compose.yml | 8 ++++---- docs/docs.go | 16 ++++++++-------- docs/swagger.json | 16 ++++++++-------- docs/swagger.yaml | 16 ++++++++-------- internal/handlers/auth/auth.go | 8 ++++---- internal/handlers/auth/token.go | 4 ++-- internal/services/websocket/broadcaster.go | 4 ++-- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0bbd9d7..6e53779 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,10 +17,10 @@ services: # Default Database Configuration (PostgreSQL) DB_CONNECTION: postgres - DB_USERNAME: simtest - DB_PASSWORD: 12345 - DB_HOST: 10.10.123.223 - DB_DATABASE: simrsbackup + DB_USERNAME: simrs + DB_PASSWORD: simrs.rssa + DB_HOST: 10.10.123.163 + DB_DATABASE: simrs DB_PORT: 5432 DB_SSLMODE: disable diff --git a/docs/docs.go b/docs/docs.go index dac397d..359e7b6 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -24,7 +24,7 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/api/v1/auth/login": { + "/auth/login": { "post": { "description": "Authenticate user with username and password to receive JWT token", "consumes": [ @@ -76,7 +76,7 @@ const docTemplate = `{ } } }, - "/api/v1/auth/me": { + "/auth/me": { "get": { "security": [ { @@ -110,7 +110,7 @@ const docTemplate = `{ } } }, - "/api/v1/auth/refresh": { + "/auth/refresh": { "post": { "description": "Refresh the JWT token using a valid refresh token", "consumes": [ @@ -165,7 +165,7 @@ const docTemplate = `{ } } }, - "/api/v1/auth/register": { + "/auth/register": { "post": { "description": "Register a new user account", "consumes": [ @@ -214,7 +214,7 @@ const docTemplate = `{ } } }, - "/api/v1/token/generate": { + "/token/generate": { "post": { "description": "Generate a JWT token for a user", "consumes": [ @@ -266,7 +266,7 @@ const docTemplate = `{ } } }, - "/api/v1/token/generate-direct": { + "/token/generate-direct": { "post": { "description": "Generate a JWT token directly without password verification (for testing)", "consumes": [ @@ -312,7 +312,7 @@ const docTemplate = `{ } } }, - "/api/v1/ws/broadcast/check": { + "/ws/broadcast/check": { "post": { "description": "Creates and broadcasts a WebSocket message with the specified type and data", "consumes": [ @@ -363,7 +363,7 @@ const docTemplate = `{ } } }, - "/api/v1/ws/broadcast/qris": { + "/ws/broadcast/qris": { "post": { "description": "Creates and broadcasts a WebSocket message with the specified type and data for QRIS operations", "consumes": [ diff --git a/docs/swagger.json b/docs/swagger.json index dda1125..112b830 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -22,7 +22,7 @@ "host": "localhost:8080", "basePath": "/api/v1", "paths": { - "/api/v1/auth/login": { + "/auth/login": { "post": { "description": "Authenticate user with username and password to receive JWT token", "consumes": [ @@ -74,7 +74,7 @@ } } }, - "/api/v1/auth/me": { + "/auth/me": { "get": { "security": [ { @@ -108,7 +108,7 @@ } } }, - "/api/v1/auth/refresh": { + "/auth/refresh": { "post": { "description": "Refresh the JWT token using a valid refresh token", "consumes": [ @@ -163,7 +163,7 @@ } } }, - "/api/v1/auth/register": { + "/auth/register": { "post": { "description": "Register a new user account", "consumes": [ @@ -212,7 +212,7 @@ } } }, - "/api/v1/token/generate": { + "/token/generate": { "post": { "description": "Generate a JWT token for a user", "consumes": [ @@ -264,7 +264,7 @@ } } }, - "/api/v1/token/generate-direct": { + "/token/generate-direct": { "post": { "description": "Generate a JWT token directly without password verification (for testing)", "consumes": [ @@ -310,7 +310,7 @@ } } }, - "/api/v1/ws/broadcast/check": { + "/ws/broadcast/check": { "post": { "description": "Creates and broadcasts a WebSocket message with the specified type and data", "consumes": [ @@ -361,7 +361,7 @@ } } }, - "/api/v1/ws/broadcast/qris": { + "/ws/broadcast/qris": { "post": { "description": "Creates and broadcasts a WebSocket message with the specified type and data for QRIS operations", "consumes": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index edef21f..b71cb60 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -44,7 +44,7 @@ info: title: API Service version: 1.0.0 paths: - /api/v1/auth/login: + /auth/login: post: consumes: - application/json @@ -78,7 +78,7 @@ paths: summary: Login user and get JWT token tags: - Authentication - /api/v1/auth/me: + /auth/me: get: description: Get information about the currently authenticated user produces: @@ -99,7 +99,7 @@ paths: summary: Get current user info tags: - Authentication - /api/v1/auth/refresh: + /auth/refresh: post: consumes: - application/json @@ -135,7 +135,7 @@ paths: summary: Refresh JWT token tags: - Authentication - /api/v1/auth/register: + /auth/register: post: consumes: - application/json @@ -167,7 +167,7 @@ paths: summary: Register new user tags: - Authentication - /api/v1/token/generate: + /token/generate: post: consumes: - application/json @@ -201,7 +201,7 @@ paths: summary: Generate JWT token tags: - Token - /api/v1/token/generate-direct: + /token/generate-direct: post: consumes: - application/json @@ -232,7 +232,7 @@ paths: summary: Generate token directly tags: - Token - /api/v1/ws/broadcast/check: + /ws/broadcast/check: post: consumes: - application/json @@ -267,7 +267,7 @@ paths: summary: Broadcast a WebSocket message tags: - WebSocket QRIS - /api/v1/ws/broadcast/qris: + /ws/broadcast/qris: post: consumes: - application/json diff --git a/internal/handlers/auth/auth.go b/internal/handlers/auth/auth.go index 3bd74dd..1efb091 100644 --- a/internal/handlers/auth/auth.go +++ b/internal/handlers/auth/auth.go @@ -30,7 +30,7 @@ func NewAuthHandler(authService *services.AuthService) *AuthHandler { // @Success 200 {object} models.TokenResponse // @Failure 400 {object} map[string]string "Bad request" // @Failure 401 {object} map[string]string "Unauthorized" -// @Router /api/v1/auth/login [post] +// @Router /auth/login [post] func (h *AuthHandler) Login(c *gin.Context) { var loginReq models.LoginRequest @@ -60,7 +60,7 @@ func (h *AuthHandler) Login(c *gin.Context) { // @Success 200 {object} models.TokenResponse // @Failure 400 {object} map[string]string "Bad request" // @Failure 401 {object} map[string]string "Unauthorized" -// @Router /api/v1/auth/refresh [post] +// @Router /auth/refresh [post] func (h *AuthHandler) RefreshToken(c *gin.Context) { // For now, this is a placeholder for refresh token functionality // In a real implementation, you would handle refresh tokens here @@ -76,7 +76,7 @@ func (h *AuthHandler) RefreshToken(c *gin.Context) { // @Param register body map[string]string true "Registration data" // @Success 201 {object} map[string]string // @Failure 400 {object} map[string]string "Bad request" -// @Router /api/v1/auth/register [post] +// @Router /auth/register [post] func (h *AuthHandler) Register(c *gin.Context) { var registerReq struct { Username string `json:"username" binding:"required"` @@ -113,7 +113,7 @@ func (h *AuthHandler) Register(c *gin.Context) { // @Security Bearer // @Success 200 {object} models.User // @Failure 401 {object} map[string]string "Unauthorized" -// @Router /api/v1/auth/me [get] +// @Router /auth/me [get] func (h *AuthHandler) Me(c *gin.Context) { // Get user info from context (set by middleware) userID, exists := c.Get("user_id") diff --git a/internal/handlers/auth/token.go b/internal/handlers/auth/token.go index 02383c7..f6dc8c0 100644 --- a/internal/handlers/auth/token.go +++ b/internal/handlers/auth/token.go @@ -30,7 +30,7 @@ func NewTokenHandler(authService *services.AuthService) *TokenHandler { // @Success 200 {object} models.TokenResponse // @Failure 400 {object} map[string]string "Bad request" // @Failure 401 {object} map[string]string "Unauthorized" -// @Router /api/v1/token/generate [post] +// @Router /token/generate [post] func (h *TokenHandler) GenerateToken(c *gin.Context) { var loginReq models.LoginRequest @@ -59,7 +59,7 @@ func (h *TokenHandler) GenerateToken(c *gin.Context) { // @Param user body map[string]string true "User info" // @Success 200 {object} models.TokenResponse // @Failure 400 {object} map[string]string "Bad request" -// @Router /api/v1/token/generate-direct [post] +// @Router /token/generate-direct [post] func (h *TokenHandler) GenerateTokenDirect(c *gin.Context) { var req struct { Username string `json:"username" binding:"required"` diff --git a/internal/services/websocket/broadcaster.go b/internal/services/websocket/broadcaster.go index 820e2d6..c7be883 100644 --- a/internal/services/websocket/broadcaster.go +++ b/internal/services/websocket/broadcaster.go @@ -119,7 +119,7 @@ func (b *Broadcaster) BroadcastMessage(messageType string, data interface{}) { // @Param data body interface{} true "QRIS data payload for the message" // @Success 200 {object} map[string]string "QRIS message successfully queued for broadcast" // @Failure 500 {object} map[string]string "Failed to queue QRIS message (queue full)" -// @Router /api/v1/ws/broadcast/qris [post] +// @Router /ws/broadcast/qris [post] func (b *Broadcaster) BroadcastQris(messageType string, data interface{}) { msg := NewWebSocketMessage(MessageType(messageType), data, "", "") @@ -150,7 +150,7 @@ func (b *Broadcaster) BroadcastQris(messageType string, data interface{}) { // @Param data body interface{} true "Data payload for the message" // @Success 200 {object} map[string]string "Message successfully queued for broadcast" // @Failure 500 {object} map[string]string "Failed to queue message (queue full)" -// @Router /api/v1/ws/broadcast/check [post] +// @Router /ws/broadcast/check [post] func (b *Broadcaster) BroadcastCheck(messageType string, data interface{}) { msg := NewWebSocketMessage(MessageType(messageType), data, "", "")