Skip to content

Commit

Permalink
chore: add & remove config options
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Nov 14, 2024
1 parent 910a880 commit 715ae2a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ scc

# Log files
logs/

# DB
*.db
4 changes: 4 additions & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[server]
host = "localhost"
port = 3000

[buzzer]
song = [
"-n", "-f880", "-l100", "-d0",
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func apiCmd(db *db.DB) {
api.New(apiGroup, db)

host := config.GetDefaultString("server.host", "127.0.0.1")
port := config.GetDefaultInt("server.port", 8080)
port := config.GetDefaultInt("server.port", 3000)

zap.S().Fatal("API: Fatal server error", app.Listen(fmt.Sprintf("%s:%d", host, port)))
}
5 changes: 1 addition & 4 deletions internal/pkg/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

_ "github.com/mattn/go-sqlite3" // SQLite driver
"github.com/zeusWPI/scc/internal/pkg/db/sqlc"
"github.com/zeusWPI/scc/pkg/config"
)

// DB represents a database connection
Expand All @@ -17,9 +16,7 @@ type DB struct {

// New creates a new database connection
func New() (*DB, error) {
dbPath := config.GetDefaultString("db.path", "./sqlite.db")

db, err := sql.Open("sqlite3", dbPath)
db, err := sql.Open("sqlite3", "./sqlite.db")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ create-migration:

goose:
@read -p "Action: " action; \
goose -dir ./db/migrations postgres "user=postgres password=postgres dbname=adoca host=localhost sslmode=disable" $$action
goose -dir ./db/migrations sqlite3 ./sqlite.db $$action

migrate:
@goose -dir ./db/migrations postgres "user=postgres password=postgres dbname=adoca host=localhost sslmode=disable" up
@goose -dir ./db/migrations sqlite3 ./sqlite.db up

watch:
@if command -v air > /dev/null; then \
Expand Down

0 comments on commit 715ae2a

Please sign in to comment.