superkit/README.md

115 lines
2.7 KiB
Markdown
Raw Normal View History

2024-06-06 11:51:22 +02:00
# GOTHKIT
2024-06-09 11:16:23 +02:00
Create interactive applications with Golang, HTMX, and Templ
2024-06-06 11:51:22 +02:00
2024-06-11 21:00:48 +02:00
> The project (for now) is in the **experimental** phase.
2024-06-09 11:16:23 +02:00
## Table of content
- [GOTHKIT](#gothkit)
- [Table of content](#table-of-content)
- [Installation](#installation)
- [Getting started](#getting-started)
2024-06-09 11:31:59 +02:00
- [Application structure](#application-structure)
- [assets](#assets)
- [conf](#conf)
- [db](#db)
- [events](#events)
- [handlers](#handlers)
- [types](#types)
- [views](#views)
2024-06-09 11:16:23 +02:00
- [Development server](#development-server)
- [Hot reloading the browser](#hot-reloading-the-browser)
- [Migrations](#migrations)
- [Create a new migration](#create-a-new-migration)
- [Migrate the database](#migrate-the-database)
- [Reset the database](#reset-the-database)
- [Seeds](#seeds)
2024-06-11 21:12:12 +02:00
- [Creating views with Templ](#creating-views-with-templ)
2024-06-09 20:49:31 +02:00
- [Validations](#validations)
2024-06-09 11:16:23 +02:00
- [Testing](#testing)
- [Testing handlers](#testing-handlers)
2024-06-09 11:31:59 +02:00
- [Create a production release](#create-a-production-release)
2024-06-06 16:53:16 +02:00
2024-06-06 11:51:22 +02:00
# Installation
```
go install github.com/anthdm/gothkit@master
```
After installation you can create a new project by running:
```
gothkit [myprojectname]
2024-06-07 09:24:46 +02:00
```
2024-06-09 11:16:23 +02:00
You can now navigate to your project:
2024-06-07 11:26:58 +02:00
```
cd [myprojectname]
```
2024-06-07 09:24:46 +02:00
# Getting started
2024-06-09 11:31:59 +02:00
## Application structure
### assets
### conf
### db
### events
### handlers
### types
### views
2024-06-09 11:16:23 +02:00
## Development server
2024-06-11 21:12:12 +02:00
You can run the development server with the following command:
2024-06-08 11:02:51 +02:00
```
2024-06-09 11:16:23 +02:00
make dev
2024-06-08 11:02:51 +02:00
```
2024-06-09 11:16:23 +02:00
## Hot reloading the browser
Hot reloading is configured by default when running your application in development.
2024-06-11 21:12:12 +02:00
> 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.
2024-06-09 11:16:23 +02:00
# Migrations
## Create a new migration
2024-06-07 09:24:46 +02:00
```
2024-06-11 21:12:12 +02:00
make db-mig-create add_users_table
2024-06-07 09:24:46 +02:00
```
2024-06-11 21:12:12 +02:00
The command will create a new migration SQL file located at `app/db/migrations/add_users_table.sql`
2024-06-09 11:16:23 +02:00
## Migrate the database
2024-06-07 09:24:46 +02:00
```
make db-up
```
2024-06-09 11:16:23 +02:00
## Reset the database
2024-06-07 09:24:46 +02:00
```
make db-reset
```
2024-06-09 11:16:23 +02:00
## Seeds
2024-06-07 09:24:46 +02:00
```
make db-seed
```
2024-06-11 21:12:12 +02:00
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)
2024-06-07 09:24:46 +02:00
2024-06-09 20:49:31 +02:00
# Validations
2024-06-11 21:12:12 +02:00
todo
2024-06-07 09:24:46 +02:00
2024-06-09 11:16:23 +02:00
# Testing
## Testing handlers
2024-06-07 09:24:46 +02:00
2024-06-09 11:31:59 +02:00
# Create a production release
Gothkit will compile your whole application including its assets into a single binary. To build your application for production you can run the following command:
```
make build
```
2024-06-11 21:12:12 +02:00
This will create a binary file located at `/bin/app_prod`.
2024-06-09 11:31:59 +02:00
Make sure you also set the correct application environment variable in your `.env` file.
```
APP_ENV = production
```
2024-06-07 09:24:46 +02:00