Spaces:
Runtime error
Runtime error
Commit ·
131eba4
1
Parent(s): 751ca1b
Deploy files from GitHub repository
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .env.exampleAdded+9
- .github/workflows/main_huggingface.ymlAdded+52
- .gitignoreAdded+6
- DockerfileAdded+29
- LICENSEAdded+201
- README.md+10-10
- config/config.goAdded+34
- config/database_connection_config.goAdded+61
- controller/auth/auth_change_password_controller.goAdded+21
- controller/auth/auth_login_controller.goAdded+20
- controller/auth/auth_register_controller.goAdded+20
- controller/controller.goAdded+65
- controller/home_controller.goAdded+9
- controller/user/user_delete_controller.goAdded+22
- controller/user/user_list_controller.goAdded+19
- controller/user/user_profile_controller.goAdded+21
- controller/user/user_update_profile_controller.goAdded+25
- go.modAdded+67
- go.sumAdded+168
- main.goAdded+14
- middleware/authentication_middleware.goAdded+65
- middleware/middleware.goAdded+31
- middleware/response_middleware.goAdded+45
- models/authentication_payload_model.goAdded+8
- models/custom_claim.goAdded+9
- models/database_orm_model.goAdded+35
- models/exception_model.goAdded+12
- models/model.goAdded+1
- models/request_model.goAdded+42
- models/response_model.goAdded+25
- repositories/account_repository.goAdded+97
- repositories/repository.goAdded+117
- router/auth_route.goAdded+15
- router/router.goAdded+21
- router/user_route.goAdded+17
- services/authentication_service.goAdded+72
- services/jwt_service.goAdded+81
- services/register_service.goAdded+46
- services/service.goAdded+42
- services/user_list_service.goAdded+43
- services/user_profile_service.goAdded+97
- space/.gitattributesAdded+35
- space/README.mdAdded+10
- utils/Logger.goAdded+28
- utils/api_response.goAdded+53
- utils/helper.goAdded+11
- utils/util.goAdded+9
- views/index.htmlAdded+61
- views/login.htmlAdded+77
- views/profile.htmlAdded+108
123456789DB_HOST =DB_USER =DB_PASSWORD =DB_PORT =DB_NAME =SALT =HOST_ADDRESS = HOST_PORT = LOG_PATH = logs12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152name: Deploy to Huggingface
on: push: branches: - main
jobs: deploy-to-huggingface: runs-on: ubuntu-latest
steps: # Checkout repository - name: Checkout Repository uses: actions/checkout@v3
# Setup Git - name: Setup Git for Huggingface run: | git config --global user.email "abdan.hafidz@gmail.com" git config --global user.name "abdanhafidz"
# Clone Huggingface Space Repository - name: Clone Huggingface Space env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git clone https://huggingface.co/spaces/lifedebugger/pweb-api-ets space
# Update Git Remote URL and Pull Latest Changes - name: Update Remote and Pull Changes env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | cd space git remote set-url origin https://lifedebugger:$HF_TOKEN@huggingface.co/spaces/lifedebugger/pweb-api-ets git pull origin main || echo "No changes to pull"
# Copy Files to Huggingface Space - name: Copy Files to Space run: | rsync -av --exclude='.git' ./ space/
# Commit and Push to Huggingface Space - name: Commit and Push to Huggingface env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | cd space git add . git commit -m "Deploy files from GitHub repository" || echo "No changes to commit" git push origin main || echo "No changes to push"123456.env
vendor/
quzuu-be.exe
.qodo
.error
logs/1234567891011121314151617181920212223242526272829# Gunakan image dasar Golang versi 1.21.6FROM golang:1.24.1 AS builder
# Set working directoryWORKDIR /app
# Copy go.mod dan go.sumCOPY go.mod go.sum ./
# Download dependenciesRUN go mod download
# Copy seluruh kodeCOPY . .# Buat file .env dengan variabel environment yang dibutuhkanRUN echo "DB_HOST=aws-0-ap-southeast-1.pooler.supabase.com" >> .env && \ echo "DB_USER=postgres.ykxexvvsqhgsonpzmivq" >> .env && \ echo "DB_PASSWORD=Pweb@558585" >> .env && \ echo "DB_PORT=5432" >> .env && \ echo "DB_NAME=postgres" >> .env && \ echo "HOST_ADDRESS = 0.0.0.0" >> .env && \ echo "HOST_PORT = 7860" >> .env && \ echo "SALT=OkeGASOKEGASTAMBAHDUASORANGG45" >> .env
# Build aplikasiRUN go build -o main .
# Jalankan aplikasiCMD ["./main"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright 2025 Abdan Hafidz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.12345678910---title: Pweb Api Etsemoji: 🐢colorFrom: greencolorTo: greensdk: dockerpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910---title: Pweb Apiemoji: 📉colorFrom: greencolorTo: pinksdk: dockerpinned: false---
12345678910111213141516171819202122232425262728293031323334package config
import (
"os"
"strconv"
"github.com/joho/godotenv"
)
var TCP_ADDRESS string
var LOG_PATH string
var HOST_ADDRESS string
var HOST_PORT string
var EMAIL_VERIFICATION_DURATION int
var SMTP_SENDER_EMAIL string
var SMTP_SENDER_PASSWORD string
var SMTP_HOST string
var SMTP_PORT string
func init() {
godotenv.Load()
HOST_ADDRESS = os.Getenv("HOST_ADDRESS")
HOST_PORT = os.Getenv("HOST_PORT")
TCP_ADDRESS = HOST_ADDRESS + ":" + HOST_PORT
LOG_PATH = os.Getenv("LOG_PATH")
EMAIL_VERIFICATION_DURATION, _ = strconv.Atoi(os.Getenv("EMAIL_VERIFICATION_DURATION"))
SMTP_SENDER_EMAIL = os.Getenv("SMTP_SENDER_EMAIL")
SMTP_SENDER_PASSWORD = os.Getenv("SMTP_SENDER_PASSWORD")
SMTP_HOST = os.Getenv("SMTP_HOST")
SMTP_PORT = os.Getenv("SMTP_PORT")
// Menampilkan nilai variabel lingkungan
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061package config
import (
"fmt"
"log"
"os"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"github.com/joho/godotenv"
"pweb-api.abdanhafidz.com/models"
)
var DB *gorm.DB
var err error
var Salt string
func init() {
godotenv.Load()
if err != nil {
fmt.Println("Gagal membaca file .env")
return
}
os.Setenv("TZ", "Asia/Jakarta")
dbHost := os.Getenv("DB_HOST")
dbPort := os.Getenv("DB_PORT")
dbUser := os.Getenv("DB_USER")
dbPassword := os.Getenv("DB_PASSWORD")
dbName := os.Getenv("DB_NAME")
Salt := os.Getenv("SALT")
dsn := "host=" + dbHost + " user=" + dbUser + " password=" + dbPassword + " dbname=" + dbName + " port=" + dbPort + " sslmode=disable TimeZone=Asia/Jakarta"
DB, err = gorm.Open(postgres.Open(dsn), &gorm.Config{TranslateError: true})
if err != nil {
panic(err)
}
if Salt == "" {
Salt = "D3f4u|t"
}
// Call AutoMigrateAll to perform auto-migration
AutoMigrateAll(DB)
}
func AutoMigrateAll(db *gorm.DB) {
// Enable logger to see SQL logs
db.Logger.LogMode(logger.Info)
// Auto-migrate all models
err := db.AutoMigrate(
&models.Account{},
&models.AccountDetails{},
)
if err != nil {
log.Fatal(err)
}
fmt.Println("Migration completed successfully.")
}123456789101112131415161718192021package auth
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/controller"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
)
func ChangePassword(c *gin.Context) {
authentication := services.AuthenticationService{}
changePasswordController := controller.Controller[models.ChangePasswordRequest, models.Account, models.AuthenticatedUser]{
Service: &authentication.Service,
}
changePasswordController.HeaderParse(c, func() {
changePasswordController.Service.Constructor.Id = uint(changePasswordController.AccountData.UserID)
})
changePasswordController.RequestJSON(c, func() {
authentication.Update(changePasswordController.Request.OldPassword, changePasswordController.Request.NewPassword)
})
}1234567891011121314151617181920package auth
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/controller"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
)
func Login(c *gin.Context) {
authentication := services.AuthenticationService{}
loginController := controller.Controller[models.LoginRequest, models.Account, models.AuthenticatedUser]{
Service: &authentication.Service,
}
loginController.RequestJSON(c, func() {
loginController.Service.Constructor.Email = loginController.Request.Email
loginController.Service.Constructor.Password = loginController.Request.Password
authentication.Authenticate()
})
}1234567891011121314151617181920package auth
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/controller"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
)
func Register(c *gin.Context) {
register := services.RegisterService{}
registerController := controller.Controller[models.RegisterRequest, models.Account, models.Account]{
Service: ®ister.Service,
}
registerController.RequestJSON(c, func() {
registerController.Service.Constructor.Password = registerController.Request.Password
registerController.Service.Constructor.Email = registerController.Request.Email
register.Create()
})
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465package controller
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
"pweb-api.abdanhafidz.com/utils"
)
type (
Controllers interface {
RequestJSON(c *gin.Context)
Response(c *gin.Context)
}
Controller[T1 any, T2 any, T3 any] struct {
AccountData models.AccountData
Request T1
Service *services.Service[T2, T3]
}
)
func (controller *Controller[T1, T2, T3]) HeaderParse(c *gin.Context, act func()) {
cParam, _ := c.Get("accountData")
if cParam != nil {
controller.AccountData = cParam.(models.AccountData)
}
act()
}
func (controller *Controller[T1, T2, T3]) RequestJSON(c *gin.Context, act func()) {
cParam, _ := c.Get("accountData")
if cParam != nil {
controller.AccountData = cParam.(models.AccountData)
}
errBinding := c.ShouldBindJSON(&controller.Request)
if errBinding != nil {
utils.ResponseFAIL(c, 400, models.Exception{
BadRequest: true,
Message: "Invalid Request!, recheck your request, there's must be some problem about required parameter or type parameter",
})
return
} else {
act()
controller.Response(c)
}
}
func (controller *Controller[T1, T2, T3]) Response(c *gin.Context) {
switch {
case controller.Service.Error != nil:
utils.LogError(controller.Service.Error)
utils.ResponseFAIL(c, 500, models.Exception{
InternalServerError: true,
Message: "Internal Server Error",
})
case controller.Service.Exception.DataDuplicate:
utils.ResponseFAIL(c, 400, controller.Service.Exception)
case controller.Service.Exception.Unauthorized:
utils.ResponseFAIL(c, 401, controller.Service.Exception)
case controller.Service.Exception.DataNotFound:
utils.ResponseFAIL(c, 404, controller.Service.Exception)
case controller.Service.Exception.Message != "":
utils.ResponseFAIL(c, 400, controller.Service.Exception)
default:
utils.ResponseOK(c, controller.Service.Result)
}
}123456789package controller
import "github.com/gin-gonic/gin"
func HomeController(c *gin.Context) {
c.JSON(200, gin.H{
"message": "PWEB API 2025 by Abdan Hafidz!",
})
}12345678910111213141516171819202122package user
import (
"strconv"
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/controller"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
)
func Delete(c *gin.Context) {
userList := services.UserListService{}
userListController := controller.Controller[any, models.Account, []models.UserProfileResponse]{
Service: &userList.Service,
}
userListController.HeaderParse(c, func() {
id_user, _ := strconv.Atoi(c.Param("id_user"))
userListController.Service.Constructor.Id = uint(id_user)
userList.Delete()
})
}12345678910111213141516171819package user
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/controller"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
)
func List(c *gin.Context) {
userList := services.UserListService{}
userListController := controller.Controller[any, models.Account, []models.UserProfileResponse]{
Service: &userList.Service,
}
userListController.HeaderParse(c, func() {
userList.Retrieve()
userListController.Response(c)
})
}123456789101112131415161718192021package user
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/controller"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
)
func Profile(c *gin.Context) {
userProfile := services.UserProfileService{}
userProfileController := controller.Controller[any, models.AccountDetails, models.UserProfileResponse]{
Service: &userProfile.Service,
}
userProfileController.HeaderParse(c, func() {
userProfileController.Service.Constructor.AccountId = uint(userProfileController.AccountData.UserID)
userProfile.Retrieve()
userProfileController.Response(c)
},
)
}12345678910111213141516171819202122232425package user
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/controller"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
)
func UpdateProfile(c *gin.Context) {
userProfile := services.UserProfileService{}
userUpdateProfileController := controller.Controller[models.AccountDetails, models.AccountDetails, models.UserProfileResponse]{
Service: &userProfile.Service,
}
userUpdateProfileController.RequestJSON(c, func() {
userUpdateProfileController.Service.Constructor = userUpdateProfileController.Request
userUpdateProfileController.HeaderParse(c, func() {
userUpdateProfileController.Service.Constructor.AccountId = uint(userUpdateProfileController.AccountData.UserID)
})
userProfile.Update()
},
)
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667module pweb-api.abdanhafidz.com
go 1.24.0
require ( github.com/gin-gonic/gin v1.10.0 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/gosimple/slug v1.15.0 github.com/joho/godotenv v1.5.1 github.com/satori/go.uuid v1.2.0 golang.org/x/crypto v0.36.0 google.golang.org/api v0.228.0 gorm.io/driver/postgres v1.5.11 gorm.io/gorm v1.25.12)
require ( cloud.google.com/go/auth v0.15.0 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect cloud.google.com/go/compute/metadata v0.6.0 // indirect github.com/bytedance/sonic v1.13.1 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect github.com/cloudwego/base64x v0.1.5 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/gin-contrib/sse v1.0.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.25.0 // indirect github.com/goccy/go-json v0.10.5 // indirect github.com/google/s2a-go v0.1.9 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect github.com/googleapis/gax-go/v2 v2.14.1 // indirect github.com/gosimple/unidecode v1.0.1 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/pgx/v5 v5.7.2 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect go.opentelemetry.io/otel v1.34.0 // indirect go.opentelemetry.io/otel/metric v1.34.0 // indirect go.opentelemetry.io/otel/trace v1.34.0 // indirect golang.org/x/arch v0.15.0 // indirect golang.org/x/net v0.37.0 // indirect golang.org/x/oauth2 v0.28.0 // indirect golang.org/x/sync v0.12.0 // indirect golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 // indirect google.golang.org/grpc v1.71.0 // indirect google.golang.org/protobuf v1.36.6 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168cloud.google.com/go/auth v0.15.0 h1:Ly0u4aA5vG/fsSsxu98qCQBemXtAtJf+95z9HK+cxps=cloud.google.com/go/auth v0.15.0/go.mod h1:WJDGqZ1o9E9wKIL+IwStfyn/+s59zl4Bi+1KQNVXLZ8=cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc=cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c=cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I=cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=github.com/bytedance/sonic v1.13.1 h1:Jyd5CIvdFnkOWuKXr+wm4Nyk2h0yAFsr8ucJgEasO3g=github.com/bytedance/sonic v1.13.1/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4=github.com/googleapis/enterprise-certificate-proxy v0.3.6/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA=github.com/googleapis/gax-go/v2 v2.14.1 h1:hb0FFeiPaQskmvakKu5EbCbpntQn48jyHuvrkurSS/Q=github.com/googleapis/gax-go/v2 v2.14.1/go.mod h1:Hb/NubMaVM88SrNkvl8X/o8XWwDJEPqouaLeN2IUxoA=github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo=github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc=github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI=github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 h1:rgMkmiGfix9vFJDcDi1PK8WEQP4FLQwLDfhp5ZLpFeE=go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0/go.mod h1:ijPqXp5P6IRRByFVVg9DY8P5HkxkHE5ARIa+86aXPf4=go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 h1:CV7UdSGJt/Ao6Gp4CXckLxVRRsRgDHoI8XjbL3PDl8s=go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0/go.mod h1:FRmFuRJfag1IZ2dPkHnEoSFVgTVPUd2qf5Vi69hLb8I=go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=google.golang.org/api v0.228.0 h1:X2DJ/uoWGnY5obVjewbp8icSL5U4FzuCfy9OjbLSnLs=google.golang.org/api v0.228.0/go.mod h1:wNvRS1Pbe8r4+IfBIniV8fwCpGwTrYa+kMUDiC5z5a4=google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 h1:iK2jbkWL86DXjEx0qiHcRE9dE4/Ahua5k6V8OWFb//c=google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314=gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=1234567891011121314package main
import (
"fmt"
"pweb-api.abdanhafidz.com/config"
"pweb-api.abdanhafidz.com/router"
)
func main() {
fmt.Println("Server started on ", config.TCP_ADDRESS, ", port :", config.HOST_PORT)
router.StartService()
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465// auth/auth.go
package middleware
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
"pweb-api.abdanhafidz.com/utils"
)
func AuthUser(c *gin.Context) {
var currAccData models.AccountData
if c.Request.Header["Authorization"] != nil {
token := c.Request.Header["Authorization"]
_, currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = services.VerifyToken(token[0])
if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {
currAccData.UserID = 0
utils.ResponseFAIL(c, 401, models.Exception{Unauthorized: true, Message: "Your session is expired, Please re-Login!"})
c.Abort()
return
} else {
c.Set("accountData", currAccData)
c.Next()
}
} else {
currAccData.UserID = 0
currAccData.VerifyStatus = "no-token"
currAccData.ErrVerif = nil
utils.ResponseFAIL(c, 401, models.Exception{Unauthorized: true, Message: "You have to login first!"})
c.Abort()
return
}
}
func AuthAdmin(c *gin.Context) {
var currAccData models.AccountData
if c.Request.Header["Authorization"] != nil {
token := c.Request.Header["Authorization"]
currAccData.Role, currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = services.VerifyToken(token[0])
if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {
currAccData.UserID = 0
utils.ResponseFAIL(c, 401, models.Exception{Unauthorized: true, Message: "Your session is expired, Please re-Login!"})
c.Abort()
return
} else {
c.Set("accountData", currAccData)
c.Next()
}
} else {
currAccData.UserID = 0
currAccData.VerifyStatus = "no-token"
currAccData.ErrVerif = nil
utils.ResponseFAIL(c, 401, models.Exception{Unauthorized: true, Message: "You have to login first!"})
c.Abort()
return
}
}12345678910111213141516171819202122232425262728293031package middleware
import (
"math"
"time"
"gorm.io/gorm"
)
func RecordCheck(rows *gorm.DB) (string, error) {
count := rows.RowsAffected
err := rows.Error
// fmt.Println(rows)
// fmt.Println(count)
if count == 0 {
return "no-record", err
} else if err != nil {
return "query-error", err
} else {
return "ok", err
}
}
func DiffTime(t1 time.Time, t2 time.Time) (int, int, int) {
hs := t1.Sub(t2).Hours()
hs, mf := math.Modf(hs)
ms := mf * 60
ms, sf := math.Modf(ms)
ss := sf * 60
return int(hs), int(ms), int(ss)
}123456789101112131415161718192021222324252627282930313233343536373839404142434445package middleware
import (
"net/http"
"github.com/gin-gonic/gin"
)
// SendJSON200 sends a JSON response with HTTP status code 200
func SendJSON200(c *gin.Context, data interface{}) {
c.JSON(http.StatusOK, gin.H{"status": "success", "data": data})
return
}
// SendJSON400 sends a JSON response with HTTP status code 400
func SendJSON400(c *gin.Context, error_status *string, message *string) {
c.JSON(http.StatusBadRequest, gin.H{"status": "error", "error-status": error_status, "message": message})
return
}
// SendJSON401 sends a JSON response with HTTP status code 401
func SendJSON401(c *gin.Context, error_status *string, message *string) {
c.JSON(http.StatusUnauthorized, gin.H{"status": "error", "error-status": error_status, "message": message})
return
}
// SendJSON403 sends a JSON response with HTTP status code 403
func SendJSON403(c *gin.Context, message *string) {
c.JSON(http.StatusForbidden, gin.H{"status": "error", "message": message})
return
}
// SendJSON404 sends a JSON response with HTTP status code 404
func SendJSON404(c *gin.Context, message *string) {
c.JSON(http.StatusNotFound, gin.H{"status": "error", "message": message})
return
}
// SendJSON500 sends a JSON response with HTTP status code 500
func SendJSON500(c *gin.Context, error_status *string, message *string) {
c.JSON(http.StatusInternalServerError, gin.H{"status": "error", "error-status": error_status, "message": message})
return
}
// JSONResponseMiddleware is a middleware that provides functions for sending JSON responses12345678package models
type AccountData struct {
UserID uint
VerifyStatus string
Role string
ErrVerif error
}123456789package models
import "github.com/golang-jwt/jwt/v5"
type CustomClaims struct { jwt.RegisteredClaims UserID uint `json:"id"` Role string `json:"role"`}1234567891011121314151617181920212223242526272829303132333435package models
import (
"time"
uuid "github.com/satori/go.uuid"
)
type Account struct {
Id uint `gorm:"primaryKey" json:"id"`
UUID uuid.UUID `gorm:"type:uuid" json:"uuid" `
Email string `gorm:"uniqueIndex" json:"email"`
Password string `json:"password"`
Role string `json:"role"`
IsDetailCompleted bool `json:"is_detail_completed"`
CreatedAt time.Time `json:"created_at"`
DeletedAt *time.Time `json:"deleted_at" gorm:"default:null"`
}
type AccountDetails struct {
ID uint `gorm:"primaryKey" json:"id"`
AccountId uint `json:"account_id"`
InitialName string `json:"initial_name"`
FullName *string `json:"full_name"`
Address *string `json:"address"`
Gender bool `json:"gender"`
University *string `json:"university"`
DateOfBirth *time.Time `json:"date_of_birth"`
PlaceOfBirth *string `json:"place_of_birth"`
PhoneNumber *string `json:"phone_number"`
}
// Gorm table name settings
func (Account) TableName() string { return "account" }
func (AccountDetails) TableName() string { return "account_details" }123456789101112package models
type Exception struct {
Unauthorized bool `json:"unauthorized,omitempty"`
BadRequest bool `json:"bad_request,omitempty"`
DataNotFound bool `json:"data_not_found,omitempty"`
InternalServerError bool `json:"internal_server_error,omitempty"`
DataDuplicate bool `json:"data_duplicate,omitempty"`
QueryError bool `json:"query_error,omitempty"`
InvalidPasswordLength bool `json:"invalid_password_length,omitempty"`
Message string `json:"message,omitempty"`
}1package models123456789101112131415161718192021222324252627282930313233343536373839404142package models
type LoginRequest struct {
Email string `json:"email" binding:"required"`
Password string `json:"password" binding:"required"`
}
type RegisterRequest struct {
Name string `json:"name"`
Email string `json:"email" binding:"required,email"`
Phone int `json:"phone"`
Password string `json:"password" binding:"required"`
}
type ChangePasswordRequest struct {
OldPassword string `json:"old_password" binding:"required" `
NewPassword string `json:"new_password" binding:"required" `
}
type CreateVerifyEmailRequest struct {
Token uint `json:"token" binding:"required"`
}
type OptionsRequest struct {
OptionName string `json:"option_name" binding:"required"`
OptionValue []string `json:"option_values" binding:"required"`
}
type ExternalAuthRequest struct {
OauthID string `json:"oauth_id" binding:"required"`
OauthProvider string `json:"oauth_provider" binding:"required"`
IsAgreeTerms bool `json:"is_agree_terms"`
IsSexualDisease bool `json:"is_sexual_disease"`
}
type ForgotPasswordRequest struct {
Email string `json:"email" binding:"required,email"`
}
type ValidateForgotPasswordRequest struct {
Token uint `json:"token" binding:"required"`
NewPassword string `json:"new_password"`
}12345678910111213141516171819202122232425package models
type SuccessResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data any `json:"data"`
MetaData any `json:"meta_data"`
}
type ErrorResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Errors Exception `json:"errors"`
MetaData any `json:"meta_data"`
}
type AuthenticatedUser struct {
Account Account `json:"account"`
Token string `json:"token"`
}
type UserProfileResponse struct {
Account Account `json:"account"`
Details AccountDetails `json:"details"`
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697package repositories
import (
"pweb-api.abdanhafidz.com/models"
)
func GetAccountbyEmail(email string) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
models.Account{Email: email},
)
repo.Transactions(
WhereGivenConstructor[models.Account, models.Account],
Find[models.Account, models.Account],
)
return *repo
}
func GetAllAccount() Repository[models.Account, []models.Account] {
repo := Construct[models.Account, []models.Account](
models.Account{},
)
repo.Transactions(
Find[models.Account, []models.Account],
)
return *repo
}
func GetAccountById(AccountId uint) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
models.Account{Id: AccountId},
)
repo.Transactions(
WhereGivenConstructor[models.Account, models.Account],
Find[models.Account, models.Account],
)
return *repo
}
func UpdateAccount(account models.Account) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
account,
)
repo.Transaction.Save(&repo.Constructor)
repo.Result = repo.Constructor
return *repo
}
func GetDetailAccountById(AccountId uint) Repository[models.AccountDetails, models.AccountDetails] {
repo := Construct[models.AccountDetails, models.AccountDetails](
models.AccountDetails{AccountId: AccountId},
)
// fmt.Println("Account ID:", repo.Constructor.AccountId)
repo.Transactions(
WhereGivenConstructor[models.AccountDetails, models.AccountDetails],
Find[models.AccountDetails, models.AccountDetails],
)
return *repo
}
func CreateAccount(account models.Account) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
account,
)
Create(repo)
return *repo
}
func CreateAccountDetails(accountDetails models.AccountDetails) Repository[models.AccountDetails, models.AccountDetails] {
repo := Construct[models.AccountDetails, models.AccountDetails](
accountDetails,
)
Create(repo)
return *repo
}
func UpdateAccountDetails(accountDetails models.AccountDetails) Repository[models.AccountDetails, models.AccountDetails] {
repo := Construct[models.AccountDetails, models.AccountDetails](
models.AccountDetails{AccountId: accountDetails.AccountId},
)
repo.Transaction.Where("account_id = ?", accountDetails.AccountId).First(&repo.Constructor)
accountDetails.ID = repo.Constructor.ID
// fmt.Println(repo.Constructor)
// fmt.Println(accountDetails)
repo.Transaction.Updates(accountDetails)
repo.Result = accountDetails
return *repo
}
func DeleteAccountbyId(accountId uint) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
models.Account{Id: accountId},
)
repo.Transactions(
Delete[models.Account],
)
return *repo
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117package repositories
import (
"gorm.io/gorm"
"pweb-api.abdanhafidz.com/config"
)
type Repositories interface {
FindAllPaginate()
Where()
Find()
Create()
Update()
CustomQuery()
Delete()
}
type PaginationConstructor struct {
Limit int
Offset int
Filter string
}
type CustomQueryConstructor struct {
SQL string
Values interface{}
}
type Repository[TConstructor any, TResult any] struct {
Constructor TConstructor
Pagination PaginationConstructor
CustomQuery CustomQueryConstructor
Result TResult
Transaction *gorm.DB
RowsCount int
NoRecord bool
RowsError error
}
func Construct[TConstructor any, TResult any](constructor ...TConstructor) *Repository[TConstructor, TResult] {
if len(constructor) == 1 {
return &Repository[TConstructor, TResult]{
Constructor: constructor[0],
Transaction: config.DB,
}
}
return &Repository[TConstructor, TResult]{
Constructor: constructor[0],
Transaction: config.DB.Begin(),
}
}
func (repo *Repository[T1, T2]) Transactions(transactions ...func(*Repository[T1, T2]) *gorm.DB) {
for _, tx := range transactions {
repo.Transaction = tx(repo)
if repo.RowsError != nil {
return
}
}
}
func WhereGivenConstructor[T1 any, T2 any](repo *Repository[T1, T2]) *gorm.DB {
tx := repo.Transaction.Where(&repo.Constructor)
repo.RowsCount = int(tx.RowsAffected)
repo.NoRecord = repo.RowsCount == 0
repo.RowsError = tx.Error
return tx
}
func Find[T1 any, T2 any](repo *Repository[T1, T2]) *gorm.DB {
tx := repo.Transaction.Find(&repo.Result)
repo.RowsCount = int(tx.RowsAffected)
repo.NoRecord = repo.RowsCount == 0
repo.RowsError = tx.Error
return tx
}
func FinddAllPaginate[T1 any, T2 any](repo *Repository[T1, T2]) *gorm.DB {
tx := repo.Transaction.Limit(repo.Pagination.Limit).Offset(repo.Pagination.Offset).Find(&repo.Result)
repo.RowsCount = int(tx.RowsAffected)
repo.NoRecord = repo.RowsCount == 0
repo.RowsError = tx.Error
return tx
}
func Create[T1 any](repo *Repository[T1, T1]) *gorm.DB {
tx := repo.Transaction.Create(&repo.Constructor)
repo.RowsCount = int(tx.RowsAffected)
repo.NoRecord = repo.RowsCount == 0
repo.RowsError = tx.Error
repo.Result = repo.Constructor
return tx
}
func Update[T1 any](repo *Repository[T1, T1]) *gorm.DB {
tx := repo.Transaction.Updates(&repo.Constructor)
repo.RowsCount = int(tx.RowsAffected)
repo.NoRecord = repo.RowsCount == 0
repo.RowsError = tx.Error
repo.Result = repo.Constructor
return tx
}
func Delete[T1 any](repo *Repository[T1, T1]) *gorm.DB {
tx := repo.Transaction.Delete(&repo.Constructor)
repo.RowsCount = int(tx.RowsAffected)
repo.NoRecord = repo.RowsCount == 0
repo.RowsError = tx.Error
return tx
}
func CustomQuery[T1 any, T2 any](repo *Repository[T1, T2]) *gorm.DB {
tx := repo.Transaction.Raw(repo.CustomQuery.SQL, repo.CustomQuery.Values).Scan(&repo.Result)
repo.RowsCount = int(tx.RowsAffected)
repo.NoRecord = repo.RowsCount == 0
repo.RowsError = tx.Error
return tx
}123456789101112131415package router
import (
"github.com/gin-gonic/gin"
AuthController "pweb-api.abdanhafidz.com/controller/auth"
)
func AuthRoute(router *gin.Engine) {
routerGroup := router.Group("/api/v1/auth")
{
routerGroup.POST("/login", AuthController.Login)
routerGroup.POST("/register", AuthController.Register)
}
}123456789101112131415161718192021package router
import (
"log"
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/config"
"pweb-api.abdanhafidz.com/controller"
)
func StartService() {
router := gin.Default()
router.GET("/", controller.HomeController)
AuthRoute(router)
UserRoute(router)
err := router.Run(config.TCP_ADDRESS)
if err != nil {
log.Fatalf("Failed to run server: %v", err)
}
}1234567891011121314151617package router
import (
"github.com/gin-gonic/gin"
UserController "pweb-api.abdanhafidz.com/controller/user"
"pweb-api.abdanhafidz.com/middleware"
)
func UserRoute(router *gin.Engine) {
routerGroup := router.Group("/api/v1/user")
{
routerGroup.GET("/me", middleware.AuthUser, UserController.Profile)
routerGroup.GET("/list", middleware.AuthUser, UserController.List)
routerGroup.DELETE("/:id_user", middleware.AuthAdmin, UserController.Delete)
routerGroup.PUT("/me", middleware.AuthUser, UserController.UpdateProfile)
}
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172// meme
package services
import (
"errors"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/repositories"
)
type AuthenticationService struct {
Service[models.Account, models.AuthenticatedUser]
}
func (s *AuthenticationService) Authenticate() {
accountData := repositories.GetAccountbyEmail(s.Constructor.Email)
if accountData.NoRecord {
s.Exception.DataNotFound = true
s.Exception.Message = "there is no account with given credentials!"
return
}
if VerifyPassword(accountData.Result.Password, s.Constructor.Password) != nil {
s.Exception.Unauthorized = true
s.Exception.Message = "incorrect password!"
return
}
token, err_tok := GenerateToken(&accountData.Result)
if err_tok != nil {
s.Error = errors.Join(s.Error, err_tok)
return
}
accountData.Result.Password = "SECRET"
s.Result = models.AuthenticatedUser{
Account: accountData.Result,
Token: token,
}
s.Error = accountData.RowsError
}
func (s *AuthenticationService) Update(oldPassword string, newPassword string) {
if len(newPassword) < 8 {
s.Exception.InvalidPasswordLength = true
s.Exception.Message = "Password must have at least 8 characters!"
return
}
accountData := repositories.GetAccountById(s.Constructor.Id)
if accountData.NoRecord {
s.Exception.DataNotFound = true
s.Exception.Message = "there is no account with given credentials!"
return
}
if VerifyPassword(accountData.Result.Password, oldPassword) != nil {
s.Exception.Unauthorized = true
s.Exception.Message = "incorrect old password!"
return
}
hashed_password, _ := HashPassword(newPassword)
accountData.Result.Password = hashed_password
changePassword := repositories.UpdateAccount(accountData.Result)
changePassword.Result.Password = "SECRET"
s.Result = models.AuthenticatedUser{
Account: changePassword.Result,
}
s.Error = changePassword.RowsError
}
// LoginHandler handles user login123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081package services
import (
"errors"
"strings"
"time"
"github.com/golang-jwt/jwt/v5"
"golang.org/x/crypto/bcrypt"
"pweb-api.abdanhafidz.com/config"
"pweb-api.abdanhafidz.com/models"
)
var salt = config.Salt
var secretKey = []byte(salt)
func GenerateToken(user *models.Account) (string, error) {
claims := models.CustomClaims{
UserID: user.Id,
Role: user.Role,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour * 24)), // Token berlaku 24 jam
IssuedAt: jwt.NewNumericDate(time.Now()),
Issuer: "abdanhafidz.com",
},
}
// Buat token dengan metode signing
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
return token.SignedString(secretKey)
}
func ExtractBearerToken(authHeader string) (string, error) {
parts := strings.Split(authHeader, " ")
if len(parts) != 2 || parts[0] != "Bearer" {
return "", errors.New("invalid authorization header format")
}
return parts[1], nil
}
func VerifyToken(bearerToken string) (string, uint, string, error) {
// fmt.Println("bearerToken :", bearerToken)
tokenData, err := ExtractBearerToken(bearerToken)
if err != nil {
return "", 0, "invalid-token", err
} else {
// fmt.Println("Extracted Token:", tokenData)
}
token, err := jwt.ParseWithClaims(tokenData, &models.CustomClaims{}, func(token *jwt.Token) (interface{}, error) {
return secretKey, nil
})
if err != nil {
return "", 0, "invalid-token", err
}
// Extract the claims
claims, ok := token.Claims.(*models.CustomClaims)
if !ok || !token.Valid {
return "", 0, "invalid-token", err
}
if claims.ExpiresAt != nil && claims.ExpiresAt.Time.Before(time.Now()) {
return "", 0, "expired", err
}
return claims.Role, claims.UserID, "valid", err
}
func VerifyPassword(hashedPassword, password string) error {
err := bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password))
if err != nil {
return errors.New("invalid password")
}
return nil
}
func HashPassword(password string) (string, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
return string(bytes), err
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546package services
import (
"errors"
uuid "github.com/satori/go.uuid"
"gorm.io/gorm"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/repositories"
)
type RegisterService struct {
Service[models.Account, models.Account]
}
func (s *RegisterService) Create() {
if len(s.Constructor.Password) < 8 {
s.Exception.InvalidPasswordLength = true
s.Exception.Message = "Password must have at least 8 characters!"
return
}
hashed_password, err_hash := HashPassword(s.Constructor.Password)
s.Error = err_hash
s.Constructor.Password = hashed_password
s.Constructor.UUID = uuid.NewV4()
accountCreated := repositories.CreateAccount(s.Constructor)
if errors.Is(accountCreated.RowsError, gorm.ErrDuplicatedKey) {
s.Exception.DataDuplicate = true
s.Exception.Message = "Account with email " + s.Constructor.Email + " already exists!"
return
} else if errors.Is(accountCreated.RowsError, gorm.ErrModelAccessibleFieldsRequired) || errors.Is(accountCreated.RowsError, gorm.ErrInvalidData) || errors.Is(accountCreated.RowsError, gorm.ErrInvalidValue) || errors.Is(accountCreated.RowsError, gorm.ErrInvalidField) {
s.Exception.BadRequest = true
s.Exception.Message = "Bad request!"
return
}
userProfile := UserProfileService{}
userProfile.Constructor.AccountId = accountCreated.Result.Id
userProfile.Create()
if userProfile.Error != nil {
s.Error = userProfile.Error
return
}
s.Error = accountCreated.RowsError
s.Result = accountCreated.Result
s.Result.Password = "SECRET"
}123456789101112131415161718192021222324252627282930313233343536373839404142package services
import (
"time"
"pweb-api.abdanhafidz.com/models"
)
type (
Services interface {
Retrieve()
Update()
Create()
Delete()
Validate()
Authenticate()
Authorize()
}
IService interface {
Implements()
}
Service[TConstructor any, TResult any] struct {
Constructor TConstructor
Result TResult
Exception models.Exception
Error error
}
)
func Construct[TConstructor any, TResult any](constructor ...TConstructor) *Service[TConstructor, TResult] {
if len(constructor) == 1 {
return &Service[TConstructor, TResult]{}
}
return &Service[TConstructor, TResult]{
Constructor: constructor[0],
}
}
func CalculateDueTime(duration time.Duration) time.Time {
return time.Now().Add(duration)
}12345678910111213141516171819202122232425262728293031323334353637383940414243package services
import (
"errors"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/repositories"
)
type UserListService struct {
Service[models.Account, []models.UserProfileResponse]
}
func (s *UserListService) Retrieve() {
userListRepo := repositories.GetAllAccount()
s.Error = userListRepo.RowsError
for _, user := range userListRepo.Result {
if user.Role != "admin" {
userDetailsRepo := repositories.GetDetailAccountById(user.Id)
s.Error = errors.Join(userDetailsRepo.RowsError)
if s.Error != nil {
return
}
s.Result = append(s.Result, models.UserProfileResponse{
Account: user,
Details: userDetailsRepo.Result,
})
}
}
return
}
func (s *UserListService) Delete() {
deleteUserRepo := repositories.DeleteAccountbyId(s.Constructor.Id)
if deleteUserRepo.NoRecord {
s.Exception.DataNotFound = true
s.Exception.Message = "user not found"
return
}
s.Error = deleteUserRepo.RowsError
s.Retrieve()
return
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697package services
import (
"regexp"
"strings"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/repositories"
)
type UserProfileService struct {
Service[models.AccountDetails, models.UserProfileResponse]
}
// SanitizePhoneNumber membersihkan dan menormalkan nomor telepon ke format +62
func SanitizePhoneNumber(input string) string {
// Hilangkan semua spasi dan strip
input = strings.ReplaceAll(input, " ", "")
input = strings.ReplaceAll(input, "-", "")
input = strings.ReplaceAll(input, "(", "")
input = strings.ReplaceAll(input, ")", "")
// Hilangkan semua karakter non-digit kecuali +
re := regexp.MustCompile(`[^0-9\+]`)
input = re.ReplaceAllString(input, "")
// Handle nomor diawali 0 (contoh: 0812...) menjadi +62812...
if strings.HasPrefix(input, "0") {
input = "+62" + input[1:]
}
// Handle jika diawali dengan 62 tanpa + (contoh: 62812...)
if strings.HasPrefix(input, "62") && !strings.HasPrefix(input, "+62") {
input = "+" + input
}
// Handle jika tidak ada awalan +62 sama sekali (contoh: 8123456789)
if !strings.HasPrefix(input, "+62") {
if strings.HasPrefix(input, "8") {
input = "+62" + input
}
}
return input
}
func (s *UserProfileService) Create() {
userProfile := repositories.CreateAccountDetails(s.Constructor)
s.Error = userProfile.RowsError
if userProfile.NoRecord {
s.Exception.DataNotFound = true
s.Exception.Message = "There is no account with given credentials!"
return
}
s.Result = models.UserProfileResponse{
Account: repositories.GetAccountById(s.Constructor.AccountId).Result,
Details: userProfile.Result,
}
}
func (s *UserProfileService) Retrieve() {
userProfile := repositories.GetDetailAccountById(s.Constructor.AccountId)
s.Error = userProfile.RowsError
if userProfile.NoRecord {
s.Exception.DataNotFound = true
s.Exception.Message = "There is no account with given credentials!"
return
}
s.Result = models.UserProfileResponse{
Account: repositories.GetAccountById(s.Constructor.AccountId).Result,
Details: userProfile.Result,
}
s.Result.Account.Password = "SECRET"
}
func (s *UserProfileService) Update() {
if s.Constructor.PhoneNumber != nil {
phoneNumber := *s.Constructor.PhoneNumber
*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)
}
userProfile := repositories.UpdateAccountDetails(s.Constructor)
s.Error = userProfile.RowsError
if userProfile.NoRecord {
s.Exception.DataNotFound = true
s.Exception.Message = "There is no account with given credentials!"
return
}
account := repositories.GetAccountById(s.Constructor.AccountId)
account.Result.IsDetailCompleted = (userProfile.Result.InitialName != "" &&
userProfile.Result.FullName != nil &&
userProfile.Result.PhoneNumber != nil &&
userProfile.Result.University != nil)
repositories.UpdateAccount(account.Result)
s.Result = models.UserProfileResponse{
Account: account.Result,
Details: userProfile.Result,
}
s.Result.Account.Password = "SECRET"
}1234567891011121314151617181920212223242526272829303132333435*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text12345678910---
title: Pweb Api
emoji: 📉
colorFrom: green
colorTo: pink
sdk: docker
pinned: false
---
12345678910111213141516171819202122232425262728package utils
import (
"log"
"os"
"pweb-api.abdanhafidz.com/config"
)
func LogError(errorLogged error) {
log.Println("Error Log :", errorLogged)
_, err := os.Stat(config.LOG_PATH + "/error_log.txt")
if os.IsNotExist(err) {
_, err = os.Create(config.LOG_PATH + "/error_log.txt")
if err != nil {
log.Fatalf("Gagal buka file log: %v", err)
}
}
file, err := os.OpenFile(config.LOG_PATH+"/error_log.txt", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
log.Fatalf("Gagal buka file log: %v", err)
}
log.SetOutput(file)
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253package utils
import (
"net/http"
"reflect"
"pweb-api.abdanhafidz.com/models"
"pweb-api.abdanhafidz.com/services"
"github.com/gin-gonic/gin"
)
func ResponseOK(c *gin.Context, data any) {
res := models.SuccessResponse{
Status: "success",
Message: "Data retrieved successfully!",
Data: data,
MetaData: c.Request.Body,
}
c.JSON(http.StatusOK, res)
return
}
func ResponseFAIL(c *gin.Context, status int, exception models.Exception) {
message := exception.Message
exception.Message = ""
res := models.ErrorResponse{
Status: "error",
Message: message,
Errors: exception,
MetaData: c.Request.Body,
}
c.AbortWithStatusJSON(status, res)
return
}
func SendResponse(c *gin.Context, data services.Service[any, any]) {
if reflect.ValueOf(data.Exception).IsNil() {
ResponseOK(c, data)
} else {
if data.Exception.Unauthorized {
ResponseFAIL(c, 401, data.Exception)
} else if data.Exception.BadRequest {
ResponseFAIL(c, 400, data.Exception)
} else if data.Exception.DataNotFound {
ResponseFAIL(c, 404, data.Exception)
} else if data.Exception.InternalServerError {
ResponseFAIL(c, 500, data.Exception)
} else {
ResponseFAIL(c, 403, data.Exception)
}
}
}1234567891011package utils
import (
"github.com/gin-gonic/gin"
"pweb-api.abdanhafidz.com/models"
)
func GetAccount(c *gin.Context) models.AccountData {
cParam, _ := c.Get("accountData")
return cParam.(models.AccountData)
}123456789package utils
func ternaryMessage(condition bool, valueIfTrue string, valueIfFalse string) string {
if condition {
return valueIfTrue
} else {
return valueIfFalse
}
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Abdan Hafidz Portal</title>
<link rel="stylesheet" href="style/styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="scripts/scripts.js"></script>
</head>
<body>
<!-- Loading Indicator -->
<div class="loading" id="loadingIndicator" style="display: none;">
<div class="loading-spinner"></div>
</div>
<!-- Header -->
<header>
<div class="container">
<nav>
<div class="logo">Abdan Hafidz Portal</div>
<div class="nav-links" id="navLinks">
<!-- Links will be dynamically added based on auth state -->
</div>
</nav>
</div>
</header>
<!-- Welcome Section -->
<section class="auth-section">
<div class="container">
<div class="auth-container">
<h2 class="auth-title">Welcome to Abdan Hafidz Portal</h2>
<p style="text-align: center; margin-bottom: 2rem;">
Your personal dashboard for managing your profile and settings.
</p>
<div style="display: flex; justify-content: center; gap: 1rem;">
<a href="login.html" class="btn">Login</a>
<a href="register.html" class="btn btn-outline">Register</a>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer>
<div class="container">
<p>© 2025 Abdan Hafidz Portal. All rights reserved.</p>
</div>
</footer>
<script>
$(document).ready(function() {
// Check if user is already logged in
if (isLoggedIn()) {
window.location.href = 'profile.html';
}
});
</script>
</body>
</html>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Abdan Hafidz Portal</title>
<link rel="stylesheet" href="style/styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="scripts/scripts.js"></script>
</head>
<body>
<!-- Loading Indicator -->
<div class="loading" id="loadingIndicator" style="display: none;">
<div class="loading-spinner"></div>
</div>
<!-- Header -->
<header>
<div class="container">
<nav>
<div class="logo">Abdan Hafidz Portal</div>
<div class="nav-links" id="navLinks">
<!-- Links will be dynamically added based on auth state -->
</div>
</nav>
</div>
</header>
<!-- Login Page -->
<section class="auth-section">
<div class="container">
<div class="auth-container">
<h2 class="auth-title">Login to Your Account</h2>
<div id="loginAlert" style="display: none;"></div>
<form id="loginForm">
<div class="form-group">
<label for="loginEmail">Email Address</label>
<input type="email" class="form-control" id="loginEmail" placeholder="Enter your email" required>
</div>
<div class="form-group">
<label for="loginPassword">Password</label>
<input type="password" class="form-control" id="loginPassword" placeholder="Enter your password" required>
</div>
<button type="submit" class="btn" style="width: 100%;">Login</button>
<div class="form-footer">
<p>Don't have an account? <a href="register.html">Register Now</a></p>
</div>
</form>
</div>
</div>
</section>
<!-- Footer -->
<footer>
<div class="container">
<p>© 2025 Abdan Hafidz Portal. All rights reserved.</p>
</div>
</footer>
<script>
$(document).ready(function() {
// Check if user is already logged in
if (isLoggedIn()) {
window.location.href = 'profile.html';
}
// Login Form Submission
$('#loginForm').on('submit', function(e) {
e.preventDefault();
const email = $('#loginEmail').val();
const password = $('#loginPassword').val();
login(email, password);
});
});
</script>
</body>
</html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Profile - Abdan Hafidz Portal</title>
<link rel="stylesheet" href="style/styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="scripts/scripts.js"></script>
</head>
<body>
<!-- Loading Indicator -->
<div class="loading" id="loadingIndicator" style="display: none;">
<div class="loading-spinner"></div>
</div>
<!-- Header -->
<header>
<div class="container">
<nav>
<div class="logo">Abdan Hafidz Portal</div>
<div class="nav-links" id="navLinks">
<!-- Links will be dynamically added based on auth state -->
</div>
</nav>
</div>
</header>
<!-- Profile Page -->
<section>
<div class="container">
<div class="profile-container">
<div class="profile-header">
<div class="profile-avatar" id="profileInitials">U</div>
<div class="profile-title">
<h1 id="profileName">User Profile</h1>
<p class="profile-email" id="profileEmail">email@example.com</p>
</div>
</div>
<div id="profileAlert" style="display: none;"></div>
<form id="profileForm">
<div class="profile-form">
<div class="form-group">
<label for="profileFullName">Full Name</label>
<input type="text" class="form-control" id="profileFullName" placeholder="Enter your full name">
</div>
<div class="form-group">
<label for="profileInitialName">Initial Name</label>
<input type="text" class="form-control" id="profileInitialName" placeholder="Enter your initials">
</div>
<div class="form-group">
<label for="profileUniversity">University</label>
<input type="text" class="form-control" id="profileUniversity" placeholder="Enter your university">
</div>
<div class="form-group">
<label for="profilePhone">Phone Number</label>
<input type="tel" class="form-control" id="profilePhone" placeholder="Enter your phone number">
</div>
</div>
<div class="profile-actions">
<button type="submit" class="btn">Save Changes</button>
<button type="button" class="btn btn-danger" id="logoutBtn">Logout</button>
</div>
</form>
</div>
</div>
</section>
<!-- Footer -->
<footer>
<div class="container">
<p>© 2025 Abdan Hafidz Portal. All rights reserved.</p>
</div>
</footer>
<script>
$(document).ready(function() {
// Check if user is logged in
if (!isLoggedIn()) {
window.location.href = 'login.html';
return;
}
// Fetch user profile data
fetchUserProfile();
// Profile Form Submission
$('#profileForm').on('submit', function(e) {
e.preventDefault();
const profileData = {
fullName: $('#profileFullName').val(),
initialName: $('#profileInitialName').val(),
university: $('#profileUniversity').val(),
phoneNumber: $('#profilePhone').val()
};
updateUserProfile(profileData);
});
// Logout Button
$('#logoutBtn').on('click', function(e) {
e.preventDefault();
logout();
});
});
</script>
</body>
</html>.env.exampleAdded+9
.github/workflows/main_huggingface.ymlAdded+52
.gitignoreAdded+6
DockerfileAdded+29
LICENSEAdded+201
README.md+10-10
config/config.goAdded+34
config/database_connection_config.goAdded+61
controller/auth/auth_change_password_controller.goAdded+21
controller/auth/auth_login_controller.goAdded+20
controller/auth/auth_register_controller.goAdded+20
controller/controller.goAdded+65
controller/home_controller.goAdded+9
controller/user/user_delete_controller.goAdded+22
controller/user/user_list_controller.goAdded+19
controller/user/user_profile_controller.goAdded+21
controller/user/user_update_profile_controller.goAdded+25
go.modAdded+67
go.sumAdded+168
main.goAdded+14
middleware/authentication_middleware.goAdded+65
middleware/middleware.goAdded+31
middleware/response_middleware.goAdded+45
models/authentication_payload_model.goAdded+8
models/custom_claim.goAdded+9
models/database_orm_model.goAdded+35
models/exception_model.goAdded+12
models/model.goAdded+1
models/request_model.goAdded+42
models/response_model.goAdded+25
repositories/account_repository.goAdded+97
repositories/repository.goAdded+117
router/auth_route.goAdded+15
router/router.goAdded+21
router/user_route.goAdded+17
services/authentication_service.goAdded+72
services/jwt_service.goAdded+81
services/register_service.goAdded+46
services/service.goAdded+42
services/user_list_service.goAdded+43
services/user_profile_service.goAdded+97
space/.gitattributesAdded+35
space/README.mdAdded+10
utils/Logger.goAdded+28
utils/api_response.goAdded+53
utils/helper.goAdded+11
utils/util.goAdded+9
views/index.htmlAdded+61
views/login.htmlAdded+77
views/profile.htmlAdded+108