nbb

Nick Cellino 2022-09-03T15:46:34.937249Z

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
borkdude 2022-09-03T19:17:01.090759Z

Awesome!

Nick Cellino 2022-09-03T19:29:13.942969Z

thanks 🙂

valtteri 2022-09-03T19:39:16.285839Z

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

valtteri 2022-09-03T19:39:59.395109Z

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

Nick Cellino 2022-09-03T19:41:31.077289Z

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))}})

valtteri 2022-09-03T19:42:32.296359Z

Yep, exactly. 🙂

Nick Cellino 2022-09-03T19:42:53.722319Z

very nice, didn’t know about that

valtteri 2022-09-03T19:43:01.514439Z

Yeh, it’s pretty well hidden!

Nick Cellino 2022-09-03T19:46:12.318859Z

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

valtteri 2022-09-03T19:47:40.657459Z

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.

valtteri 2022-09-03T19:49:06.918049Z

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

Nick Cellino 2022-09-03T19:50:07.316119Z

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

valtteri 2022-09-03T19:50:07.662249Z

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

Nick Cellino 2022-09-03T19:52:37.929719Z

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 Cellino 2022-09-03T19:52:51.248009Z

i’m kind of in awe of aws

🙂 1
valtteri 2022-09-03T19:54:26.382719Z

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

valtteri 2022-09-03T19:54:43.018999Z

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

valtteri 2022-09-03T19:55:00.927359Z

OTOH also GCP and Azure have very crappy UI’s

Nick Cellino 2022-09-03T19:56:38.432519Z

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

Nick Cellino 2022-09-03T19:57:22.043049Z

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

valtteri 2022-09-03T19:59:24.075859Z

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

valtteri 2022-09-03T20:00:25.829419Z

Which is always a journey 😎

Nick Cellino 2022-09-03T20:01:24.704819Z

i know what you mean 😆