Reorganize API endpoints
This commit is contained in:
parent
fb136e656d
commit
c60db00f6d
|
@ -36,7 +36,17 @@
|
||||||
:description "commitETH API"}}}}
|
:description "commitETH API"}}}}
|
||||||
|
|
||||||
(context "/api" []
|
(context "/api" []
|
||||||
(POST "/user/address" []
|
|
||||||
|
(context "/bounties" []
|
||||||
|
(GET "/all" []
|
||||||
|
(ok (bounties-db/list-all-bounties))))
|
||||||
|
|
||||||
|
(context "/user" []
|
||||||
|
(GET "/" []
|
||||||
|
:auth-rules authenticated?
|
||||||
|
:current-user user
|
||||||
|
(ok {:user (users/get-user (:id user))}))
|
||||||
|
(POST "/address" []
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:body-params [user-id :- String, address :- String]
|
:body-params [user-id :- String, address :- String]
|
||||||
:summary "Update user address"
|
:summary "Update user address"
|
||||||
|
@ -44,22 +54,16 @@
|
||||||
(if (= 1 result)
|
(if (= 1 result)
|
||||||
(ok)
|
(ok)
|
||||||
(internal-server-error))))
|
(internal-server-error))))
|
||||||
(GET "/user" []
|
(GET "/repositories" []
|
||||||
:auth-rules authenticated?
|
|
||||||
:current-user user
|
|
||||||
(ok {:user (users/get-user (:id user))}))
|
|
||||||
(GET "/user/repositories" []
|
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:current-user user
|
:current-user user
|
||||||
(ok {:repositories (->> (github/list-repos (:token user))
|
(ok {:repositories (->> (github/list-repos (:token user))
|
||||||
(map #(select-keys %
|
(map #(select-keys %
|
||||||
[:id :html_url :name :full_name :description])))}))
|
[:id :html_url :name :full_name :description])))}))
|
||||||
(GET "/repositories" []
|
(GET "/enabled-repositories" []
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:current-user user
|
:current-user user
|
||||||
(ok (repositories/get-enabled (:id user))))
|
(ok (repositories/get-enabled (:id user))))
|
||||||
(GET "/bounties" []
|
|
||||||
(ok (bounties-db/list-all-bounties)))
|
|
||||||
(POST "/bounty/:issue{[0-9]{1,9}}/payout" {:keys [params]}
|
(POST "/bounty/:issue{[0-9]{1,9}}/payout" {:keys [params]}
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:current-user user
|
:current-user user
|
||||||
|
@ -71,7 +75,7 @@
|
||||||
(if (= 1 result)
|
(if (= 1 result)
|
||||||
(ok)
|
(ok)
|
||||||
(internal-server-error))))
|
(internal-server-error))))
|
||||||
(GET "/user/bounties" []
|
(GET "/bounties" []
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:current-user user
|
:current-user user
|
||||||
(ok (map #(conj % (let [balance (:balance %)]
|
(ok (map #(conj % (let [balance (:balance %)]
|
||||||
|
@ -97,4 +101,4 @@
|
||||||
(repositories/update-hook-id repo-id (:id created-hook))
|
(repositories/update-hook-id repo-id (:id created-hook))
|
||||||
(bounties/add-bounties-for-existing-issues result)))
|
(bounties/add-bounties-for-existing-issues result)))
|
||||||
(github/remove-webhook repo (:hook_id result) token))
|
(github/remove-webhook repo (:hook_id result) token))
|
||||||
result)))))
|
result))))))
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
(fn [{:keys [db]} [_]]
|
(fn [{:keys [db]} [_]]
|
||||||
{:db db
|
{:db db
|
||||||
:http {:method GET
|
:http {:method GET
|
||||||
:url "/api/bounties"
|
:url "/api/bounties/all"
|
||||||
:on-success #(dispatch [:set-bounties %])}}))
|
:on-success #(dispatch [:set-bounties %])}}))
|
||||||
|
|
||||||
(reg-event-fx
|
(reg-event-fx
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
(fn [{:keys [db]} [_ issue-id payout-hash]]
|
(fn [{:keys [db]} [_ issue-id payout-hash]]
|
||||||
{:db db
|
{:db db
|
||||||
:http {:method POST
|
:http {:method POST
|
||||||
:url (str/format "/api/bounty/%s/payout" issue-id)
|
:url (str/format "/api/user/bounty/%s/payout" issue-id)
|
||||||
:on-success #(println %)
|
:on-success #(println %)
|
||||||
:params {:payout-hash payout-hash}}}))
|
:params {:payout-hash payout-hash}}}))
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
(fn [{:keys [db]} [_]]
|
(fn [{:keys [db]} [_]]
|
||||||
{:db db
|
{:db db
|
||||||
:http {:method GET
|
:http {:method GET
|
||||||
:url "/api/repositories"
|
:url "/api/user/enabled-repositories"
|
||||||
:on-success #(dispatch [:set-enabled-repos %])}}))
|
:on-success #(dispatch [:set-enabled-repos %])}}))
|
||||||
|
|
||||||
(reg-event-fx
|
(reg-event-fx
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
(println "toggle-repo" repo)
|
(println "toggle-repo" repo)
|
||||||
{:db db
|
{:db db
|
||||||
:http {:method POST
|
:http {:method POST
|
||||||
:url "/api/repository/toggle"
|
:url "/api/user/repository/toggle"
|
||||||
:on-success #(println %)
|
:on-success #(println %)
|
||||||
:params (select-keys repo [:id :login :full_name :name])}}))
|
:params (select-keys repo [:id :login :full_name :name])}}))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue