create working test endpoint

This commit is contained in:
katefort 2025-04-17 15:54:33 -05:00
parent 560a3dbc4b
commit c1930d6821
11 changed files with 134 additions and 66 deletions

View file

@ -1,11 +1,11 @@
package main
package database
import (
"context"
"fmt"
"log"
"os"
"github.com/sirupsen/logrus"
"github.com/vingarcia/ksql"
"github.com/vingarcia/ksql/adapters/kpgx"
)
@ -16,24 +16,8 @@ var UserClaimsTable = ksql.NewTable("user_claims", "user_claim_id")
var AutomatedClaimsTable = ksql.NewTable("automated_claims", "automated_claim_id")
// log is the global error logging interface.
var log *logrus.Logger
func main() {
setupLogger()
// Do we want to handle the error here instead?
db := initializeDatabase()
}
func setupLogger() {
log = logrus.New()
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true, // Include the full timestamp (with date and time)
})
}
// initializeDatabase creates the database and then calls createTables.
func initializeDatabase() ksql.DB {
// initializeDatabase creates the database and calls createTables.
func InitializeDatabase() *ksql.DB {
ctx := context.Background()
// urlExample := "postgres://username:password@localhost:5432/database_name"
@ -46,8 +30,8 @@ func initializeDatabase() ksql.DB {
if err != nil {
log.Fatalf("Unable to connect to database: %v\n", err)
}
createTables(ctx, db)
return &db
}
// createTables adds the product, automated_claims, and user_claims tables to the initialized database.

View file

@ -1,4 +1,4 @@
package main
package database
import (
"time"