Skip to content

javibookline/jambonz-api-server

 
 

Repository files navigation

jambonz-api-server Build Status

Jambones REST API server of the jambones platform.

Configuration

Configuration is provided via environment variables:

variable meaning required?
JWT_SECRET secret for signing JWT token yes
JWT_EXPIRES_IN expiration time for JWT token(in minutes) no
ENCRYPTION_SECRET secret for credential encryption(JWT_SECRET is deprecated) yes
HTTP_PORT tcp port to listen on for API requests from jambonz-api-server no
JAMBONES_LOGLEVEL log level for application, 'info' or 'debug' no
JAMBONES_MYSQL_HOST mysql host yes
JAMBONES_MYSQL_USER mysql username yes
JAMBONES_MYSQL_PASSWORD mysql password yes
JAMBONES_MYSQL_DATABASE mysql data yes
JAMBONES_MYSQL_PORT mysql port no
JAMBONES_MYSQL_CONNECTION_LIMIT mysql connection limit no
JAMBONES_REDIS_HOST redis host yes
JAMBONES_REDIS_PORT redis port no
RATE_LIMIT_WINDOWS_MINS rate limit window no
RATE_LIMIT_MAX_PER_WINDOW number of requests per window no
JAMBONES_TRUST_PROXY trust proxies, must be a number no
JAMBONES_API_VERSION api version no
JAMBONES_TIME_SERIES_HOST influxdb host yes
JAMBONES_CLUSTER_ID cluster id no
HOMER_BASE_URL HOMER URL no
HOMER_USERNAME HOMER username no
HOMER_PASSWORD HOMER password no
K8S service running as kubernetes service no
K8S_FEATURE_SERVER_SERVICE_NAME feature server name(required for K8S) no
K8S_FEATURE_SERVER_SERVICE_PORT feature server port(required for K8S) no

Database dependency

A mysql database is used to store long-lived objects such as Accounts, Applications, etc. To create the database schema, use or review the scripts in the 'db' folder, particularly:

Note: due to the dependency on the npmjs mysql package, the mysql database must be configured to use sql native authentication.

Running the app

At this point, if you have followed the above instructions, its simply

npm install
node app

The server will listen by default on port 3000, to change this set the HTTP_PORT environment variable:

HTTP_PORT=4000 node app

Running the test suite

To run the included test suite, you will need to have a mysql server installed on your laptop/server. You will need to set the MYSQL_ROOT_PASSWORD env variable to the mysql root password before running the tests. The test suite creates a database named 'jambones_test' in your mysql server to run the tests against, and removes it when done.

MYSQL_ROOT_PASSWORD=foobar npm test

Testing a deployed server

There is a swagger endpoint at http://<your-ip>:3000/swagger that can be used to exercise the APIs. Bearer authentication is required, so you will need an auth token (refer to create-admin-token.sql to see how to generate one).s

About

jambones REST APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.8%
  • Other 0.2%