Adapts main.go to sqlc usage
This commit is contained in:
parent
5005186cd3
commit
c2a27a0751
2 changed files with 14 additions and 4 deletions
9
main.go
9
main.go
|
|
@ -1,8 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"freed/internal/api"
|
_ "embed"
|
||||||
"freed/internal/database"
|
"freed/api"
|
||||||
|
"freed/database"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
|
@ -18,7 +19,7 @@ func main() {
|
||||||
log.Fatalf("No ENV value set for 'DB_FILE', could not initialize database. Please provide a valid path and filename")
|
log.Fatalf("No ENV value set for 'DB_FILE', could not initialize database. Please provide a valid path and filename")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := database.Connect(dbFile)
|
repository, err := database.NewRepository(dbFile)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not initialize database: %v", err)
|
log.Fatalf("Could not initialize database: %v", err)
|
||||||
|
|
@ -30,7 +31,7 @@ func main() {
|
||||||
app.Use(logger.New())
|
app.Use(logger.New())
|
||||||
|
|
||||||
// Try to set up API routes
|
// Try to set up API routes
|
||||||
if err := api.Setup(app); err != nil {
|
if err := api.Setup(app, repository); err != nil {
|
||||||
log.Printf("Could not setup /api routes: %s", err)
|
log.Printf("Could not setup /api routes: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
9
sqlc.yaml
Normal file
9
sqlc.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
version: "2"
|
||||||
|
sql:
|
||||||
|
- engine: "sqlite"
|
||||||
|
queries: "database/queries"
|
||||||
|
schema: "database/migrations"
|
||||||
|
gen:
|
||||||
|
go:
|
||||||
|
package: "database"
|
||||||
|
out: "database"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue