Skip to content

Commit

Permalink
feat: improve paste retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
httpjamesm committed Dec 7, 2023
1 parent 913186d commit be23df2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
44 changes: 44 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ./src/cmd"
delay = 0
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[screen]
clear_on_rebuild = false
keep_scroll = true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/logs
.env
docker-compose.yml
*.db
*.db
/tmp
2 changes: 1 addition & 1 deletion src/controllers/paste.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ func (ctrl *PasteController) GetPaste(c *gin.Context) {
c.JSON(200, types.GenericResponseBody{
Success: true,
Message: "Paste was found",
Data: paste.PasteRequestBody,
Data: paste,
})
}
8 changes: 4 additions & 4 deletions src/models/paste.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
)

type Paste struct {
ID string `gorm:"primaryKey,uniqueIndex"`
ID string `gorm:"primaryKey,uniqueIndex" json:"id"`

PasteRequestBody types.PasteRequestBody `gorm:"embedded"`
types.PasteRequestBody `gorm:"embedded" json:",inline"`

CreatedAt time.Time
ExpiresAt time.Time
CreatedAt time.Time `json:"-"`
ExpiresAt time.Time `json:"expiresAt"`
}
2 changes: 1 addition & 1 deletion src/types/paste.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ type PasteRequestBody struct {
OneView bool `json:"oneView"`

// gorm ignore
ExpiresInSeconds int `gorm:"-" json:"expiresInSeconds" binding:"required"`
ExpiresInSeconds int `gorm:"-" json:"expiresInSeconds,omitempty" binding:"required"`
}

0 comments on commit be23df2

Please sign in to comment.