Siren.js

80 views
Skip to first unread message

Dillon Redding

unread,
May 14, 2021, 11:20:50 AM5/14/21
to Siren Hypermedia
Hello everybody!

I wanted to share a set of libraries I've been working on for using Siren in JavaScript (and TypeScript). The primary libraries are core (for generating/parsing Siren) and client (for working with Siren components (links, actions, etc.)). If you're interested, you can find these and other auxiliary repos in the Siren.js org on GitHub.

The project is in the early stages, but there are packages published to NPM, so feel free to check those out, leave feedback on GitHub or the Siren.js Google Group, or make some contributions. 😁

Regards,
Dillon

Michael Tiller

unread,
May 16, 2021, 8:54:27 AM5/16/21
to siren-hy...@googlegroups.com
For anybody interested in this topic of Siren and TypeScript, I've also created two libraries somewhat analogous to your "core" and "client" libraries called siren-types and siren-nav, respectively.  You can find them here:


They are published to NPM as well.  I haven't updated them in a while, but they serve my purposes pretty well.  Feel free to borrow any ideas from them.  The thing I'm particularly pleased with in siren-nav is the chaining API.  It allows you to build up a recipe for navigation starting from the root API level in a declarative way.  While the entire expression is a single async evaluation, it requires carefully chaining together a bunch of async requests underneath.

To me, some of the highlights of siren-nav are the fact that it has a "squash" option for when you'd like to describe a complex recipe to navigate from root to a particular resource but you don't want to repeat it each time (so it resolves it once and caches the result).  Another feature is that it allows you to leverage relations that include URI templates so you can substitute values in.  I find this particular useful because often I don't want to provide a link for every resource possible but instead include a URI as a way for the client to construct the URI programmatically.  The way it handles actions gives a fair amount of flexibility in how you handle the responses.

--
Mike


--
You received this message because you are subscribed to the Google Groups "Siren Hypermedia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to siren-hypermed...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/siren-hypermedia/69752ff0-8638-4150-b859-046c4820bc83n%40googlegroups.com.

Dillon Redding

unread,
May 17, 2021, 9:56:00 AM5/17/21
to Siren Hypermedia
That's awesome, Mike!

I had found siren-parser and siren-nav before starting Siren.js. siren-parser didn't support extensions, which led me to building @siren-js/core. I really like the idea of siren-nav, but the workflow it created was too static for my needs at the time, which led me to building the general-purpose @siren-js/client. I'd love to incorporate some of those ideas into Siren.js at some point!
Reply all
Reply to author
Forward
0 new messages