feat: readme

This commit is contained in:
2025-05-14 04:15:58 -04:00
parent bce4d598fb
commit 634bff4411
7 changed files with 110 additions and 30 deletions

View File

@ -1,16 +0,0 @@
wipe: true
replacements:
- match:
db_type: "INTEGER"
replace: "int64"
- match:
db_type: "INTEGER"
nullable: true
replace: "int64"
sql:
dialect: sqlite
dir: db
output: internal/models

View File

@ -29,6 +29,8 @@ import (
)
func main() {
name := "TrevStack"
// Get env
env, err := getEnv()
if err != nil {
@ -49,7 +51,7 @@ func main() {
// Create webauthn
webAuthn, err := webauthn.New(&webauthn.Config{
RPDisplayName: env.Name,
RPDisplayName: name,
RPID: env.URL.Hostname(),
RPOrigins: []string{env.URL.String()},
})
@ -63,9 +65,9 @@ func main() {
log.Fatalf("failed to create validator: %s", err.Error())
}
// Serve GRPC Handlers
// Serve gRPC Handlers
api := http.NewServeMux()
api.Handle(interceptors.WithCORS(user.NewAuthHandler(vi, sqlc, webAuthn, env.Name, env.Key)))
api.Handle(interceptors.WithCORS(user.NewAuthHandler(vi, sqlc, webAuthn, name, env.Key)))
api.Handle(interceptors.WithCORS(user.NewHandler(vi, sqlc, webAuthn, env.Key)))
api.Handle(interceptors.WithCORS(item.NewHandler(vi, sqlc, env.Key)))
@ -108,7 +110,6 @@ func main() {
type env struct {
Port string
Key string
Name string
URL *url.URL
DatabaseURL string
}
@ -123,7 +124,6 @@ func getEnv() (*env, error) {
env := env{
Port: os.Getenv("PORT"),
Key: os.Getenv("KEY"),
Name: os.Getenv("NAME"),
DatabaseURL: os.Getenv("DATABASE_URL"),
}
@ -135,10 +135,6 @@ func getEnv() (*env, error) {
if env.Key == "" {
return nil, errors.New("env 'KEY' not found")
}
if env.Name == "" {
env.Name = "trevstack"
log.Printf("env 'NAME' not found, defaulting to %s\n", env.Name)
}
if env.DatabaseURL == "" {
return nil, errors.New("env 'DATABASE_URL' not found")
}