Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Node.JS Examples:

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

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/directory

Here you'll find a basic "helloworld" script, plus a promise based script that simulates a longer server script execution time.



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: avajestmochatape


Convenient HTTP Requests

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


Front-End

When writing your front-end Javascript for your app:


External Resources: