Skip to content

Commit

Permalink
insurance routes: fix interceptor dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramblurr committed May 16, 2024
1 parent a49972e commit efa3370
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
15 changes: 9 additions & 6 deletions src/clj/app/errors.clj
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
ex)
ex)))

(defn format-req
"Given a pedestal request map, returns a smaller map designed for s entry consumption"
(defn prepare-req
"Given a pedestal request map, returns a smaller sanitized map designed for event logging consumption"
[req]
(-> req
(update :params (fn [params]
Expand All @@ -69,7 +69,7 @@
;; (update :request-method name)
(select-keys [:uri :query-string :request-method :headers :params :member-id :user-email])
;; (set/rename-keys {:request-method :method :params :data :uri :url})
))
sanitize))

(defn send-event!
"Sends a telemetry event asynchronously"
Expand All @@ -78,21 +78,24 @@
([msg req ex]
(let [event-data {:msg msg
:extra {:human-id (:human-id req)}
:request (-> req sanitize format-req)}]
:request (prepare-req req)}]
(μ/with-context event-data
(μ/log ::error :ex (unwrap-ex ex))))))

(defn log-error! [req ex]
(when (config/prod-mode? (-> req :system :env))
(μ/log ::error :ex ex)))
(μ/log ::error
:ex ex
:request (prepare-req req))))

(defn report-error!
"Report an exception outside the normal request/response lifecycle"
([ex]
(report-error! ex nil))
([ex extra]
(μ/with-context {:msg (ex-message ex)
:extra extra}
:extra extra
:reported? true}
(μ/log ::error :ex (unwrap-ex ex)))))

(defn redact-mulog-events [events]
Expand Down
64 changes: 31 additions & 33 deletions src/clj/app/insurance/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -126,50 +126,48 @@
instrument-id (assoc-in [:request :instrument] (q/retrieve-instrument db (parse-uuid instrument-id))))))})

(defn routes []
[""
["" {:app.route/name :app/insurance1
:interceptors [policy-interceptor]}
["" {:app.route/name :app/insurance}
(insurance-index)
["/instrument-image/{instrument-id}"
{:post {:summary "Upload an image for an instrument"
:parameters {:multipart [:map [:file reitit.ring.malli/temp-file-part]]
:path [:map [:instrument-id :uuid]]}
:handler (fn [req] (view/image-upload-handler req))}}]
["/instrument-image-button/"
{:post {:summary "Upload an image for an instrument from a single button"
:parameters {:multipart [:map
[:files [:vector {:decode/string (fn [v] (if (vector? v) v [v]))} reitit.ring.malli/temp-file-part]]
[:instrument-id :uuid]]}
:handler (fn [req] (view/instrument-image-upload-button-handler req))}}]

["" {:interceptors [policy-interceptor]}
(insurance-survey)
(insurance-coverage-create)
(insurance-coverage-create2)
(insurance-coverage-create3)
(insurance-generate-changes)
(insurance-detail)
(insurance-notification)

["/insurance-changes-excel/{policy-id}/"
{:post {:summary "Get the changes excel file"
:parameters {}
:handler (fn [req]
(view/insurance-policy-changes-file req))}}]
(view/insurance-policy-changes-file req))}}]]

["/instrument-image/{instrument-id}"
{:post {:summary "Upload an image for an instrument"
:parameters {:multipart [:map [:file reitit.ring.malli/temp-file-part]]
:path [:map [:instrument-id :uuid]]}
:handler (fn [req] (view/image-upload-handler req))}}]
["" {:interceptors [policy-interceptor instrument-interceptor]}
(insurance-coverage-create2)
(insurance-coverage-create3)]

["/instrument-image-button/"
{:post {:summary "Upload an image for an instrument from a single button"
:parameters {:multipart [:map
[:files [:vector {:decode/string (fn [v] (if (vector? v) v [v]))} reitit.ring.malli/temp-file-part]]
[:instrument-id :uuid]]}
:handler (fn [req] (view/instrument-image-upload-button-handler req))}}]]
["" {:app.route/name :app/instrument.coverage
:interceptors [coverage-interceptor]}
(insurance-coverage-detail)
(insurance-coverage-detail-edit)]

(insurance-index)
(insurance-create)
(instrument-create)
["" {:app.route/name :app/insurance2
:interceptors [policy-interceptor instrument-interceptor]}
;; (ctmx/make-routes
;; "/insurance-policy-duplicate/"
;; (fn [req]
;; (view/insurance-policy-duplicate req)))
["" {:app.route/name :app/instrument.coverage
:interceptors [coverage-interceptor]}
(insurance-coverage-detail)
(insurance-coverage-detail-edit)]
(insurance-create)
(insurance-generate-changes)
(insurance-detail)
(insurance-notification)
(instrument-detail)
(instrument-create)]])
:interceptors [instrument-interceptor]}

(instrument-detail)]])

(defn unauthenticated-routes []
[""
Expand Down

0 comments on commit efa3370

Please sign in to comment.