StdLib Updates: Node.js 8.4.0 Support, Use Custom Hostnames For Your Services With Cloudflare

Jacob Lee
Jacob Lee
Aug 24, 2017 · 4 min read

Hey everyone! We’re thrilled to announce some great additions to StdLib here. We’ve added hostname route support, allowing you to redirect custom domains to your StdLib services using Cloudflare. We’ve also updated the default Node engine to Node 8.4.0, which includes some nifty performance updates to the V8 engine.

If you’re not familiar with StdLib, we’re a function as a service (FaaS) library that allows users to rapidly create, discover, and consume APIs as web functions. We’re the fastest way for developers to turn their code into a live, infinitely-scalable, production-ready endpoint. This tutorial on our Github page will walk you through the process of signing up and creating your first service.

StdLib + Cloudflare

Hostname Routing Support

We’re happy to announce today that StdLib now supports custom hostnames! You can now route your personal domains to your released StdLib services, allowing you to use them as the entry point to your Slack bots, Twilio hubs, Vue single-page apps, Stripe stores, and other functions built on StdLib. The only things you’ll need are a StdLib account, a Cloudflare account, and a domain name.

Step 1: Set Up Cloudflare With Your Domain

If you haven’t already, follow the steps here to set up Cloudflare with your hosting provider. It may take a few minutes to allow for changes to propagate.

Step 2: Redirect Your Cloudflare Domain to StdLib

The DNS tab in your Cloudflare dashboard

From your Cloudflare dashboard, you should select the DNS tab, then create a new CNAME record from whatever hostname you’d like (we use “test” in the example below), to the domain name

Creating a CNAME DNS record in your Cloudflare dashboard

If you would like to make your root domain redirect to a Standard Library API (e.g., simply use the “@” symbol as the name. Once you have done that, try navigating to <hostname>.<your domain name>.<your TLD>. You should see the following error message in your browser:

Error message from StdLib before adding a StdLib route

This is normal — we still have to let StdLib know where to route your function. We’ll do this in the next step.

If you don’t see the above message right away, it may be because Cloudflare can take time to propagate your route, so try checking again in a minute or two.

Step 3: Add a StdLib Route

First, install the latest version of the lib CLI using npm install lib.cli -g. Then, navigate to your StdLib directory and run lib hosts. You should see an empty table:

Result from running “lib hosts” with no created hostname routes

Some terminology: hostname in this table is the custom domain you want to route from. You should avoid using http:// or https:// in front of your domain (i.e. rather than Target is the specific StdLib service you want to route your custom domain to.

Once you’re ready, run lib hosts:add <hostname> <service name>, where service name is in the form <username>.<service name>[@<version/environment>]. If you do not specify a version, StdLib will automatically route to the latest release.

Successfully creating a route from a custom domain to a StdLib service

Run lib hosts again to see your successfully created route!

The updated hostname routes table

If you navigate to your custom hostname, you should see the output from your StdLib function! You should also be able to use https:// in front of your URL to encrypt your traffic — Cloudflare has settings to automatically enforce this if that’s your preference.

For more information on the lib CLI and other features we support, check out our docs page.

Node 8.4.0 Support

Our main Node engine is now Node 8.4.0, complete with the V8 6.0 engine + Turbofan and the performance benefits that go along with it. To use the previous engine version, you should manually set "engine": "nodejs-8.2.1" in the "stdlib" field of your package.json.

That’s it!

You’ve successfully created a route from a custom domain to a StdLib service. We’ve got more exciting features and announcements coming up in the next few weeks, so stay tuned by following us on Twitter @StdLibHQ. You can also join our Slack channel by going to our homepage and requesting an invite under the “Community” tab. Feel free to reach out anytime!

Jacob Lee is a co-founder of StdLib and firm believer in the FaaS future. He’s an east-coast transplant and ex-Googler who loves skiing, playing squash, and traveling. Follow him on Twitter @hacubu!

Standard Library

Standard Library Development Blog

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store