Skip to content

Commit

Permalink
fix: api creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspeen committed Jun 10, 2024
1 parent 14eb9aa commit a92be34
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type Api struct {
cache *ttlcache.Cache[string, *queries.GetApiKeyForVerifyRow]
}

func (a *Api) NewApi(log *slog.Logger, db *sql.DB, config Config) (*Api, error) {
func NewApi(log *slog.Logger, db *sql.DB, config Config) (*Api, error) {
var cache *ttlcache.Cache[string, *queries.GetApiKeyForVerifyRow]
if config.CacheMaxSize > 0 {
cache = ttlcache.New(
Expand Down
13 changes: 8 additions & 5 deletions cmd/apikeyman/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ func main() {
panic(err)
}

a := api.Api{
Log: slog.Default(),
Db: db,
Config: api.Config{
a, err := api.NewApi(
slog.Default(),
db,
api.Config{
ApiKeyHeaderName: api.API_KEY_DEFAULT_HEADER,
ApiKeyQueryParamName: "apikey",
SignatureHeaderName: api.SIGNATURE_DEFAULT_HEADER,
Expand All @@ -151,7 +151,10 @@ func main() {
DefaultKeyExpiration: 30 * 24 * time.Hour,
CacheMaxSize: cCtx.Uint64("cache-max-size"),
CacheTTL: cCtx.Duration("cache-ttl"),
}}
})
if err != nil {
panic(err)
}
r := a.Routes(cCtx.String("base-path"))
return r.Run(cCtx.String("addr"))
},
Expand Down
4 changes: 2 additions & 2 deletions deploy/charts/apikeyman/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ keywords:
- security
sources:
- https://github.com/jaspeen/apikeyman
version: 0.1.10
appVersion: "0.1.8"
version: 0.1.11
appVersion: "0.1.11"

0 comments on commit a92be34

Please sign in to comment.