This app enables stopwatch functionality for Eliona.
This app needs no configuration over api or database. Just use the new added asset type Stopwatch
to start and stop an second counter as many you want.
To start and initialize an app in an Eliona environment, the app have to registered in Eliona. For this, an entry stopwatch
in the database table public.eliona_app
is necessary.
-
CONNECTION_STRING
: configures the Eliona database. Otherwise, the app can't be initialized and started (e.g.postgres://user:pass@localhost:5432/iot
). -
INIT_CONNECTION_STRING
: configures the Eliona database for app initialization like creating schema and tables (e.g.postgres://user:pass@localhost:5432/iot
). Default is content ofCONNECTION_STRING
. -
API_ENDPOINT
: configures the endpoint to access the Eliona API v2. Otherwise, the app can't be initialized and started. (e.g.http://api-v2:3000/v2
) -
API_TOKEN
: defines the secret to authenticate the app and access the API. -
API_SERVER_PORT
(optional): define the port the API server listens. The default value is Port3000
. -
DEBUG_LEVEL
(optional): defines the minimum level that should be logged. Not defined the default level isinfo
.
This app works without any database tables.
The app provides its own API to access configuration data and other functions. The full description of the API is defined in the openapi.yaml
OpenAPI definition file.
- API Reference shows Details of the API
Generation: to generate api server stub see Generation section below.
This app provides a start and a stop input (Button) to start or stop the stopwatch. In Current Value the time in seconds will provided to eliona until the timer has stopped. Then the Last Value will be actualized and the Current Value will be set to 0.
The code can be tested by running go test
For the API server the OpenAPI Generator for go-server is used to generate a server stub. The easiest way to generate the server files is to use one of the predefined generation script which use the OpenAPI Generator Docker image.
.\generate-api-server.cmd # Windows
./generate-api-server.sh # Linux
For the database access SQLBoiler is used. The easiest way to generate the database files is to use one of the predefined generation script which use the SQLBoiler implementation. Please note that the database connection in the sqlboiler.toml
file have to be configured.
.\generate-db.cmd # Windows
./generate-db.sh # Linux
- Native
- Install deps:
go install .
- Build:
go build .
- Install deps:
- Docker
docker build . --tag my-stopwatch