diff --git a/README.md b/README.md index ac8ea4b..ccc2749 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,15 @@ Website: [https://deizisauer-waschweiber.de/](https://deizisauer-waschweiber.de/) +## Setting up a development environment +* Install docker and docker-compose +* Run the docker-compose development file +```shell script +sudo docker-compose -f docker-compose_dev.yml up -d +``` +This will start pgadmin on port `8084` and a postgres-db on port `8081` +* Run the program `trikotwaschliste` to execute the database migrations. + ## Building ```sh diff --git a/docker-compose_dev.yml b/docker-compose_dev.yml index 5fc6de1..5ea1e95 100644 --- a/docker-compose_dev.yml +++ b/docker-compose_dev.yml @@ -6,7 +6,6 @@ services: environment: PGADMIN_DEFAULT_EMAIL: test@schoff.it PGADMIN_DEFAULT_PASSWORD: example - restart: always ports: - "8084:80" volumes: @@ -48,7 +47,6 @@ services: postgres-db: image: postgres:11.6 - restart: always ports: - "8081:5432" environment: diff --git a/main.go b/main.go index 9854e1e..242de56 100644 --- a/main.go +++ b/main.go @@ -14,8 +14,6 @@ import ( ) func main() { - fmt.Println("Hallo") - //gin.SetMode(gin.ReleaseMode) r := gin.Default() var err error @@ -33,7 +31,7 @@ func main() { r.Static("/static", "html/static") //r.StaticFile("/favicon.ico", "html/favicon.ico") //routes.RoutesInit(r, pool) - routes.RoutesInit(r, pool) + routes.RoutesInit(r, pool, &cfg) err = r.Run("0.0.0.0:8082") diff --git a/models/config_model.go b/models/config_model.go index 71a41e5..a1ede38 100644 --- a/models/config_model.go +++ b/models/config_model.go @@ -12,4 +12,7 @@ type Config struct { DB_DATABASE string `env:"DB_DATABASE" envDefault:"web"` DB_MAXCONNECTIONS uint `env:"DB_MAXCONNECTIONS" envDefault:"5"` + ADMIN_NAME string `env:"ADMIN_NAME" envDefault:"test"` + ADMIN_PASSWORD string `env:"ADMIN_PASSWORD" envDefault:"example"` + } diff --git a/routes/routes.go b/routes/routes.go index 9289d76..33e11cc 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -4,12 +4,21 @@ import ( "github.com/gin-gonic/gin" "github.com/jackc/pgx/v4/pgxpool" "trikotwaschliste/handler" + "trikotwaschliste/models" ) -func RoutesInit(router *gin.Engine, pool *pgxpool.Pool) { +func RoutesInit(router *gin.Engine, pool *pgxpool.Pool, config *models.Config) { router.GET("/", handler.MainPage(pool)) router.GET("/credits", handler.Credits()) router.POST("/uploadname", handler.UploadName(pool)) router.GET("/persons", handler.ShowPersonsList(pool)) + + // Basic auth accounts + //authorized := router.Group("/admin", gin.BasicAuth(gin.Accounts{ + //})) + + // Basic auth routes + + } diff --git a/web.env.example b/web.env.example index 6de33c9..4bbb988 100644 --- a/web.env.example +++ b/web.env.example @@ -4,3 +4,6 @@ DB_USER=web DB_PASSWORD=example DB_DATABASE=web DB_MAXCONNECTIONS=5 + +ADMIN_NAME=test +ADMIN_PASSWORD=example \ No newline at end of file