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
|
||||
|
||||
import (
|
||||
"freed/internal/api"
|
||||
"freed/internal/database"
|
||||
_ "embed"
|
||||
"freed/api"
|
||||
"freed/database"
|
||||
"log"
|
||||
"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")
|
||||
}
|
||||
|
||||
err := database.Connect(dbFile)
|
||||
repository, err := database.NewRepository(dbFile)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Could not initialize database: %v", err)
|
||||
|
|
@ -30,7 +31,7 @@ func main() {
|
|||
app.Use(logger.New())
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
|
|
|||
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