amps-client-javascript
This is the official TypeScript/JavaScript client for AMPS server.
Supported features:
- very few external dependencies (WebSocket and Promise);
- a fully asynchronous Promise-based interface;
- convenience methods for common commands, such as publish, subscribe, sow, deltaSubscribe;
- heartbeat mode for quickly detecting connection failures.
- the Command interface for fine-grained control over commands and their options;
- support of enterprise authentication systems, such as Kerberos, NTLM, and Basic Auth;
- support of Authenticators for custom authentication scenarios.
- HAClient functionality
Development
- Install required dependencies:
npm install --save
- source code and dependencies are located in the
src
directory.
Tests
Tests require a running AMPS instance. The configuration file for that instance is provided: tests/docker/amps-config.xml
The library should be tested in both Browser and Node.js environment, that's why it provides a set of
universal tests and the dev web server.
Test results will also be stored in the JUnit XML format, in order to support automatic builds (junit_tests_output.xml
).
Docker
In order to run tests, a running AMPS server instance is required. The testing config is located in
tests/docker/amps-config.xml
. A dockerfile
provided to start AMPS Server using docker on your Mac or Windows machine:
- Navigate to
./tests/docker
- Build the AMPS server container in Terminal:
docker build .
- Run the built container:
docker run -p 8085:8085 -p 9000:9000 -p 9001:9001 -p 9002:9002 -p 9003:9003 -p 9004:9004 -p 9005:9005 -p 9100:9100 <container_id>
- The server will be available at
localhost
Build amps.js and amps.d.ts (typings) - for testing and development
This command will validate formatting and and syntax of .ts files. Settings are available in deployment/tslint.json
npm run gen
Build distrubution package
The following command will build, minify, generage documentation, and archive the project:
npm run build
The output will be placed in the amps-javascript-client-.tar.gz file.
Alternatively you can:
- just build documentation files:
npm run docbuild
(will be available in build/docs
) - lint the project files:
npm run lint
- clear build files:
npm run clear
- run tests in the Node.js environment:
npm test
Running lint and tests is recommended before building a client package.