Added sqlite database
This commit is contained in:
+13
-2
@@ -1,20 +1,31 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"quay/app/handlers"
|
||||
"quay/internal/config"
|
||||
"quay/internal/database"
|
||||
"quay/internal/envconfig"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func Register(app *fiber.App, cfg *config.Config, envCfg *envconfig.EnvConfig) {
|
||||
func Register(app *fiber.App, cfg *config.Config, envCfg *envconfig.EnvConfig, db *sql.DB) {
|
||||
siteRepository := database.NewSQLiteSiteRepository(db)
|
||||
|
||||
updateSiteHandler := handlers.NewUpdateSiteHandler(cfg, envCfg)
|
||||
siteHandler := handlers.NewSiteHandler(siteRepository)
|
||||
|
||||
api := app.Group("/api")
|
||||
api.Get("/health", handlers.HealthCheck)
|
||||
|
||||
api.Post("/update", handlers.NewUpdateSiteHandler(cfg, envCfg))
|
||||
api.Post("/update", updateSiteHandler.PostUpdate)
|
||||
|
||||
api.Get("/sites", siteHandler.GetSites)
|
||||
api.Get("/sites/:id", siteHandler.GetSite)
|
||||
api.Post("/sites", siteHandler.PostSite)
|
||||
|
||||
storagePath, err := filepath.Abs(envCfg.StoragePath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user