aboutsummaryrefslogtreecommitdiff
path: root/internal/model/api_key.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <f@miniflux.net> 2023-08-10 19:46:45 -0700
committerGravatar Frédéric Guillot <f@miniflux.net> 2023-08-10 20:29:34 -0700
commit168a870c025bfef6efdeb46e166e79a16093c157 (patch)
tree4d8ab69c7e3ef03a7ade06e7b5e5053429a64c3b /internal/model/api_key.go
parentc2349032552891745cbbc3d2a9e772845a0239f4 (diff)
downloadv2-168a870c025bfef6efdeb46e166e79a16093c157.tar.gz
v2-168a870c025bfef6efdeb46e166e79a16093c157.tar.zst
v2-168a870c025bfef6efdeb46e166e79a16093c157.zip
Move internal packages to an internal folder
For reference: https://go.dev/doc/go1.4#internalpackages
Diffstat (limited to 'internal/model/api_key.go')
-rw-r--r--internal/model/api_key.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/model/api_key.go b/internal/model/api_key.go
new file mode 100644
index 00000000..c623c9b8
--- /dev/null
+++ b/internal/model/api_key.go
@@ -0,0 +1,32 @@
+// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+// SPDX-License-Identifier: Apache-2.0
+
+package model // import "miniflux.app/v2/internal/model"
+
+import (
+ "time"
+
+ "miniflux.app/v2/internal/crypto"
+)
+
+// APIKey represents an application API key.
+type APIKey struct {
+ ID int64
+ UserID int64
+ Token string
+ Description string
+ LastUsedAt *time.Time
+ CreatedAt time.Time
+}
+
+// NewAPIKey initializes a new APIKey.
+func NewAPIKey(userID int64, description string) *APIKey {
+ return &APIKey{
+ UserID: userID,
+ Token: crypto.GenerateRandomString(32),
+ Description: description,
+ }
+}
+
+// APIKeys represents a collection of API Key.
+type APIKeys []*APIKey