📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Fixes in auth, setup config, start documents & user routes, setup minio for files uploads, add configs, fix responses.
Smaug#67394cd6304f7b48
diff --git a/backend/.env b/backend/.envindex b4fc4b5e..59b1f93d 100644--- a/backend/.env+++ b/backend/.env@@ -1,4 +1,10 @@JWT_SECRET=your_secret_keyDATABASE_USER=rootDATABASE_PASSWORD=root-FRONT_DOMAIN=localhost\ No newline at end of file+FRONT_DOMAIN=localhost++DOMAIN_CLIENT=http://localhost:3000+MINIO_ACCESSKEY=pXJwctLBhoL1RP4DUFtg+MINIO_SECRETKEY=OPpNQKFeZxC2AXRATLZX4YBhqCnXpjNF6OiQ95Yz+MINIO_ENDPOINT=localhost:9000+MINIO_BUCKET=alexandrie-uploads\ No newline at end of filediff --git a/backend/.gitignore b/backend/.gitignorenew file mode 100644index 00000000..198d671a--- /dev/null+++ b/backend/.gitignore@@ -0,0 +1,2 @@+minio.exe+.env\ No newline at end of filediff --git a/backend/app/app.go b/backend/app/app.goindex 2475d8cf..0893c7b4 100644--- a/backend/app/app.go+++ b/backend/app/app.go@@ -5,6 +5,7 @@ import ("database/sql"_ "github.com/go-sql-driver/mysql"+ "github.com/minio/minio-go/v7")type Config struct {@@ -16,8 +17,10 @@ type Config struct {Driver string}Cdn struct {- MaxSize float64- MaxUploadsSize float64+ MaxSize float64+ MaxUploadsSize float64+ SupportedTypesImages []string+ SupportedTypes []string}Auth struct {AccessTokenExpiry int@@ -26,15 +29,18 @@ type Config struct {}type App struct {- DB *sql.DB- Snowflake *utils.Snowflake- Config Config+ DB *sql.DB+ Snowflake *utils.Snowflake+ Config Config+ MinioClient *minio.Client}func InitApp(config Config) *App {var app Appapp.DB = DBConection(config)+ app.MinioClient, _ = MinioConnection()app.Snowflake = utils.NewSnowflake(1609459200000)app.Config = config+return &app}diff --git a/backend/app/minio.go b/backend/app/minio.gonew file mode 100644index 00000000..97eb591f--- /dev/null+++ b/backend/app/minio.go@@ -0,0 +1,60 @@+package app++import (+ "context"+ "fmt"+ "log"+ "os"++ "github.com/minio/minio-go/v7"+ "github.com/minio/minio-go/v7/pkg/credentials"+)++func MinioConnection() (*minio.Client, error) {+ ctx := context.Background()+ endpoint := os.Getenv("MINIO_ENDPOINT")+ accessKeyID := os.Getenv("MINIO_ACCESSKEY")+ secretAccessKey := os.Getenv("MINIO_SECRETKEY")+ // Initialize minio client object.+ minioClient, errInit := minio.New(endpoint, &minio.Options{+ Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),+ Secure: false,+ })+ if errInit != nil {+ log.Fatalln(errInit)+ }++ // Make a new bucket called dev-minio.+ bucketName := os.Getenv("MINIO_BUCKET")+ err := minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{})+ if err != nil {+ // Check to see if we already own this bucket (which happens if you run this twice)+ exists, errBucketExists := minioClient.BucketExists(ctx, bucketName)+ if errBucketExists == nil && exists {+ log.Printf("We already own %s\n", bucketName)+ } else {+ log.Fatalln(err)+ }+ } else {+ log.Printf("✅ Successfully created %s\n", bucketName)+ }+ // Définir la politique de lecture publique+ policy := fmt.Sprintf(`{+ "Version": "2012-10-17",+ "Statement": [+ {+ "Effect": "Allow",+ "Principal": "*",+ "Action": "s3:GetObject",+ "Resource": "arn:aws:s3:::%s/*"+ }+ ]+ }`, bucketName)++ err = minioClient.SetBucketPolicy(ctx, bucketName, policy)+ if err != nil {+ log.Fatalf("Failed to set bucket policy: %v", err)+ }+ fmt.Println("✅ Successfully set bucket policy")+ return minioClient, errInit+}diff --git a/backend/config.toml b/backend/config.tomlindex 84a920c7..0f53e426 100644--- a/backend/config.toml+++ b/backend/config.toml@@ -9,8 +9,51 @@ Port = 3306[Cdn]MaxSize = 2e+7 # 20MBMaxUploadsSize = 1e+9 # 1GB+SupportedTypesImages = [+ "image/png",+ "image/jpeg",+ "image/gif",+ "image/bmp",+ "image/webp",+ "image/svg+xml",+ "image/vnd.microsoft.icon",+]+SupportedTypes = [+ # image formats+ "image/png",+ "image/jpeg",+ "image/gif",+ "image/bmp",+ "image/webp",+ "image/svg+xml",+ "image/vnd.microsoft.icon",+ # video formats+ "video/mp4",+ "video/x-msvideo", # .avi+ "video/quicktime", # .mov+ "video/x-ms-wmv", # .wmv+ "video/x-flv", # .flv+ "video/x-matroska", # .mkv+ "video/webm", # .webm+ # document formats+ "application/pdf", # .pdf+ "application/msword", # .doc+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document", # .docx+ "application/vnd.ms-excel", # .xls+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", # .xlsx+ "application/vnd.ms-powerpoint", # .ppt+ "application/vnd.openxmlformats-officedocument.presentationml.presentation", # .pptx+ "text/plain", # .txt+ "text/csv", # .csv+ # archive formats+ "application/zip", # .zip+ "application/x-rar-compressed", # .rar+ "application/x-tar", # .tar+ "application/gzip", # .gz+ "application/x-bzip2", # .bz2+][Auth]AccessTokenExpiry = 1800 # 30 minutesRefreshTokenExpiry = 604800 # 7 days-+diff --git a/backend/controllers/authentification.controller.go b/backend/controllers/authentification.controller.goindex fc8a6745..f3dfc6c3 100644--- a/backend/controllers/authentification.controller.go+++ b/backend/controllers/authentification.controller.go@@ -6,6 +6,7 @@ import ("crypto/rand""fmt""os"+ "strconv""time""github.com/gin-gonic/gin"@@ -13,8 +14,6 @@ import ("golang.org/x/crypto/bcrypt")-var refresh_token_expiration = 1000 * 60 * 1 // 2 minutes-func (dc *Controller) Login(c *gin.Context) {username := c.PostForm("username")password := c.PostForm("password")@@ -45,7 +44,7 @@ func (dc *Controller) Login(c *gin.Context) {Id: dc.app.Snowflake.Generate(),UserId: user.Id,RefreshToken: signRefreshToken(),- ExpireToken: time.Now().Add(time.Duration(refresh_token_expiration * 1000000)).UnixMilli(),+ ExpireToken: time.Now().Add(time.Duration(dc.app.Config.Auth.RefreshTokenExpiry * int(time.Second))).UnixMilli(),LastRefreshTimestamp: time.Now().UnixMilli(),Active: 1,LoginTimestamp: time.Now().UnixMilli(),@@ -58,7 +57,7 @@ func (dc *Controller) Login(c *gin.Context) {}c.SetCookie("Authorization", tokenString, 1800, "/", "localhost", false, true)- c.SetCookie("RefreshToken", session.RefreshToken, int(time.Duration(refresh_token_expiration).Seconds()), "/", "localhost", false, true)+ c.SetCookie("RefreshToken", session.RefreshToken, int(time.Duration(dc.app.Config.Auth.RefreshTokenExpiry).Seconds()), "/", "localhost", false, true)c.JSON(200, utils.Success(user))@@ -93,7 +92,7 @@ func (dc *Controller) RefreshSession(c *gin.Context) {}// Update the sessionsession.RefreshToken = signRefreshToken()- session.ExpireToken = time.Now().Add(time.Duration(refresh_token_expiration)).UnixMilli()+ session.ExpireToken = time.Now().Add(time.Duration(dc.app.Config.Auth.RefreshTokenExpiry * int(time.Second))).UnixMilli()session.LastRefreshTimestamp = time.Now().UnixMilli()if _, err = dc.model.UpdateSession(&session); err != nil {c.JSON(500, utils.Error("Failed to update session."))@@ -107,13 +106,12 @@ func (dc *Controller) RefreshSession(c *gin.Context) {}func (dc *Controller) signAccessToken(user models.User) (string, error) {- fmt.Println("Signing token for user", user.Username, "with role", user.Role)claims := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{- "sub": user.Id, // Subject (user identifier)+ "sub": strconv.FormatInt(user.Id, 10), // Subject (user identifier)"iss": "alexandrie", // Issuer"exp": time.Now().Add(time.Duration(time.Second * time.Duration(dc.app.Config.Auth.RefreshTokenExpiry))).Unix(), // Expiration time"iat": time.Now().Unix(), // Issued at- "role": user.Role,+ "role": strconv.Itoa(user.Role),})tokenString, err := claims.SignedString([]byte(os.Getenv("JWT_SECRET")))if err != nil {diff --git a/backend/controllers/documents.controller.go b/backend/controllers/documents.controller.gonew file mode 100644index 00000000..90462784--- /dev/null+++ b/backend/controllers/documents.controller.go@@ -0,0 +1,131 @@+package controllers++import (+ "Smaug6739/Alexandrie/models"+ "net/http"+ "strconv"++ "github.com/gin-gonic/gin"+)++func (ctr *Controller) GetAllDocuments(c *gin.Context) {+ userId, exists := c.Get("user_id")+ if !exists {+ c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})+ return+ }++ documents, err := ctr.model.GetAllDocuments(userId.(int64))+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ return+ }+ c.JSON(http.StatusOK, documents)+}++func (ctr *Controller) GetDocument(c *gin.Context) {+ userId, exists := c.Get("user_id")+ if !exists {+ c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})+ return+ }+ id, err := strconv.ParseInt(c.Param("id"), 10, 64)+ if err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid document ID"})+ return+ }+ document, err := ctr.model.GetDocument(id, userId.(int64))+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ return+ }+ if document == nil {+ c.JSON(http.StatusNotFound, gin.H{"error": "Document not found or unauthorized"})+ return+ }+ c.JSON(http.StatusOK, document)+}++func (ctr *Controller) AddDocument(c *gin.Context) {+ userId, exists := c.Get("user_id")+ if !exists {+ c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})+ return+ }+ var document models.Document+ if err := c.ShouldBindJSON(&document); err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request payload"})+ return+ }+ document.Id = ctr.app.Snowflake.Generate()+ document.AuthorId = userId.(int64)+ err := ctr.model.AddDocument(document)+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ return+ }+ c.JSON(http.StatusCreated, gin.H{"message": "Document created successfully", "document": document})+}++func (ctr *Controller) UpdateDocument(c *gin.Context) {+ claims, exists := c.Get("claims")+ if !exists {+ c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})+ return+ }++ userId, _ := claims.(map[string]interface{})["user_id"].(float64)+ id, err := strconv.ParseInt(c.Param("id"), 10, 64)+ if err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid document ID"})+ return+ }+ var document models.Document+ if err := c.ShouldBindJSON(&document); err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request payload"})+ return+ }+ dbDoc, err := ctr.model.GetDocument(id, int64(userId))+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ return+ }+ if dbDoc == nil {+ c.JSON(http.StatusNotFound, gin.H{"error": "Document not found or unauthorized"})+ return+ }+ document.AuthorId = dbDoc.AuthorId+ err = ctr.model.UpdateDocument(id, document)+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ return+ }+ c.JSON(http.StatusOK, gin.H{"message": "Document updated successfully", "document": document})+}++func (ctr *Controller) DeleteDocument(c *gin.Context) {+ claims, exists := c.Get("claims")+ if !exists {+ c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})+ return+ }++ userId, _ := claims.(map[string]interface{})["user_id"].(float64)+ id, err := strconv.ParseInt(c.Param("id"), 10, 64)+ dbDoc, err := ctr.model.GetDocument(id, int64(userId))+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ return+ }+ if dbDoc == nil {+ c.JSON(http.StatusNotFound, gin.H{"error": "Document not found or unauthorized"})+ return+ }++ err = ctr.model.DeleteDocument(id)+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ return+ }+ c.JSON(http.StatusOK, gin.H{"message": "Document deleted successfully"})+}diff --git a/backend/controllers/uploads.controller.go b/backend/controllers/uploads.controller.gonew file mode 100644index 00000000..18f7713b--- /dev/null+++ b/backend/controllers/uploads.controller.go@@ -0,0 +1,112 @@+package controllers++import (+ "Smaug6739/Alexandrie/utils"+ "fmt"+ "net/http"+ "os"+ "path/filepath"++ "github.com/gin-gonic/gin"+ "github.com/minio/minio-go/v7"+)++func (ctr *Controller) UploadAvatar(c *gin.Context) {+ file, header, err := c.Request.FormFile("avatar")+ if err != nil {+ c.JSON(http.StatusBadRequest, utils.Error("Failed to get file"))+ return+ }+ defer file.Close()++ ext := filepath.Ext(header.Filename)++ // Check if the file size exceeds the limit+ if header.Size > int64(ctr.app.Config.Cdn.MaxSize) {+ c.JSON(http.StatusBadRequest, utils.Error("File size exceeds the limit"))+ return+ }++ // Check if the MIME type is supported+ mimeType := header.Header.Get("Content-Type")+ isSupportedMime := false+ for _, supportedMime := range ctr.app.Config.Cdn.SupportedTypesImages {+ if mimeType == supportedMime {+ isSupportedMime = true+ break+ }+ }+ if !isSupportedMime {+ c.JSON(http.StatusBadRequest, utils.Error("File type not supported"))+ return+ }++ userID, _ := c.Get("user_id")+ prefix := fmt.Sprintf("avatars/%0.f", userID)++ // Lister les fichiers de l'utilisateur dans MinIO+ objectsCh := ctr.app.MinioClient.ListObjects(c, os.Getenv("MINIO_BUCKET"), minio.ListObjectsOptions{+ Prefix: prefix,+ Recursive: true,+ })++ // Supprimer les anciens avatars+ for object := range objectsCh {+ if object.Err == nil {+ _ = ctr.app.MinioClient.RemoveObject(c, os.Getenv("MINIO_BUCKET"), object.Key, minio.RemoveObjectOptions{})+ }+ }++ objectName := fmt.Sprintf("avatars/%0.f%s", userID, ext)++ _, err = ctr.app.MinioClient.PutObject(c, os.Getenv("MINIO_BUCKET"), objectName, file, header.Size, minio.PutObjectOptions{ContentType: header.Header.Get("Content-Type")})+ if err != nil {+ c.JSON(http.StatusInternalServerError, utils.Error("Failed to upload file"))+ return+ }++ c.JSON(http.StatusOK, utils.Success("Avatar uploaded successfully"))+}++func (ctr *Controller) UploadFile(c *gin.Context) {+ file, header, err := c.Request.FormFile("file")+ if err != nil {+ c.JSON(http.StatusBadRequest, utils.Error("Failed to get file"))+ return+ }+ defer file.Close()++ ext := filepath.Ext(header.Filename)++ // Check if the file size exceeds the limit+ if header.Size > int64(ctr.app.Config.Cdn.MaxUploadsSize) {+ c.JSON(http.StatusBadRequest, utils.Error("File size exceeds the limit"))+ return+ }++ // Check if the MIME type is supported+ mimeType := header.Header.Get("Content-Type")+ isSupportedMime := false+ for _, supportedMime := range ctr.app.Config.Cdn.SupportedTypes {+ if mimeType == supportedMime {+ isSupportedMime = true+ break+ }+ }+ if !isSupportedMime {+ c.JSON(http.StatusBadRequest, utils.Error("File type not supported"))+ return+ }++ userID, _ := c.Get("user_id")++ objectName := fmt.Sprintf("uploads/%0.f%s", userID, ext)++ _, err = ctr.app.MinioClient.PutObject(c, os.Getenv("MINIO_BUCKET"), objectName, file, header.Size, minio.PutObjectOptions{ContentType: header.Header.Get("Content-Type")})+ if err != nil {+ c.JSON(http.StatusInternalServerError, utils.Error("Failed to upload file"))+ return+ }++ c.JSON(http.StatusOK, utils.Success("File uploaded successfully"))+}diff --git a/backend/controllers/users.controller.go b/backend/controllers/users.controller.goindex c834dd77..72bfefb4 100644--- a/backend/controllers/users.controller.go+++ b/backend/controllers/users.controller.go@@ -1,7 +1,10 @@package controllersimport (+ "Smaug6739/Alexandrie/models"+ "Smaug6739/Alexandrie/utils""net/http"+ "strconv""github.com/gin-gonic/gin")@@ -10,8 +13,103 @@ func (ctr *Controller) GetUsers(c *gin.Context) {users, err := ctr.model.GetAllUsers()if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})+ c.JSON(http.StatusInternalServerError, utils.Error(err.Error()))return}c.JSON(http.StatusOK, users)}++func (ctr *Controller) GetMe(c *gin.Context) {+ userId, exists := c.Get("user_id")+ if !exists {+ c.JSON(http.StatusUnauthorized, gin.H{"error": "User ID not found in context"})+ return+ }+ user, err := ctr.model.GetUserById(userId.(int64))+ if err != nil {+ c.JSON(http.StatusInternalServerError, utils.Error(err.Error()))+ return+ }+ c.JSON(http.StatusOK, utils.Success(user))+}++func (ctr *Controller) GetUserById(c *gin.Context) {+ id, err := strconv.ParseInt(c.Param("id"), 10, 64)+ if err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid user ID"})+ return+ }+ user, err := ctr.model.GetUserById(id)+ if err != nil {+ c.JSON(http.StatusInternalServerError, utils.Error(err.Error()))+ return+ }+ if user == nil {+ c.JSON(http.StatusNotFound, gin.H{"error": "User not found"})+ return+ }+ c.JSON(http.StatusOK, utils.Success(user))+}++func (ctr *Controller) CreateUser(c *gin.Context) {+ var user models.User+ if err := c.ShouldBindJSON(&user); err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request payload"})+ return+ }++ createdUser, err := ctr.model.CreateUser(user)+ if err != nil {+ c.JSON(http.StatusInternalServerError, utils.Error(err.Error()))+ return+ }+ c.JSON(http.StatusCreated, createdUser)+}++func (ctr *Controller) UpdateUser(c *gin.Context) {+ id, err := strconv.ParseInt(c.Param("id"), 10, 64)+ if err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid user ID"})+ return+ }+ var user models.User+ if err := c.ShouldBindJSON(&user); err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request payload"})+ return+ }++ updatedUser, err := ctr.model.UpdateUser(id, user)+ if err != nil {+ c.JSON(http.StatusInternalServerError, utils.Error(err.Error()))+ return+ }+ c.JSON(http.StatusOK, updatedUser)+}++func (ctr *Controller) UpdatePassword(c *gin.Context) {+ id, err := strconv.ParseInt(c.Param("id"), 10, 64)+ if err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid user ID"})+ return+ }+ var payload struct {+ Password string `json:"password"`+ }++ if err := c.ShouldBindJSON(&payload); err != nil {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request payload"})+ return+ }++ if payload.Password == "" {+ c.JSON(http.StatusBadRequest, gin.H{"error": "Password must be provided"})+ return+ }++ err = ctr.model.UpdatePassword(id, payload.Password)+ if err != nil {+ c.JSON(http.StatusInternalServerError, utils.Error(err.Error()))+ return+ }+ c.JSON(http.StatusOK, gin.H{"message": "Password updated successfully"})+}diff --git a/backend/go.mod b/backend/go.modindex 885f49dc..5cf13178 100644--- a/backend/go.mod+++ b/backend/go.mod@@ -2,6 +2,8 @@ module Smaug6739/Alexandriego 1.23.1+require github.com/minio/minio-go v6.0.14+incompatible+require (filippo.io/edwards25519 v1.1.0 // indirectgithub.com/BurntSushi/toml v1.5.0 // indirect@@ -9,28 +11,38 @@ require (github.com/bytedance/sonic/loader v0.2.4 // indirectgithub.com/cloudwego/base64x v0.1.5 // indirectgithub.com/cloudwego/iasm v0.2.0 // indirect+ github.com/dustin/go-humanize v1.0.1 // indirectgithub.com/gabriel-vasile/mimetype v1.4.8 // indirect+ github.com/gin-contrib/cors v1.7.4 // indirectgithub.com/gin-contrib/sse v1.0.0 // indirectgithub.com/gin-gonic/gin v1.10.0 // indirect+ github.com/go-ini/ini v1.67.0 // indirectgithub.com/go-playground/locales v0.14.1 // indirectgithub.com/go-playground/universal-translator v0.18.1 // indirectgithub.com/go-playground/validator/v10 v10.25.0 // indirectgithub.com/go-sql-driver/mysql v1.9.1 // indirectgithub.com/goccy/go-json v0.10.5 // indirectgithub.com/golang-jwt/jwt/v5 v5.2.2 // indirect+ github.com/google/uuid v1.6.0 // indirectgithub.com/joho/godotenv v1.5.1 // indirectgithub.com/json-iterator/go v1.1.12 // indirect+ github.com/klauspost/compress v1.18.0 // indirectgithub.com/klauspost/cpuid/v2 v2.2.10 // indirectgithub.com/leodido/go-urn v1.4.0 // indirectgithub.com/mattn/go-isatty v0.0.20 // indirect+ github.com/minio/crc64nvme v1.0.1 // indirect+ github.com/minio/md5-simd v1.1.2 // indirect+ github.com/minio/minio-go/v7 v7.0.89 // indirect+ github.com/mitchellh/go-homedir v1.1.0 // indirectgithub.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirectgithub.com/modern-go/reflect2 v1.0.2 // indirectgithub.com/pelletier/go-toml/v2 v2.2.3 // indirect+ github.com/rs/xid v1.6.0 // indirectgithub.com/twitchyliquid64/golang-asm v0.15.1 // indirectgithub.com/ugorji/go/codec v1.2.12 // indirectgolang.org/x/arch v0.15.0 // indirectgolang.org/x/crypto v0.36.0 // indirect- golang.org/x/net v0.37.0 // indirect+ golang.org/x/net v0.38.0 // indirectgolang.org/x/sys v0.31.0 // indirectgolang.org/x/text v0.23.0 // indirectgoogle.golang.org/protobuf v1.36.5 // indirectdiff --git a/backend/go.sum b/backend/go.sumindex ec509882..02d0ac62 100644--- a/backend/go.sum+++ b/backend/go.sum@@ -13,12 +13,18 @@ github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=+github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=+github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=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/cors v1.7.4 h1:/fC6/wk7rCRtqKqki8lLr2Xq+hnV49aXDLIuSek9g4k=+github.com/gin-contrib/cors v1.7.4/go.mod h1:vGc/APSgLMlQfEJV5NAzkrAHb0C8DetL3K6QZuvGii0=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-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=+github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=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=@@ -32,10 +38,15 @@ github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PUgithub.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=+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/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/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=+github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=+github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=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=@@ -44,6 +55,16 @@ 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/minio/crc64nvme v1.0.1 h1:DHQPrYPdqK7jQG/Ls5CTBZWeex/2FMS3G5XGkycuFrY=+github.com/minio/crc64nvme v1.0.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=+github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=+github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=+github.com/minio/minio-go v6.0.14+incompatible h1:fnV+GD28LeqdN6vT2XdGKW8Qe/IfjJDswNVuni6km9o=+github.com/minio/minio-go v6.0.14+incompatible/go.mod h1:7guKYtitv8dktvNUGrhzmNlA5wrAABTQXCoesZdFQO8=+github.com/minio/minio-go/v7 v7.0.89 h1:hx4xV5wwTUfyv8LarhJAwNecnXpoTsj9v3f3q/ZkiJU=+github.com/minio/minio-go/v7 v7.0.89/go.mod h1:2rFnGAp02p7Dddo1Fq4S2wYOfpF0MUTSeLTRC90I204=+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=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=@@ -52,6 +73,8 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYgithub.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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=+github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=+github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=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=@@ -73,6 +96,8 @@ 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/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=+golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=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=diff --git a/backend/main.go b/backend/main.goindex edd9289f..e2ef72c7 100644--- a/backend/main.go+++ b/backend/main.go@@ -7,6 +7,7 @@ import ("os""github.com/BurntSushi/toml"+ "github.com/gin-contrib/cors""github.com/gin-gonic/gin"_ "github.com/go-sql-driver/mysql""github.com/joho/godotenv"@@ -27,5 +28,15 @@ func main() {app_router := router.InitRouter(app)// Recovery middleware recovers from any panics and writes a 500 if there was one.app_router.Use(gin.Recovery())++ app_router.SetTrustedProxies([]string{"127.0.0.1", "localhost"})++ app_router.Use(cors.New(cors.Config{+ AllowOrigins: []string{os.Getenv("DOMAIN_CLIENT")},+ AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},+ ExposeHeaders: []string{"Content-Length"},+ AllowCredentials: true,+ }))+app_router.Run("localhost:8080")}diff --git a/backend/middlewares/admin.go b/backend/middlewares/admin.goindex 62a226f2..d0006b70 100644--- a/backend/middlewares/admin.go+++ b/backend/middlewares/admin.go@@ -4,32 +4,17 @@ import ("Smaug6739/Alexandrie/utils""github.com/gin-gonic/gin"- "github.com/golang-jwt/jwt/v5")func Admin() gin.HandlerFunc {return func(c *gin.Context) {- claims, _ := c.Get("claims")- if claims == nil {- c.JSON(401, utils.Error("Unauthorized"))- c.Abort()- return- }-- mapClaims, ok := claims.(jwt.MapClaims)- if !ok {- c.JSON(401, utils.Error("Unauthorized"))- c.Abort()- return- }- role, ok := mapClaims["role"] // JWT stocke souvent les nombres sous forme de float64+ role, ok := c.Get("user_role")if !ok {c.JSON(401, utils.Error("Invalid role in token"))c.Abort()return}-- if role.(float64) != 2 {+ if role != 2 {c.JSON(401, utils.Error("Unauthorized"))c.Abort()returndiff --git a/backend/middlewares/authentification.go b/backend/middlewares/authentification.goindex 2048ea6b..23745e0c 100644--- a/backend/middlewares/authentification.go+++ b/backend/middlewares/authentification.go@@ -5,6 +5,7 @@ import ("fmt""net/http""os"+ "strconv""github.com/gin-gonic/gin""github.com/golang-jwt/jwt/v5"@@ -20,7 +21,8 @@ func Auth() gin.HandlerFunc {}// Parse the token- token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {+ claims := utils.AuthClaims{}+ token, err := jwt.ParseWithClaims(tokenString, &claims, func(token *jwt.Token) (interface{}, error) {if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {return nil, http.ErrAbortHandler}@@ -28,21 +30,28 @@ func Auth() gin.HandlerFunc {})if err != nil || !token.Valid {+ fmt.Println("Error parsing token:", err)c.JSON(http.StatusUnauthorized, utils.Error("Unauthorized"))c.Abort() // Stop further processing if unauthorizedreturn}// Set the token claims to the context- if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {- c.Set("claims", claims)- fmt.Println(claims)- } else {- c.JSON(http.StatusUnauthorized, utils.Error("Unauthorized"))- c.Abort()+ user_id, err := strconv.ParseInt(claims.Subject, 10, 64)+ if err != nil {+ c.JSON(http.StatusUnauthorized, utils.Error("Invalid user ID"))+ c.Abort() // Stop further processing if unauthorizedreturn}-+ user_role, err := strconv.Atoi(claims.Role)+ if err != nil {+ c.JSON(http.StatusUnauthorized, utils.Error("Invalid user role"))+ c.Abort() // Stop further processing if unauthorized+ return+ }+ c.Set("user_id", user_id) // Set user ID in context+ c.Set("user_role", user_role) // Set user role in context+ c.Set("claims", claims)c.Next() // Proceed to the next handler if authorized}}diff --git a/backend/models/document.model.go b/backend/models/document.model.gonew file mode 100644index 00000000..6072ea39--- /dev/null+++ b/backend/models/document.model.go@@ -0,0 +1,79 @@+package models++import (+ "database/sql"+ "errors"+)++type Document struct {+ Id int64 `json:"id"`+ Name string `json:"name"`+ Description *string `json:"description"`+ Tags *string `json:"tags"`+ Category *int64 `json:"category"`+ ParentId *int64 `json:"parent_id"`+ Accessibility int `json:"accessibility"`+ ContentMarkdown *string `json:"content_markdown"`+ ContentHtml *string `json:"content_html"`+ AuthorId int64 `json:"author_id"`+ CreatedTimestamp int64 `json:"created_timestamp"`+ UpdatedTimestamp int64 `json:"updated_timestamp"`+}++func (m *Model) GetAllDocuments(authorId int64) ([]Document, error) {+ var documents []Document+ rows, err := m.DB.Query("SELECT id, name, description, tags, category, parent_id, accessibility, author_id, created_timestamp, updated_timestamp FROM documents WHERE author_id = ? ORDER BY name", authorId)+ if err != nil {+ return nil, err+ }+ defer rows.Close()++ for rows.Next() {+ var doc Document+ err := rows.Scan(+ &doc.Id, &doc.Name, &doc.Description, &doc.Tags, &doc.Category,+ &doc.ParentId, &doc.Accessibility, &doc.AuthorId, &doc.CreatedTimestamp, &doc.UpdatedTimestamp,+ )+ if err != nil {+ return nil, err+ }+ documents = append(documents, doc)+ }+ return documents, nil+}++func (m *Model) GetDocument(id, authorId int64) (*Document, error) {+ var doc Document+ err := m.DB.QueryRow("SELECT id, name, description, tags, category, parent_id, accessibility, author_id, created_timestamp, updated_timestamp FROM documents WHERE id = ? AND author_id = ?", id, authorId).Scan(+ &doc.Id, &doc.Name, &doc.Description, &doc.Tags, &doc.Category,+ &doc.ParentId, &doc.Accessibility, &doc.AuthorId, &doc.CreatedTimestamp, &doc.UpdatedTimestamp,+ )+ if errors.Is(err, sql.ErrNoRows) {+ return nil, nil+ }+ if err != nil {+ return nil, err+ }+ return &doc, nil+}++func (m *Model) AddDocument(doc Document) error {+ _, err := m.DB.Exec(+ "INSERT INTO documents (id, name, description, tags, category, parent_id, accessibility, content_markdown, content_html, author_id, created_timestamp, updated_timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",+ doc.Id, doc.Name, doc.Description, doc.Tags, doc.Category, doc.ParentId, doc.Accessibility, doc.ContentMarkdown, doc.ContentHtml, doc.AuthorId, doc.CreatedTimestamp, doc.UpdatedTimestamp,+ )+ return err+}++func (m *Model) UpdateDocument(id int64, doc Document) error {+ _, err := m.DB.Exec(+ "UPDATE documents SET name = ?, description = ?, tags = ?, category = ?, parent_id = ?, accessibility = ?, content_markdown = ?, content_html = ?, updated_timestamp = ? WHERE id = ?",+ doc.Name, doc.Description, doc.Tags, doc.Category, doc.ParentId, doc.Accessibility, doc.ContentMarkdown, doc.ContentHtml, doc.UpdatedTimestamp, id,+ )+ return err+}++func (m *Model) DeleteDocument(id int64) error {+ _, err := m.DB.Exec("DELETE FROM documents WHERE id = ?", id)+ return err+}diff --git a/backend/models/user.model.go b/backend/models/user.model.goindex 0bc958c9..c47ff1fe 100644--- a/backend/models/user.model.go+++ b/backend/models/user.model.go@@ -95,3 +95,32 @@ func (m *Model) GetUserById(id int64) (*User, error) {return &user, nil}+func (m *Model) CreateUser(user User) (*User, error) {+ _, err := m.DB.Exec("INSERT INTO users (id, username, firstname, lastname, role, avatar, email, password, created_timestamp, updated_timestamp) VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?)",+ user.Id, user.Username, user.Firstname, user.Lastname, user.Role, user.Avatar, user.Email, user.Password, user.CreatedTimestamp, user.UpdatedTimestamp)+ if err != nil {+ return nil, err+ }++ return &user, nil+}++func (m *Model) UpdateUser(id int64, user User) (*User, error) {+ _, err := m.DB.Exec("UPDATE users SET username=?, firstname=?, lastname=?, role=?, avatar=?, email=?, updated_timestamp=? WHERE id=?",+ user.Username, user.Firstname, user.Lastname, user.Role, user.Avatar, user.Email, user.UpdatedTimestamp, id)+ if err != nil {+ return nil, err+ }+ user.Id = id+ return &user, nil+}++func (m *Model) UpdatePassword(id int64, password string) error {+ _, err := m.DB.Exec("UPDATE users SET password=? WHERE id=?", password, id)+ return err+}++func (m *Model) DeleteUser(id int64) error {+ _, err := m.DB.Exec("DELETE FROM users WHERE id=?", id)+ return err+}diff --git a/backend/router/router.go b/backend/router/router.goindex de4b440a..c7868b40 100644--- a/backend/router/router.go+++ b/backend/router/router.go@@ -12,5 +12,6 @@ func InitRouter(app *app.App) *gin.Engine {mainGroup := router.Group("/api")routes.Users(app, mainGroup)routes.Auth(app, mainGroup)+ routes.Uploads(app, mainGroup)return router}diff --git a/backend/router/routes/documents.go b/backend/router/routes/documents.gonew file mode 100644index 00000000..677ecc41--- /dev/null+++ b/backend/router/routes/documents.go@@ -0,0 +1,19 @@+package routes++import (+ "Smaug6739/Alexandrie/controllers"+ "Smaug6739/Alexandrie/middlewares"++ "github.com/gin-gonic/gin"+)++func RegisterDocumentRoutes(router *gin.Engine, controller *controllers.Controller) {+ documents := router.Group("/documents")+ documents.Use(middlewares.Auth())++ documents.GET("/", controller.GetAllDocuments)+ documents.GET("/:id", controller.GetDocument)+ documents.POST("/", controller.AddDocument)+ documents.PATCH("/:id", controller.UpdateDocument)+ documents.DELETE("/:id", controller.DeleteDocument)+}diff --git a/backend/router/routes/uploads.go b/backend/router/routes/uploads.gonew file mode 100644index 00000000..84ea9853--- /dev/null+++ b/backend/router/routes/uploads.go@@ -0,0 +1,18 @@+package routes++import (+ "Smaug6739/Alexandrie/app"+ "Smaug6739/Alexandrie/controllers"+ "Smaug6739/Alexandrie/middlewares"++ "github.com/gin-gonic/gin"+)++func Uploads(app *app.App, router *gin.RouterGroup) {+ uploads := router.Group("/uploads")+ uploadsCtrl := controllers.NewController(app)++ uploads.Use(middlewares.Auth())++ uploads.POST("/", uploadsCtrl.UploadAvatar)+}diff --git a/backend/router/routes/users.go b/backend/router/routes/users.goindex 523ea587..c43641e4 100644--- a/backend/router/routes/users.go+++ b/backend/router/routes/users.go@@ -10,9 +10,14 @@ import (func Users(app *app.App, router *gin.RouterGroup) {usr := router.Group("/users")+ usrCtrl := controllers.NewController(app)+usr.Use(middlewares.Auth())- usrCtrl := controllers.NewController(app)usr.GET("/", middlewares.Admin(), usrCtrl.GetUsers)-+ usr.GET("/@me", usrCtrl.GetMe)+ usr.GET("/:id", middlewares.Admin(), usrCtrl.GetUserById)+ usr.POST("/", usrCtrl.CreateUser)+ usr.PATCH("/:id", usrCtrl.UpdateUser)+ usr.PATCH("/:id/password", usrCtrl.UpdatePassword)}diff --git a/backend/utils/constants.go b/backend/utils/constants.gonew file mode 100644index 00000000..6783b8a6--- /dev/null+++ b/backend/utils/constants.go@@ -0,0 +1,8 @@+package utils++import "github.com/golang-jwt/jwt/v5"++type AuthClaims struct {+ Role string `json:"role"`+ jwt.RegisteredClaims+}diff --git a/backend/utils/responses.go b/backend/utils/responses.goindex ca89df60..59b1940e 100644--- a/backend/utils/responses.go+++ b/backend/utils/responses.go@@ -9,15 +9,15 @@ import (func Success(data any) gin.H {return gin.H{"status": "success",- "result": data,"timestamp": time.Now().UnixMilli(),+ "result": data,}}func Error(message string) gin.H {return gin.H{"status": "error",- "message": message,"timestamp": time.Now().UnixMilli(),+ "message": message,}}