From 31728d53da4c983117c293954d2172f78882bbfb Mon Sep 17 00:00:00 2001 From: anthdm Date: Tue, 11 Jun 2024 21:12:12 +0200 Subject: [PATCH] changed db-mig to db-mig-create --- README.md | 18 ++++++++++++------ bootstrap/Makefile | 6 +++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c074a16..b217e80 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Create interactive applications with Golang, HTMX, and Templ - [Migrate the database](#migrate-the-database) - [Reset the database](#reset-the-database) - [Seeds](#seeds) +- [Creating views with Templ](#creating-views-with-templ) - [Validations](#validations) - [Testing](#testing) - [Testing handlers](#testing-handlers) @@ -54,7 +55,7 @@ cd [myprojectname] ### views ## Development server -Run the development server with the following command: +You can run the development server with the following command: ``` make dev ``` @@ -62,15 +63,15 @@ make dev ## Hot reloading the browser Hot reloading is configured by default when running your application in development. -> NOTE: on windows you might need to run `make assets` to watch for CSS and JS changes in another terminal. +> NOTE: on windows or on in my case (WSL2) you might need to run `make assets` in another terminal to watch for CSS and JS file changes. # Migrations ## Create a new migration ``` -make db-mig add_user_table +make db-mig-create add_users_table ``` -Will create a new migration SQL file inside `app/db/migrations` +The command will create a new migration SQL file located at `app/db/migrations/add_users_table.sql` ## Migrate the database ``` @@ -86,9 +87,14 @@ make db-reset ``` make db-seed ``` -This command will run the seeds file located at `cmd/scripts/seed/main.go` +This command will run the seed file located at `cmd/scripts/seed/main.go` + +# Creating views with Templ +Gothkit uses Templ as its templating engine. Templ allows you to create type safe view components that renders fragments of HTML. In-depth information about Templ can be found here: +[Templ documentation](https://templ.guide) # Validations +todo # Testing ## Testing handlers @@ -98,7 +104,7 @@ Gothkit will compile your whole application including its assets into a single b ``` make build ``` -This will create a binary file located at `/bin/app_release`. +This will create a binary file located at `/bin/app_prod`. Make sure you also set the correct application environment variable in your `.env` file. ``` diff --git a/bootstrap/Makefile b/bootstrap/Makefile index a80a509..f4dfa5d 100644 --- a/bootstrap/Makefile +++ b/bootstrap/Makefile @@ -45,8 +45,8 @@ dev: # to a single binary with all its assets embedded. build: @tailwindcss -i app/assets/app.css -o ./public/assets/styles.css - @go build -o bin/app_release cmd/app/main.go - @echo "compiled you application with all its assets to a single binary => bin/app_release" + @go build -o bin/app_prod cmd/app/main.go + @echo "compiled you application with all its assets to a single binary => bin/app_prod" db-status: @GOOSE_DRIVER=$(DB_DRIVER) GOOSE_DBSTRING=$(DB_NAME) go run github.com/pressly/goose/v3/cmd/goose@latest status @@ -60,7 +60,7 @@ db-down: db-up: @GOOSE_DRIVER=$(DB_DRIVER) GOOSE_DBSTRING=$(DB_NAME) go run github.com/pressly/goose/v3/cmd/goose@latest -dir=$(MIGRATION_DIR) up -db-mig: +db-mig-create: @GOOSE_DRIVER=$(DB_DRIVER) GOOSE_DBSTRING=$(DB_NAME) go run github.com/pressly/goose/v3/cmd/goose@latest -dir=$(MIGRATION_DIR) create $(filter-out $@,$(MAKECMDGOALS)) sql db-seed: