summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorGrailFinder <wohilas@gmail.com>2024-04-07 09:53:04 +0300
committerGrailFinder <wohilas@gmail.com>2024-04-07 09:53:04 +0300
commit4a42a4465c8ff5496229f8883b9d1532bf7c9cab (patch)
treee0cbccdfe6a770cbbdecee2e2176ee697997229e /cmd
parentb662265234d70d648a7adce74f3d9cc245456d3a (diff)
Feat: db connection and migrations
Diffstat (limited to 'cmd')
-rw-r--r--cmd/start.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/cmd/start.go b/cmd/start.go
index 00872aa..a1f051c 100644
--- a/cmd/start.go
+++ b/cmd/start.go
@@ -1,9 +1,10 @@
package cmd
import (
- "os"
"apjournal/config"
+ database "apjournal/internal/database/sql"
"apjournal/internal/server"
+ "os"
"log/slog"
@@ -28,8 +29,11 @@ var startCmd = &cobra.Command{
"path", viper.ConfigFileUsed())
}
cfg := config.LoadConfig(viper.GetViper())
-
- srv := server.NewServer(cfg, log)
+ db, err := database.InitWithMigrate(cfg.DBURI, true)
+ if err != nil {
+ panic(err)
+ }
+ srv := server.NewServer(cfg, log, db.Conn)
// listen for new messages
log.Info("Listening for incoming events")
srv.Listen()