Skip to content

Commit 647e783

Browse files
author
Roman Rudakov
committed
Add API endpoint for getting last featured articles (resolve #7)
1 parent 7271bb6 commit 647e783

File tree

2 files changed

+129
-101
lines changed

2 files changed

+129
-101
lines changed

src/education/http/endpoints/articles.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@
8484
(not-found {:message not-found-error-message})
8585
(ok (to-short-article-response mf-article)))))
8686

87+
(defn- get-last-featured-articles-handler
88+
"Get last featured articles handler."
89+
[db limit]
90+
(->> (articlesdb/get-last-featured-articles db limit)
91+
(map to-short-article-response)
92+
ok))
93+
8794
(defn- delete-article-handler
8895
"Delete article by `article-id` handler."
8996
[db article-id]
@@ -135,6 +142,11 @@
135142
:return ::specs/article-short
136143
:summary "Get main featured article"
137144
(get-last-main-featured-article-handler db))
145+
(GET "/articles/featured/latest" []
146+
:return ::specs/articles-short
147+
:query-params [limit :- ::specs/limit]
148+
:summary "Get latest featured articles list"
149+
(get-last-featured-articles-handler db limit))
138150
(DELETE "/articles/:id" []
139151
:middleware [[require-roles #{:moderator}]]
140152
:path-params [id :- ::specs/id]

0 commit comments

Comments
 (0)