Fork me on GitHub
#nbb
<
2022-09-03
>
Nick Cellino15:09:34

hey all, I just posted this https://www.reddit.com/r/Clojure/comments/x4xd0g/implementing_a_comments_feature_with_nbb_htmx little example of an nbb project running on Lambda (using serverless framework) and interacting with DynamoDB. There’s some code in there working with the AWS JS v3 SDK for dynamodb if it’s of any interest 🙂 I’d love to hear any feedback anyone has on the code or writing! edit: here’s the link to the repo if you wanna skip right to the code https://github.com/NickCellino/nbb-comments

👍 3
valtteri19:09:16

Nice project! In JS v3 sdk they don’t seem to have DocumentClient for DynamoDB anymore, but they’ve included the utils to marshall from dynamodb-JSON to “normal” JSON and the other way around. https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_util_dynamodb.html

valtteri19:09:59

Just quickly skimmed through the code. 🙂 Tomorrow I might have time to actually try it out!

Nick Cellino19:09:31

hey, thanks! Looks like that would take some of the manual work out of this kind of stuff that I’m doing, right?

(defn build-dynamo-comment-payload
  [comment-input]
  {:PostId {:S (:post-id comment-input)}
   :CommentId {:S (uuid/v4)}
   :Message {:S (:message comment-input)}
   :Time {:S (.toISOString (js/Date.))}
   :Author {:S (:author comment-input)}
   :RecaptchaScore {:S (str (:score comment-input))}})

valtteri19:09:32

Yep, exactly. 🙂

Nick Cellino19:09:53

very nice, didn’t know about that

valtteri19:09:01

Yeh, it’s pretty well hidden!

Nick Cellino19:09:12

yeah there’s definitely a lot in those sdks to dig through

valtteri19:09:40

I remember it was PITA to add those type attributes.. then I found out that DocumentClient does that automatically. But now they don’t have DocumentClient in v3 which got me confused but luckily they’ve kept the supporting functions around.

valtteri19:09:06

Weird that they don’t mention it in the DynamoDB Client README. :thinking_face: I guess 99% of the SDK users would like to use those functions if they knew they existed

Nick Cellino19:09:07

that’s good. we actually have some DynamoDB code that we use at my day job in plain old JS and whoever wrote it definitely did not know about these utils. We have that crazy nested { "Field": { "S": "Value" } } type stuff all over the place lol

valtteri19:09:07

I guess it’s all generated (code, docs, references) and these weird things on the side get excluded

Nick Cellino19:09:37

yeah i guess that makes sense. I’ve looked into that a little bit (not too deeply), but i think it’s pretty amazing how they basically describe all of their apis for all of their services in some generic way and autogenerate all the stuff that they do

Nick Cellino19:09:51

i’m kind of in awe of aws

🙂 1
valtteri19:09:26

Personally I like their engineering. They have quite clojurey mindset to not break things.

valtteri19:09:43

One thing they don’t know how to do is UI’s 😄

valtteri19:09:00

OTOH also GCP and Azure have very crappy UI’s

Nick Cellino19:09:38

i really like it too. it’s very “DIY” which was/is pretty painful sometimes, but I appreciate the transparency of everything

Nick Cellino19:09:22

agreed on the UIs too haha. i try to do everything i can using infra-as-code but i spend time in the UI when prototyping things. but eh, they serve their purpose for me most of the time

valtteri19:09:24

Yep, I usually explore in the UI and when I know what I want I write it in Cloudformation

valtteri20:09:25

Which is always a journey 😎

Nick Cellino20:09:24

i know what you mean 😆