diff --git a/docs/docs.go b/docs/docs.go index e8f8d6b..42e8724 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -119,59 +119,7 @@ const docTemplate = `{ } } }, - "/auth/send-otp": { - "post": { - "description": "Send OTP code to the provided phone number", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "auth" - ], - "summary": "Send OTP code", - "parameters": [ - { - "description": "OTP Request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dto.OTPProviderReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dto.OTPProviderResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - } - } - }, - "/auth/verify-kyc": { + "/auth/kyc": { "post": { "description": "Verify user KYC with national ID and birth date", "consumes": [ @@ -223,7 +171,7 @@ const docTemplate = `{ } } }, - "/auth/verify-otp": { + "/auth/otp": { "post": { "description": "Verify the provided OTP code for the phone number", "consumes": [ diff --git a/docs/swagger.json b/docs/swagger.json index b629186..4bc4404 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -108,59 +108,7 @@ } } }, - "/auth/send-otp": { - "post": { - "description": "Send OTP code to the provided phone number", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "auth" - ], - "summary": "Send OTP code", - "parameters": [ - { - "description": "OTP Request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dto.OTPProviderReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/dto.OTPProviderResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - } - } - }, - "/auth/verify-kyc": { + "/auth/kyc": { "post": { "description": "Verify user KYC with national ID and birth date", "consumes": [ @@ -212,7 +160,7 @@ } } }, - "/auth/verify-otp": { + "/auth/otp": { "post": { "description": "Verify the provided OTP code for the phone number", "consumes": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 7be45f2..c270d37 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -148,41 +148,7 @@ paths: summary: Generate authentication challenge tags: - auth - /auth/send-otp: - post: - consumes: - - application/json - description: Send OTP code to the provided phone number - parameters: - - description: OTP Request - in: body - name: request - required: true - schema: - $ref: '#/definitions/dto.OTPProviderReq' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/dto.OTPProviderResponse' - "400": - description: Bad Request - schema: - additionalProperties: - type: string - type: object - "500": - description: Internal Server Error - schema: - additionalProperties: - type: string - type: object - summary: Send OTP code - tags: - - auth - /auth/verify-kyc: + /auth/kyc: post: consumes: - application/json @@ -216,7 +182,7 @@ paths: summary: Verify user KYC tags: - auth - /auth/verify-otp: + /auth/otp: post: consumes: - application/json diff --git a/internal/api/http/handlers/auth_handler.go b/internal/api/http/handlers/auth_handler.go index 056eb2f..48163f0 100644 --- a/internal/api/http/handlers/auth_handler.go +++ b/internal/api/http/handlers/auth_handler.go @@ -101,7 +101,7 @@ func (h *AuthHandler) Authenticate(c *fiber.Ctx) error { // @Success 200 {object} dto.OTPProviderResponse // @Failure 400 {object} map[string]string // @Failure 500 {object} map[string]string -// @Router /auth/send-otp [post] +// @Router /auth/otp [post] func (h *AuthHandler) SendOTP(c *fiber.Ctx) error { var req dto.OTPProviderReq if err := c.BodyParser(&req); err != nil { @@ -132,7 +132,7 @@ func (h *AuthHandler) SendOTP(c *fiber.Ctx) error { // @Success 200 {object} dto.OTPVerifyResponse // @Failure 400 {object} map[string]string // @Failure 401 {object} map[string]string -// @Router /auth/verify-otp [post] +// @Router /auth/otp [post] func (h *AuthHandler) VerifyOTP(c *fiber.Ctx) error { var req dto.OTPVerifyRequest if err := c.BodyParser(&req); err != nil { @@ -163,7 +163,7 @@ func (h *AuthHandler) VerifyOTP(c *fiber.Ctx) error { // @Success 200 {object} dto.KYCVerifyResponse // @Failure 400 {object} map[string]string // @Failure 500 {object} map[string]string -// @Router /auth/verify-kyc [post] +// @Router /auth/kyc [post] func (h *AuthHandler) VerifyKYC(c *fiber.Ctx) error { var req dto.KYCVerifyRequest if err := c.BodyParser(&req); err != nil { diff --git a/internal/api/http/setup.go b/internal/api/http/setup.go index 4c05f47..5c404cd 100644 --- a/internal/api/http/setup.go +++ b/internal/api/http/setup.go @@ -11,12 +11,15 @@ import ( "github.com/gofiber/adaptor/v2" "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/cors" httpSwagger "github.com/swaggo/http-swagger" ) func Run(cfg config.Server, app *app.AppContainer) { fiberApp := fiber.New() + fiberApp.Use(cors.New()) + // Serve static files (HTML, CSS, JS) fiberApp.Static("/", "./static") @@ -47,8 +50,8 @@ func registerPublicRoutes(router fiber.Router, app *app.AppContainer) { // Register auth routes authgroup.Post("/challenge", authHandler.GenerateChallenge) authgroup.Post("/authenticate", authHandler.Authenticate) - authgroup.Post("/send-otp", authHandler.SendOTP) - authgroup.Post("/verify-otp", authHandler.VerifyOTP) + authgroup.Post("/otp", authHandler.SendOTP) + authgroup.Post("/verify", authHandler.VerifyOTP) // add JWT middleware for KYC - authgroup.Post("/verify-kyc", authHandler.VerifyKYC) + authgroup.Post("/kyc", authHandler.VerifyKYC) }