Skip to content

Commit

Permalink
Whitelist keys for api-gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
dehli committed Jan 21, 2020
1 parent d8a0c59 commit 5e9fd89
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>dehli</groupId>
<artifactId>serverless</artifactId>
<version>0.1.17</version>
<version>0.1.18</version>
<name>serverless</name>

<dependencies>
Expand Down
17 changes: 11 additions & 6 deletions src/serverless/aws/api_gateway.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
(new ApiGatewayManagementApi
(clj->js {:apiVersion "2018-11-29" :endpoint endpoint})))

;; Method helpers
(def- base-xform #(select-keys % [:connection-id]))
(defn- post-xform [p]
(-> p (update :data clj->json) (select-keys [:connection-id :data])))

;; Public methods
(defn delete-connection [api params]
(js-call-v2 api "deleteConnection" params))
(defn get-connection [api params]
(js-call-v2 api "getConnection" params))
(defn post-to-connection [api params]
(js-call-v2 api "postToConnection" (update params :data clj->json)))
(def delete-connection
(partial js-call-v2 "deleteConnection" base-xform))
(def get-connection
(partial js-call-v2 "getConnection" base-xform))
(def post-to-connection
(partial js-call-v2 "postToConnection" post-xform))

;; Accessors
(def request-context :requestContext)
Expand Down
6 changes: 4 additions & 2 deletions src/serverless/aws/sdk.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
(js-invoke client method (clj->js args) (callback c))
c))

(defn js-call-v2 [client method args]
(defn js-call-v2 [method xform client args]
(let [c (promise-chan)]
(js-invoke client method (clj->js (kebab->pascal args)) (callback c))
(js-invoke client method
(clj->js (kebab->pascal (xform args)))
(callback c))
c))

0 comments on commit 5e9fd89

Please sign in to comment.