aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Serrahima <dev@vylion.com>2026-03-21 03:17:46 +0100
committerGuillermo Serrahima <dev@vylion.com>2026-03-21 03:17:46 +0100
commit75f6db76bdbf8846b58d86951e0bebf8bd4b8a3a (patch)
tree3094f6fef1ad34b4b29243e8788342aeb2ba5775
parent6c0d1e1419fedf52477f0bed618d7b08a3ff4cd9 (diff)
downloadllostre-75f6db76bdbf8846b58d86951e0bebf8bd4b8a3a.tar.xz
llostre-75f6db76bdbf8846b58d86951e0bebf8bd4b8a3a.zip
sorted posts chronologically
-rw-r--r--backend/main.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/backend/main.go b/backend/main.go
index c7a463e..eb6d70b 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"os"
+ "sort"
"strings"
"sync"
"time"
@@ -311,6 +312,10 @@ func postsHandler(w http.ResponseWriter, r *http.Request) {
return
}
+ sort.Slice(posts, func(i, j int) bool {
+ return posts[i].CreatedAt.After(posts[j].CreatedAt)
+ })
+
logger.Debug("successfully fetched posts", "number", len(posts))
w.Header().Set("Access-Control-Allow-Origin", "*")