Tolga Talks Tech: Sailplane

Tolga Talks Tech is a weekly video series in which Onica’s CTO Tolga Tarhan tackles technical topics related to AWS and cloud computing. This week, Tolga discusses the Sailplane – AWS Serverless Node.js utilities with Adam Fanello, Lead Solutions Architect at Onica. For more videos in this series, click here

So you recently worked on an open source project that Onica has released called Sailplane. Tell me a little bit about what inspired you to create this.

We discovered that we were using a lot of the same code in projects. We would develop something in one project for one client, and then when we started another project, we’d realize, “Oh, that was a really useful piece of code we had in the other project. Let’s copy that over.” We would then have to go find it and get access and sometimes, there are multiple people involved. And, then the third project would start up. Even though improvements were made in the second one, the team may go back to the first one and copy that one again. And so, we were losing innovation and doing a lot of replication. 

So these are, typically utilities that were so small that they didn’t really make their way into a reusable library. And what you did was basically extracted a bunch of these various small utilities and made a library out of them. 

That’s right. They are actually independent packages on Node Package Manager (NPM) but they are cohesive and some of them actually depend on each other. 

What are some of the things Sailplane does?

Sailplane has a variety of small lightweight simple utilities. Often, in some cases, they actually expand on existing solutions and add some extra value to them. For instance, we have a dependency injector. There are a lot of existing dependency injectors out there and are available in TypeScript and JavaScript. But they’re often very big and complicated, yet limited in some ways. And, we would just want a very simple, reusable solution. What we found was an existing library called BottleJS, which worked pretty well but still had a complicated API and was not type-safe. So we simply wrapped it up – to add a simpler API and type-safety. 

So one of my favorite parts of Sailplane is Lambda-Utils. What does that do?

Lambda-utils makes it easier to work with API gateway lambdas. A lambda launched by API gateway sends a request in a particular format and expects a specific response back. And, there’s a lot of work that goes around that. Like the request comes in with the body as a string but often you want it as a JSON object and same with the response going back – you have to stringify it going back as well as provide something like status code.

Then you have to deal with cores and query strings and various complexities. Lambda-utils wraps that up in a way where you can put that all in one place and only do it once. Beyond that, this also promisfies the whole process. So instead of having to formulate your response with the status code, and stringify body and such, you instead just return a value from your lambda. The Lambda-utils will automatically put that into the right format for API gateway and wrap it up, so if you’re trying to promise, you don’t have to deal with callbacks. 

Sailplane is very lightweight. It’s easy to use in a project and it’s meant to just stay out of the way. How do people get started with it?

You could search NPM for Sailplane. It’s actually a collection of libraries. They all start with @Sailplane. You could link to our GitHub and you can see the repository of either NPM or repositories that link to the documentation. All these utilities have a great deal of documentation. They have TypeScript declarations, they have examples independently and how to use them together, and NJSdoc and unit tests.

Learn more about Onica’s open source contributions here.

Explore More Cloud Insights from Onica

Blogs

The latest perspectives on navigating an ever-changing cloud landscape

Case Studies

Explore how our customers are driving cloud innovation in their industries

Videos

Watch an on-demand library of cloud tutorials, tips and tricks

Publications

Learn how to succeed in the cloud with deep-dives into pressing cloud topics