Get in touch

Introducing Postlight’s Modern Serverless Starter Kit

Exactly the right amount of boilerplate to get Serverless JavaScript running in seconds.

You could spend a couple hours configuring each new Serverless project to get up and running with all the tools you rely on—or you could write and deploy a new function in minutes with Postlight’s Serverless Starter Kit, a free, batteries-included starter kit for developers writing and deploying serverless JavaScript code.


??‍♀️ Serverless with all the fixings: Webpack, Babel, TypeScript (if you want it!), Jest, ESLint, and Prettier. – postlight/serverless-babel-starter

This starter kit adds a light layer on top of the Serverless framework, giving you the latest in modern JavaScript—ESNext (Webpack + Babel), testing (Jest), code linting (ESLint), and code formatting (Prettier)—plus the ease and power of Serverless.

Why Does This Exist?

Our business runs on open source, and wherever possible, we love to give code back to the commons. Postlight has shipped several serverless projects to production, and we came to realize that 1) The serverless architecture is something we’re very enthusiastic about, and 2) We didn’t want to waste time setting up boilerplate every time we launched a new serverless project. Now, all of our new serverless projects, including the Mercury Web Parser, use this starter kit. (Incidentally, going serverless with the Mercury API reduced our hosting costs by two orders of magnitude.)

Background: Why Serverless?

You’ve no doubt heard of the serverless architecture — rather than deploying your code to a dedicated server, you deploy functions that are invoked and run on demand, scale automatically, and cost comparatively little (you pay only for the time your functions run, which almost always amounts to paying less).


??‍♀️ Serverless with all the fixings: Webpack, Babel, TypeScript (if you want it!), Jest, ESLint, and Prettier. – postlight/serverless-babel-starter

You may have also heard of the Serverless framework, a toolkit for managing and deploying serverless code to various serverless providers, like Amazon Web Services, Microsoft Azure, and Google Cloud Platform.

These tools have changed the way many engineers approach new projects, including the way we tackle certain problems at Postlight. A serverless architecture isn’t a silver bullet, but a few compelling reasons to go serverless (which I’m cribbing from here) include:

  • Money: With any function-as-a-service (FaaS), you pay only for the time your functions are running. (And sometimes you don’t pay at all; AWS, for example, gives you 1 million free invocations a month.)
  • No servers to manage: Perhaps not shocking (serverless kind of gives it away), but not having to worry about provisioning and managing servers takes a large bit of work out of any project.
  • Automatic scaling: FaaS providers automatically scale up and down to meet the needs of your function. You really don’t need to monitor usage, scale up new servers if traffic ticks up, and scale back down when it drops. (Some services do, however, have concurrency limits; AWS Lambda, for example, has a default concurrency limit of 1,000 requests. That means that if your function takes 1 second to execute, your app can handle roughly 1,000 requests/second before it gets throttled. You can request increases to this limit should you need it.)
  • Faster shipping: Once you’ve wrapped your head around deploying a project with the Serverless framework, getting from zero to a working deploy could not be faster or easier. And this starter kit, for its part, trims the timeline from git init to yarn deploy even further.

The Technical Details: What Do You Get?

As I mentioned, this starter kit is more or less the default configuration from the Serverless framework, but with all of the tooling you’d expect from a modern JavaScript project baked in. When you install this kit (with serverless install --url, here’s what you get:

  • Modern ESNext features: Babel + Webpack handle transpiling your modern JavaScript code before deploys. (This also means that you can add any Webpack loaders you please to webpack.config.js.)
  • Testing: Facebook’s popular testrunner, Jest, powers unit tests with a simple yarn test.
  • Linting: Your code is linted using ESLint and the AirBnb config.
  • Formatting: Your code is formatted using Prettier, the popular new how-did-I-live-without-this formatter.

ESLint and Prettier are both run on git commit thanks to husky and lint-staged, so you never accidentally check in code that’s failing your linter or code that isn’t properly formatted.

Note: Currently, the kit’s built with a focus on AWS, but the Serverless framework supports many other FaaS services, so you can relatively easily adapt it to fit your needs by adding the appropriate plugin.

A Work-in-Progress: Pull Requests Welcome

We’ve used this starter kit to bootstrap countless serverless projects, but that doesn’t mean there isn’t room for improvement. We’d love your help making it better.

Got a great idea for more seamlessly supporting services beyond AWS out of the box? Find a mistake in the README? Give it a try, file an issue with your feature requests and questions, and send us a pull request with your changes. And please, enjoy, and let us know how it’s working for you!

Adam Pash is a Director of Engineering at Postlight. Wanna talk serverless with the experts? Get in touch:

Story published on Jan 3, 2018.