mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
feat(backend): add logout and better router initialization
This commit is contained in:
parent
932875a317
commit
be7e8e63ee
2 changed files with 75 additions and 66 deletions
|
@ -25,6 +25,13 @@
|
|||
(-> (rsp/no-content)
|
||||
(assoc :session {:user-id id})))))))
|
||||
|
||||
(defn logout
|
||||
{:description "User logout endpoint"}
|
||||
[req]
|
||||
(-> (rsp/no-content)
|
||||
(assoc :session nil)
|
||||
(p/resolved)))
|
||||
|
||||
(defn register
|
||||
{:parameters {:body {:username [st/required st/string]
|
||||
:email [st/required st/email]
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
:middleware middleware}})
|
||||
|
||||
(def routes
|
||||
(rr/router
|
||||
[["/media/*" (rr/create-resource-handler {:root "public/media"})]
|
||||
["/static/*" (rr/create-resource-handler {:root "public/static"})]
|
||||
|
||||
["/api/auth"
|
||||
["/login" {:post (handler #'api-auth/login)}]
|
||||
["/logout" {:post (handler #'api-auth/logout)}]
|
||||
["/register" {:post (handler #'api-auth/register)}]
|
||||
["/recovery/:token" {:get (handler #'api-auth/register)}]
|
||||
["/recovery" {:post (handler #'api-auth/request-recovery)
|
||||
|
@ -74,10 +74,11 @@
|
|||
["/pages/:id/history/:hid" {:put (handler #'api-pages/update-page-history)}]
|
||||
|
||||
;; Profile
|
||||
["/profile/me" {:get (handler #'api-users/retrieve-profile)
|
||||
["/profile"
|
||||
["/me" {:get (handler #'api-users/retrieve-profile)
|
||||
:put (handler #'api-users/update-profile)}]
|
||||
["/profile/me/password" {:put (handler #'api-users/update-password)}]
|
||||
["/profile/me/photo" {:post (handler #'api-users/update-photo)}]
|
||||
["/me/password" {:put (handler #'api-users/update-password)}]
|
||||
["/me/photo" {:post (handler #'api-users/update-photo)}]]
|
||||
|
||||
;; Library
|
||||
["/library"
|
||||
|
@ -107,17 +108,18 @@
|
|||
:get (handler #'api-images/list-images)}]
|
||||
]
|
||||
|
||||
]]
|
||||
router-options))
|
||||
]])
|
||||
|
||||
(def app
|
||||
(rr/ring-handler routes (rr/create-default-handler)))
|
||||
|
||||
;; --- State Initialization
|
||||
(def app
|
||||
(delay
|
||||
(-> (rr/router routes router-options)
|
||||
(rr/ring-handler (rr/create-default-handler)))))
|
||||
|
||||
(defn- start-server
|
||||
[config]
|
||||
(jetty/run-jetty app {:join? false
|
||||
(jetty/run-jetty @app {:join? false
|
||||
:async? true
|
||||
:daemon? true
|
||||
:port (:http-server-port config)}))
|
||||
|
|
Loading…
Add table
Reference in a new issue