Digital Enhanced Living service management APIs
This service is still under development and features are constantly being added. Additions may break existing functionality. Please refer to the development branch for the latest changes.
The Digital Enhanced Living (DEL) api (del-api) service is the management module for the DEL platform and handles user profiles, application details and tracks linked services and user activities on the container application. The service will be expanded to add more features including health metric tracking and mHealth profiles for remote health management by caregivers.
The service has been configured with Swagger UI for quick visualisation and interaction with the service and is available at hostname:port
Other services contributing to the platform include del-auth, del-web and del-container. More details can be found on their respective pages.
Please note that the repositories may be private at the moment and will be made public as they are developed.
The service is built using JavaScript (NodeJS) and uses MongoDb for storage. For testing, please ensure both are installed.
To install dependencies, execute the following from the cloned directory:
$ npm install
The following script will start the mongo daemon if not already running:
$ ./start_mongo.sh
Once the setup is complete, the service can be launched (in dev mode) using:
$ npm run dev_local
Once running, the api documentation can be viewed through the SwaggerUI at {host}:{port}/docs
The application has also been dockerized to simplify deployment and can also be launched using docker-compose. This may be useful for quick deployments where you want to avoid local package installation. However, the app image must be built prior to deployment using the command:
$ docker build -t del/del-api .
Run the following to launch the application:
$ docker-compose up -d
The containers can be shut down using:
$ docker-compose down
If the app image is built several times, it may occupy a significant amount of system storage. In that case, you may delete the app images and reclaim memory. Please note that the following commands remove all images, containers and volumes. If other images are present on the system, the del-api images should be removed individually to avoid deleting other images. For more details, please refer to the docker reference documentation.
$ docker image rmi $(docker images -a -q)
$ docker volume prune
$ docker system prune
Please ensure that you have installed the docker engine and docker-compose before running the above.
Please note that if you are making changes to the code, the app image will have to be built each time to run the latest updates.
Similarly, the .example_env file contains the DB_HOST value set to the docker service name. Please update this value if you are not using Docker.
The del-api service requires several environmental variables to define runtime settings as well as parameters for default service profiles. These can be exported to the bash environment OR stored in a .env
file as key-value pairs such as:
PORT=3000
JWT_ALGORITHM="HS256"
The service will recognise the file and read on launch.
Host parameters
Key | Description | Default Value |
---|---|---|
HOST |
Application hostname | localhost |
PORT |
Application port number | 3000 |
Database parameters
Key | Description | Default Value |
---|---|---|
DB_DATABASE |
The application database. This value should be changed to mongo_del for docker deployments | del_api |
DB_HOST |
The database hostname. This value should be modified in the .env file for docker deployments | localhost |
DB_PORT |
The database port | 27017 |
Authentication parameters
Key | Description | Default Value |
---|---|---|
JWT_SECRET_KEY |
The secret key used in the token generation/verification algorithm | none |
JWT_ALGORITHM |
The algorithm used for generating and verifying tokens | HS256 |
JWT_DEFAULT_EXPIRY |
The default validity duration for a token. Valid values include strings such as "1d", "60s", "1m" "1h" for 1 day, 60 seconds, 1 minute or 1 hour | 1d |
AUTH_STRATEGY |
Authentication strategy name used to refer to the mechanism from plugin registration to routes | jwt_auth |
Default superuser profile
Key | Description | Default Value |
---|---|---|
SU_FIRSTNAME |
Superuser first name | admin |
SU_LASTNAME |
Superuser last name | admin |
SU_EMAILID |
Superuser email id (this will be the default admin login credential) | admin@mail.com |
SU_AGE |
Superuser age (doesn't matter for the superuser and can be any number) | 40 |
SU_SEX |
Superuser gender (doesn't matter for the superuser) | Male |
SU_PASSWORD |
Superuser password | @dminpassword! |
SU_USERROLE |
Superuser role | admin |
Default developer profile
This profile describes the default publisher of health services
Key | Description | Default Value |
---|---|---|
DEV_NAME |
Default developer name. Jsut like the superuser, this profile cannot be deleted. | del_developer |
Dialogflow Integration
This service provides a chatbot based on Dialogflow and requires the Google project id and the authentication key
Key | Description | Default Value |
---|---|---|
DIALOGFLOW_PROJECT_ID |
The dialogflow project id | none |
GOOGLE_APPLICATION_CREDENTIALS |
Google application credentials | none |
More details to come soon!