aboutsummaryrefslogtreecommitdiff
path: root/api/lib
diff options
context:
space:
mode:
authorZach Berwaldt <zberwaldt@tutamail.com>2024-03-06 21:53:07 -0500
committerZach Berwaldt <zberwaldt@tutamail.com>2024-03-06 21:53:07 -0500
commit5fa57845052655883120ba4d19a85d8756fb8d8c (patch)
treed2d5ad1dd3fd8d9acaca9ced09612b50218f06b0 /api/lib
parentcf2113e77edabf8e3a632c7b76c769752039ba88 (diff)
[FEAT] Refactor API main file and models
This commit refactors the `main.go` file in the API directory, as well as the related models in the `models.go` file. The changes include: - Reordering imports and removing unnecessary imports - Fixing error messages to be more descriptive - Handling database connections more efficiently with deferred closures - Handling errors and returning appropriate error responses - Adding proper JSON bindings for POST requests - Adding new views in the database scripts for aggregated statistics and daily user statistics No changes were made to imports and requires.
Diffstat (limited to 'api/lib')
-rw-r--r--api/lib/models.go41
1 files changed, 0 insertions, 41 deletions
diff --git a/api/lib/models.go b/api/lib/models.go
deleted file mode 100644
index f959519..0000000
--- a/api/lib/models.go
+++ /dev/null
@@ -1,41 +0,0 @@
1package models
2
3import (
4 "time"
5 "github.com/google/uuid"
6)
7
8type Statistic struct {
9 ID int64 `json:"-"`
10 Date time.Time `json:"date"`
11 User User `json:"user"`
12 Quantity int `json:"quantity"`
13}
14
15type User struct {
16 ID int64 `json:"-"`
17 Name string `json:"name"`
18 UUID uuid.UUID `json:"uuid"`
19 Password string `json:"-"`
20}
21
22type Token struct {
23 ID int64 `json:"-"`
24 UserID int64 `json:"user_id"`
25 Token string `json:"token"`
26 CreatedAt time.Time `json:"created_at"`
27 ExpiredAt time.Time `json:"expired_at"`
28}
29
30type Preference struct {
31 ID int64 `json:"-"`
32 Color string `json:"color"`
33 UserID int64 `json:"-"`
34 Size Size `json:"size"`
35}
36
37type Size struct {
38 ID int64 `json:"-"`
39 Size int64 `json:"size"`
40 Unit string `json:"unit"`
41}