-
Notifications
You must be signed in to change notification settings - Fork 18
JavaScript Style Guide
Your demo application should read any configuration variable (e.g., Project ID, API Token) from the environment. Typically, the user will provide a .env file which will contain the environment variables, and your program will look for this file in its same directory.
You should also provide a file called env.example (without initial dot) which will act as a template. Example for env.example:
# Project ID. Copy it from the API Credentials in your SignalWire Space.
# Example: 7b98XXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
PROJECT_ID=
# API Token. Copy it from the API Credentials in your SignalWire Space.
# Example: PTda745XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
API_TOKEN=
# SPACE_URL. Copy it from the API Credentials in your SignalWire Space.
# Example: spacename.signalwire.com
SPACE_URL=Please only include the relevant fields.
To read the .env file from your application, add the following line at the very top of the main file:
require("dotenv").config();This requires the dotenv package (npm i dotenv).
To ensure a consistent look and the absence of errors, it is often advised to run an automated formatter. We support "prettier": you can use it as a VS Code plugin, or from the command line, like this:
npx prettier --write path/to/my/demo