Coaty Template Project for Node.js
This project provides a ready-to-use template for a Coaty agent running in Node.js and programmed in TypeScript. Copy and use it as a blueprint for your own Coaty agent projects.
The template project includes:
- a complete build system based on npm run scripts and gulp,
- the template sources for setting up a bare Coaty agent,
- support for running the project in a local Node.js runtime or in Docker.
Note: This template project does not provide any application-specific business logic and usage examples of Coaty communication patterns. Such examples can be found in the adjacent projects.
To begin with, make sure that the
installed on your target machine. We recommend to use the latest LTS version,
but at least version 8. Download and installation details can be found
The agent software uses the node package dependency manager
npm to download
dependent libraries. npm comes with
Node.js so you need to install it first.
The agent project can be build and executed using npm run scripts.
If you are within a corporate network, you may need to specify HTTP/HTTPS
proxies so that npm can download dependent libraries from the public npm
repository. The easiest way is to create an
.npmrc file in your home folder
and add two lines like this:
To program Coaty applications, we recommend to use Visual Studio Code, a free, open source IDE that runs everywhere. Install the VS Code extension "TSLint" to enable TypeScript linting within the IDE.
If you are new to Coaty and want to know how to learn and use the Coaty framework, take a look at the Coaty website.
If you want to run the Coaty agent with Docker, install the latest Docker version for your platform.
Install project dependencies and build the project as follows:
npm install npm run build
Start up with Node.js runtime
Ensure an MQTT broker is set up and running. If you are not running an external broker, you can start the Coaty broker:
npm run broker
Alternatively, you can start the Coaty broker in debugging mode, where all MQTT publications and subscriptions are logged on the console:
npm run broker:verbose
Next, adjust the environment variables provided in the project's
.env file to
Then, start a Coaty agent:
npm run start
Start up with Docker
The project can be run with Docker:
npm run docker:up
Ensure that the environment variables provided in the project's
.env file are
adjusted to your environment.
To rebuild the Docker images:
npm run docker:build
If you are within a corporate network, ensure to set the
environment variable when building the Docker images like this:
Copyright (c) 2019 Siemens AG. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.