diff --git a/.env b/.env
deleted file mode 100644
index a0c431e..0000000
--- a/.env
+++ /dev/null
@@ -1,22 +0,0 @@
-SERVER_HOST=0.0.0.0
-SERVER_PORT=8000
-
-DOMAIN=filekeeper.fossy.my.id
-
-CORS_PROTO=https
-CORS_LIST=filekeeper.fossy.my.id:443,fossy.my.id:443
-CORS_METHODS=POST,GET
-
-DB_HOST=
-DB_PORT=
-DB_USERNAME=
-DB_PASSWORD=
-DB_NAME=filekeeper
-
-SMTP_HOST=
-SMTP_PORT=
-SMTP_USER=
-SMTP_PASSWORD=
-
-SESSION_NAME=Session
-SESSION_MAX_AGE=604800
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 13566b8..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/filekeeper.iml b/.idea/filekeeper.iml
deleted file mode 100644
index 5e764c4..0000000
--- a/.idea/filekeeper.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index eefade7..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 33fcc00..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/db/database.go b/db/database.go
index 8123f2e..86510e1 100644
--- a/db/database.go
+++ b/db/database.go
@@ -2,14 +2,14 @@ package db
import (
"fmt"
+ "os"
+ "strings"
+
"github.com/fossyy/filekeeper/logger"
"github.com/fossyy/filekeeper/utils"
"gorm.io/driver/mysql"
- _ "gorm.io/driver/mysql"
"gorm.io/gorm"
gormLogger "gorm.io/gorm/logger"
- "os"
- "strings"
)
var DB *gorm.DB
@@ -23,11 +23,11 @@ func init() {
Logger: gormLogger.Default.LogMode(gormLogger.Silent),
})
if err != nil {
- panic("failed to connect database")
+ panic("failed to connect database" + err.Error())
}
file, err := os.ReadFile("schema.sql")
if err != nil {
- log.Error("Error opening file: %v", err)
+ log.Error("Error opening file: %s", err.Error())
}
querys := strings.Split(string(file), "\n")
for _, query := range querys {
diff --git a/db/model/user/user.go b/db/model/user/user.go
index bd2240c..6d72a1f 100644
--- a/db/model/user/user.go
+++ b/db/model/user/user.go
@@ -2,11 +2,12 @@ package user
import (
"fmt"
+ "sync"
+ "time"
+
"github.com/fossyy/filekeeper/db"
"github.com/fossyy/filekeeper/logger"
"github.com/google/uuid"
- "sync"
- "time"
)
type Cache struct {
diff --git a/handler/download/download.go b/handler/download/download.go
index c612e5b..f53ec36 100644
--- a/handler/download/download.go
+++ b/handler/download/download.go
@@ -2,6 +2,8 @@ package downloadHandler
import (
"errors"
+ "net/http"
+
"github.com/fossyy/filekeeper/db"
"github.com/fossyy/filekeeper/logger"
"github.com/fossyy/filekeeper/middleware"
@@ -10,7 +12,6 @@ import (
"github.com/fossyy/filekeeper/types/models"
"github.com/fossyy/filekeeper/utils"
downloadView "github.com/fossyy/filekeeper/view/download"
- "net/http"
)
var log *logger.AggregatedLogger
diff --git a/handler/download/file/file.go b/handler/download/file/file.go
index 29c4464..f258c44 100644
--- a/handler/download/file/file.go
+++ b/handler/download/file/file.go
@@ -1,12 +1,13 @@
package downloadFileHandler
import (
- "github.com/fossyy/filekeeper/db"
- "github.com/fossyy/filekeeper/logger"
- "github.com/fossyy/filekeeper/types/models"
"net/http"
"os"
"path/filepath"
+
+ "github.com/fossyy/filekeeper/db"
+ "github.com/fossyy/filekeeper/logger"
+ "github.com/fossyy/filekeeper/types/models"
)
var log *logger.AggregatedLogger
diff --git a/handler/error/error.go b/handler/error/error.go
index 447a384..7cb4c4e 100644
--- a/handler/error/error.go
+++ b/handler/error/error.go
@@ -1,9 +1,10 @@
package errorHandler
import (
+ "net/http"
+
"github.com/fossyy/filekeeper/logger"
errorView "github.com/fossyy/filekeeper/view/error"
- "net/http"
)
var log *logger.AggregatedLogger
diff --git a/handler/forgotPassword/forgotPassword.go b/handler/forgotPassword/forgotPassword.go
index 0b5fb77..f11c233 100644
--- a/handler/forgotPassword/forgotPassword.go
+++ b/handler/forgotPassword/forgotPassword.go
@@ -5,6 +5,11 @@ import (
"context"
"errors"
"fmt"
+ "net/http"
+ "strconv"
+ "sync"
+ "time"
+
"github.com/fossyy/filekeeper/db"
"github.com/fossyy/filekeeper/email"
"github.com/fossyy/filekeeper/logger"
@@ -14,10 +19,6 @@ import (
emailView "github.com/fossyy/filekeeper/view/email"
forgotPasswordView "github.com/fossyy/filekeeper/view/forgotPassword"
"gorm.io/gorm"
- "net/http"
- "strconv"
- "sync"
- "time"
)
type ForgotPassword struct {
diff --git a/handler/index/index.go b/handler/index/index.go
index bc17bb8..f1838bd 100644
--- a/handler/index/index.go
+++ b/handler/index/index.go
@@ -1,9 +1,10 @@
package indexHandler
import (
- "github.com/fossyy/filekeeper/logger"
- "github.com/fossyy/filekeeper/view/index"
"net/http"
+
+ "github.com/fossyy/filekeeper/logger"
+ indexView "github.com/fossyy/filekeeper/view/index"
)
var log *logger.AggregatedLogger
diff --git a/handler/logout/logout.go b/handler/logout/logout.go
index 4eda278..181310e 100644
--- a/handler/logout/logout.go
+++ b/handler/logout/logout.go
@@ -2,11 +2,12 @@ package logoutHandler
import (
"errors"
+ "net/http"
+
"github.com/fossyy/filekeeper/logger"
"github.com/fossyy/filekeeper/session"
"github.com/fossyy/filekeeper/types"
"github.com/fossyy/filekeeper/utils"
- "net/http"
)
var log *logger.AggregatedLogger
diff --git a/handler/misc/misc.go b/handler/misc/misc.go
index 5992897..a4d6241 100644
--- a/handler/misc/misc.go
+++ b/handler/misc/misc.go
@@ -9,17 +9,5 @@ func Robot(w http.ResponseWriter, r *http.Request) {
}
func Favicon(w http.ResponseWriter, r *http.Request) {
- //currentDir, _ := os.Getwd()
- //fmt.Println(currentDir)
- //logo := "../../../favicon.ico"
- //basePath := filepath.Join(currentDir, "public")
- //logoPath := filepath.Join(basePath, logo)
- //fmt.Println(filepath.Dir(logoPath))
- //if filepath.Dir(logoPath) != basePath {
- // log.Print("invalid logo path", logoPath)
- // w.WriteHeader(500)
- // return
- //}
- //http.ServeContent()
http.Redirect(w, r, "/public/favicon.ico", http.StatusSeeOther)
}
diff --git a/handler/signin/signin.go b/handler/signin/signin.go
index c6d52e4..ae932f0 100644
--- a/handler/signin/signin.go
+++ b/handler/signin/signin.go
@@ -2,14 +2,15 @@ package signinHandler
import (
"errors"
+ "net/http"
+ "strings"
+
"github.com/fossyy/filekeeper/db/model/user"
"github.com/fossyy/filekeeper/logger"
"github.com/fossyy/filekeeper/session"
"github.com/fossyy/filekeeper/types"
"github.com/fossyy/filekeeper/utils"
signinView "github.com/fossyy/filekeeper/view/signin"
- "net/http"
- "strings"
)
var log *logger.AggregatedLogger
diff --git a/handler/signup/signup.go b/handler/signup/signup.go
index 3229cd8..ade664f 100644
--- a/handler/signup/signup.go
+++ b/handler/signup/signup.go
@@ -5,6 +5,11 @@ import (
"context"
"errors"
"fmt"
+ "net/http"
+ "strconv"
+ "sync"
+ "time"
+
"github.com/fossyy/filekeeper/db"
"github.com/fossyy/filekeeper/email"
"github.com/fossyy/filekeeper/logger"
@@ -15,10 +20,6 @@ import (
signupView "github.com/fossyy/filekeeper/view/signup"
"github.com/google/uuid"
"gorm.io/gorm"
- "net/http"
- "strconv"
- "sync"
- "time"
)
type UnverifiedUser struct {
diff --git a/handler/signup/verify/verify.go b/handler/signup/verify/verify.go
index b5f3d30..01d0af2 100644
--- a/handler/signup/verify/verify.go
+++ b/handler/signup/verify/verify.go
@@ -1,12 +1,13 @@
package signupVerifyHandler
import (
+ "net/http"
+
"github.com/fossyy/filekeeper/db"
signupHandler "github.com/fossyy/filekeeper/handler/signup"
"github.com/fossyy/filekeeper/logger"
"github.com/fossyy/filekeeper/types"
signupView "github.com/fossyy/filekeeper/view/signup"
- "net/http"
)
var log *logger.AggregatedLogger
diff --git a/handler/upload/initialisation/initialisation.go b/handler/upload/initialisation/initialisation.go
index a5026f1..91d6ac6 100644
--- a/handler/upload/initialisation/initialisation.go
+++ b/handler/upload/initialisation/initialisation.go
@@ -3,6 +3,11 @@ package initialisation
import (
"encoding/json"
"errors"
+ "io"
+ "net/http"
+ "os"
+ "path/filepath"
+
"github.com/fossyy/filekeeper/db"
"github.com/fossyy/filekeeper/logger"
"github.com/fossyy/filekeeper/middleware"
@@ -11,10 +16,6 @@ import (
"github.com/fossyy/filekeeper/types/models"
"github.com/google/uuid"
"gorm.io/gorm"
- "io"
- "net/http"
- "os"
- "path/filepath"
)
var log *logger.AggregatedLogger
diff --git a/handler/upload/upload.go b/handler/upload/upload.go
index 83f6003..644adea 100644
--- a/handler/upload/upload.go
+++ b/handler/upload/upload.go
@@ -2,18 +2,19 @@ package uploadHandler
import (
"errors"
- "github.com/fossyy/filekeeper/db"
- "github.com/fossyy/filekeeper/handler/upload/initialisation"
- "github.com/fossyy/filekeeper/logger"
- "github.com/fossyy/filekeeper/middleware"
- "github.com/fossyy/filekeeper/session"
- filesView "github.com/fossyy/filekeeper/view/upload"
"io"
"net/http"
"os"
"path/filepath"
"strconv"
"sync"
+
+ "github.com/fossyy/filekeeper/db"
+ "github.com/fossyy/filekeeper/handler/upload/initialisation"
+ "github.com/fossyy/filekeeper/logger"
+ "github.com/fossyy/filekeeper/middleware"
+ "github.com/fossyy/filekeeper/session"
+ filesView "github.com/fossyy/filekeeper/view/upload"
)
var log *logger.AggregatedLogger
diff --git a/handler/user/user.go b/handler/user/user.go
index 07ad7f7..82c376e 100644
--- a/handler/user/user.go
+++ b/handler/user/user.go
@@ -2,11 +2,12 @@ package userHandler
import (
"errors"
+ "net/http"
+
"github.com/fossyy/filekeeper/logger"
"github.com/fossyy/filekeeper/middleware"
"github.com/fossyy/filekeeper/session"
userView "github.com/fossyy/filekeeper/view/user"
- "net/http"
)
var log *logger.AggregatedLogger
diff --git a/main.go b/main.go
index f674f0c..4d81e3d 100644
--- a/main.go
+++ b/main.go
@@ -2,10 +2,11 @@ package main
import (
"fmt"
+ "net/http"
+
"github.com/fossyy/filekeeper/middleware"
"github.com/fossyy/filekeeper/routes"
"github.com/fossyy/filekeeper/utils"
- "net/http"
)
func main() {
diff --git a/middleware/middleware.go b/middleware/middleware.go
index dde1de0..fbcb4d8 100644
--- a/middleware/middleware.go
+++ b/middleware/middleware.go
@@ -3,13 +3,14 @@ package middleware
import (
"errors"
"fmt"
+ "net/http"
+ "strings"
+
errorHandler "github.com/fossyy/filekeeper/handler/error"
"github.com/fossyy/filekeeper/logger"
"github.com/fossyy/filekeeper/session"
"github.com/fossyy/filekeeper/types"
"github.com/fossyy/filekeeper/utils"
- "net/http"
- "strings"
)
var log *logger.AggregatedLogger
diff --git a/routes/routes.go b/routes/routes.go
index 4c5646c..0b9b1ab 100644
--- a/routes/routes.go
+++ b/routes/routes.go
@@ -1,6 +1,8 @@
package routes
import (
+ "net/http"
+
downloadHandler "github.com/fossyy/filekeeper/handler/download"
downloadFileHandler "github.com/fossyy/filekeeper/handler/download/file"
forgotPasswordHandler "github.com/fossyy/filekeeper/handler/forgotPassword"
@@ -15,7 +17,6 @@ import (
"github.com/fossyy/filekeeper/handler/upload/initialisation"
userHandler "github.com/fossyy/filekeeper/handler/user"
"github.com/fossyy/filekeeper/middleware"
- "net/http"
)
func SetupRoutes() *http.ServeMux {
diff --git a/session/session.go b/session/session.go
index 47a62fe..5f37fbe 100644
--- a/session/session.go
+++ b/session/session.go
@@ -1,11 +1,12 @@
package session
import (
- "github.com/fossyy/filekeeper/utils"
"net/http"
"strconv"
"sync"
"time"
+
+ "github.com/fossyy/filekeeper/utils"
)
type Session struct {
diff --git a/utils/utils.go b/utils/utils.go
index 90213ae..fdd905b 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -2,9 +2,6 @@ package utils
import (
"fmt"
- "github.com/fossyy/filekeeper/logger"
- "github.com/joho/godotenv"
- "golang.org/x/crypto/bcrypt"
"math/rand"
"net/http"
"os"
@@ -12,6 +9,10 @@ import (
"sync"
"time"
"unicode"
+
+ "github.com/fossyy/filekeeper/logger"
+ "github.com/joho/godotenv"
+ "golang.org/x/crypto/bcrypt"
)
type Env struct {