Overview

Skill Level: Intermediate

This article introduces a generator that scaffolds a fully functional 12-factor compliant Node.js app built on Express. It provides API validation, interactive documentation, structured logging, environment driven config, ES.next transpilation and more

Ingredients

This article describes how to build software as a service using Node.js along with best of breed technologies and approaches. We will introduce a generator that can be used to quickly scaffold a new API application built on Express.js. The scaffolding provides structured logging, API request validation, interactive API documentation, environment driven configuration, a simple build / transpilation process, and more. The scaffolded application is also suitable for deployment on modern cloud platforms like Bluemix.

Nowadays, software is often delivered as a service on the web. This is the software that drives the API economy. APIs create value by delivering on what other’s want. They help developers innovate freely, drive change, connect seemingly disparate domains, and ultimately deliver new value.

When building APIs, it is incredibly important to meet the needs of the developer who consumes them. APIs must be dependable, scalable, intuitive, easy to use. APIs must also minimize the time and cost for the developers who maintain it. An API application should be easy to setup and automate. It should be easy to port between execution environments. It should be suitable for deployment to the cloud. It should require minimal effort with respect to systems administration and monitoring.

Fortunately, the express-no-stress generator creates an application compatible with these demands. express-no-stress is a mini project that I started. It is a Yeoman generator that scaffolds a consistent, fully functional REST API. It combines the tools you need to build awesome apps. It takes just seconds to generate and allows you to focus on what’s important – writing application code.

express-no-stress generates an application that is compatible with 12 factor apps.

It includes:
Express.js – a fast, unopinionated , minimalist web framework for Node.js.
Babel.js – a compiler that enables you to use next generation Javascript today.
– Bunyan – a simple and fast (JSON) structured logging module for node.js.
– dotenv – loads environment variables from .env.
– Backpack – a minimalistic build system for node.js.
– Swagger – a simple yet powerful representation of your RESTful API.
SwaggerUI – dynamically generated, beautiful documentation and sandbox from a Swagger-compliant API.
– Cloud Ready – deploy to any cloud. A CloudFoundry / Bluemix example is provided. See README

To see the out-of-the-box scaffolded app in action, visit https://express-no-stress-scaffolded-app.mybluemix.net.
Note: the scaffolding provides only a minimal example API. It is up to you to implement your API code the way you want.


To get started with express-no-stress, go here.

For the impatient, run:

npm install -g yo generator-express-no-stress

yo express-no-stress myapp


Give it a try. It just might help ?

Step-by-step

  1. Prerequisites

    1. Install Node.js
    2. Install Yeoman, run
      npm install -g yo
  2. Install and Scaffold

    To get started with express-no-stress, go here.

    For the impatient, run:

    npm install -g yo generator-express-no-stress
    yo express-no-stress myapp
  3. Run

    cd myapp
    npm start
  4. Try

    Navigate to http://localhost:3000

  5. Star it :-D

    If you dig the project, github stars are welcomed 🙂

    https://github.com/cdimascio/generator-express-no-stress

    Thanks 😀

1 comment on"Get started with Node.js, Express and Swagger"

  1. Wow, kudos sir. Cool generator, and finally some swagger/express usage that makes sense to me! ?

Join The Discussion