superkit/README.md

125 lines
3 KiB
Markdown
Raw Normal View History

2024-06-16 11:57:08 +02:00
# SUPERKIT
Build high-performance apps swiftly with minimal team resources in GO.
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
2024-06-16 11:57:08 +02:00
- [SUPERKIT](#superkit)
2024-06-09 11:16:23 +02:00
- [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
2024-06-16 11:50:54 +02:00
Create your SUPERKIT project in a single command:
2024-06-06 11:51:22 +02:00
```
2024-06-16 17:59:28 +02:00
go run github.com/anthdm/superkit@master [yourprojectname]
2024-06-06 11:51:22 +02:00
```
2024-06-15 17:34:19 +02:00
You can now navigate to your project:
2024-06-06 11:51:22 +02:00
```
2024-06-15 17:34:19 +02:00
cd [myprojectname]
2024-06-07 09:24:46 +02:00
```
2024-06-16 11:50:54 +02:00
Run npm install to install both tailwindcss and esbuild locally.
2024-06-07 11:26:58 +02:00
```
2024-06-15 17:34:19 +02:00
npm install
2024-06-07 11:26:58 +02:00
```
2024-06-16 11:50:54 +02:00
If you run into dependency issues you can run:
```
go clean -modcache && go get -u ./...
```
If you have the authentication plugin enabled you need to migrate your database.
```
make db-up
```
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.
> NOTE: on windows or on in my case (WSL2) you might need to run `make watch-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
2024-06-16 17:59:28 +02:00
superkit 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:
2024-06-11 21:12:12 +02:00
[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
2024-06-16 17:59:28 +02:00
superkit will compile your whole application including its assets into a single binary. To build your application for production you can run the following command:
2024-06-09 11:31:59 +02:00
```
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.
```
2024-06-15 17:34:19 +02:00
SUPERKIT_ENV = production
2024-06-09 11:31:59 +02:00
```