StdLib Updates: Node.js 8.4.0 Support, Use Custom Hostnames For Your Services With Cloudflare
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.
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
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
If you would like to make your root domain redirect to a Standard Library API (e.g.
google.com, 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:
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:
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.
test.stdlib.com rather than
https://test.stdlib.com). 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.
lib hosts again to see your successfully created route!
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
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!