Server CLI Examples and Tips


Node.JS Examples:

To help get you started, we've included some example basic Node.JS script examples that you can use as a basis to quickly get started with the Server CLI.

There are examples of using both the automatic routing option (directory based), and manual route configuration (configuration based) options, as described in Creating Your Project Structure.

Github

There are examples in the Github repo, and you can find them in the "examples" folder:

https://github.com/blinkmobile/server-cli/tree/master/examples

Download ZIP

If you prefer, you can download the examples here, directly:

Server CLI Code Examples.zip

 

Quick Javascript Tips and Suggestions:

 

Maintainability, Sustainability

When designing your Javascript code, for longer-term maintainability and sustainability, consider:

  • Extract shared logic out into separate files, and use a module system so that you can require() as needed

  • Keep credentials and other environment variables out of your code. See dotenv or similar approaches

  • Consider keeping integration functions (e.g. network requests, libraries) separate from processing functions (e.g. transformations, data traversal) in order to make them easier to test

  • Consider writing automated tests with one of the following test frameworks or similar: ava, jest, mocha, tape


Convenient HTTP Requests

Here are our favourite ways of making HTTP requests with JavaScript:


External Resources: