changed app_env to superkit_env

This commit is contained in:
anthgg 2024-06-15 17:34:19 +02:00
parent d74e729d7c
commit bda320d452
4 changed files with 19 additions and 15 deletions

View file

@ -30,13 +30,9 @@ Create interactive applications with Golang, HTMX, and Templ
- [Create a production release](#create-a-production-release)
# Installation
Install SUPERKIT in a single command:
```
go install github.com/anthdm/gothkit@master
```
After installation you can create a new project by running:
```
gothkit [myprojectname]
go run github.com/anthdm/gothkit@master [yourprojectname]
```
You can now navigate to your project:
@ -44,6 +40,11 @@ You can now navigate to your project:
cd [myprojectname]
```
Run npm install
```
npm install
```
# Getting started
## Application structure
### assets
@ -108,7 +109,6 @@ 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.
```
APP_ENV = production
SUPERKIT_ENV = production
```

View file

@ -1,6 +1,6 @@
# Application environment
# production or development
APP_ENV = development
SUPERKIT_ENV = development
# HTTP listen port of the application
HTTP_LISTEN_ADDR = :3000

View file

@ -0,0 +1,4 @@
(() => {
// app/assets/index.js
console.log("if you like superkit consider given it a star on GitHub.");
})();

View file

@ -144,26 +144,26 @@ func Getenv(name string, def string) string {
}
func IsDevelopment() bool {
return os.Getenv("APP_ENV") == "development"
return os.Getenv("SUPERKIT_ENV") == "development"
}
func IsProduction() bool {
return os.Getenv("APP_ENV") == "production"
return os.Getenv("SUPERKIT_ENV") == "production"
}
func Env() string {
return os.Getenv("APP_ENV")
return os.Getenv("SUPERKIT_ENV")
}
// initialize the store here so the environment variables are
// already initialized. Calling NewCookieStore() from outside of
// a function scope won't work.
func init() {
appSecret := os.Getenv("APP_SECRET")
appSecret := os.Getenv("SUPERKIT_SECRET")
if len(appSecret) < 32 {
// For security reasons we are calling os.Exit(1) here so Go's panic recover won't
// recover the application without a valid APP_SECRET set.
fmt.Println("invalid APP_SECRET variable. Are you sure you have set the APP_SECRET in your .env file?")
// recover the application without a valid SUPERKIT_SECRET set.
fmt.Println("invalid SUPERKIT_SECRET variable. Are you sure you have set the SUPERKIT_SECRET in your .env file?")
os.Exit(1)
}
store = sessions.NewCookieStore([]byte(appSecret))