diff --git a/.dockerignore b/.dockerignore index 93f1361..2d1096f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ node_modules npm-debug.log +postgres_data \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db01c79..1e17237 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ make up # Start Docker containers in the background ```` *** -Your API will be running on http://localhost:80 +Your API will be running on http://localhost/api/ -Test whether API is up at http://localhost/api/v1/healthcheck +Test whether API is up at http://localhost/api/ping *** diff --git a/cmd/main.go b/cmd/main.go index 4318fc0..9dd5163 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -8,6 +8,7 @@ import ( "github.com/gofiber/fiber/v2/middleware/logger" config "github.com/CodeChefVIT/cookoff-backend/config" + "github.com/CodeChefVIT/cookoff-backend/internal/database" ) func main() { @@ -18,8 +19,8 @@ func main() { log.Fatalln("Failed to load environment variables! \n", err.Error()) } - // database.ConnectDB(&config) - //database.RunMigrations(database.DB) + database.ConnectDB(&config) + database.RunMigrations(database.DB) app.Use(logger.New()) @@ -29,15 +30,12 @@ func main() { AllowMethods: "GET, POST, PATCH, DELETE", AllowCredentials: true, })) - - apiGroup := app.Group("/v1") - // routes.AuthRoutes(apiGroup) - apiGroup.Get("/healthcheck", func(c *fiber.Ctx) error { + app.Get("/ping", func(c *fiber.Ctx) error { return c.Status(200).JSON(fiber.Map{ - "status": "success", - "message": "icETITE-24 Backend API is up and running.", + "message": "pong", + "status": "Backend up and running", }) }) diff --git a/go.mod b/go.mod index 4a16bd3..c0b7f19 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,44 @@ module github.com/CodeChefVIT/cookoff-backend go 1.21.1 + +require ( + github.com/gofiber/fiber/v2 v2.49.2 + github.com/spf13/viper v1.16.0 + github.com/uptrace/bun v1.1.16 + github.com/uptrace/bun/dialect/pgdialect v1.1.16 + github.com/uptrace/bun/driver/pgdriver v1.1.16 +) + +require ( + github.com/andybalholm/brotli v1.0.5 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/klauspost/compress v1.16.7 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/rivo/uniseg v0.2.0 // indirect + github.com/spf13/afero v1.9.5 // indirect + github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.4.2 // indirect + github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.49.0 // indirect + github.com/valyala/tcplisten v1.0.0 // indirect + github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + golang.org/x/crypto v0.13.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + mellium.im/sasl v0.3.1 // indirect +) diff --git a/internal/database/db.go b/internal/database/db.go index c960838..f1e5fc1 100644 --- a/internal/database/db.go +++ b/internal/database/db.go @@ -22,4 +22,6 @@ func ConnectDB(config *config.Config) { log.Fatal("Could not connect to databse") log.Printf("DSN = %s", dsn) } + + log.Println("Connection to database successful") }