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:
Â
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 neededKeep 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:
- Browser:Â
fetch()
 (built-in) Node.js: node-fetch (like browsers'Â
fetch()
)