Skip to content

Latest commit

 

History

History
 
 

lib

Overview

The lib microservice is a simplified file manager providing graphQL API. It has three features:

  • provide a listing of directory contents.
  • transfer a file to user.
  • Source files can either come from local file system or from a gitlab instance.

Gitlab setup

For this microserivce to be functional, a certain directory or gitlab project structure is expected. The microservice expects that the gitlab consisting of one group, dtaas (by convention), and within that group, all of the projects be located, user1, user2, ... , as well as a commons projects. Each project corresponds to files of one user. A sample file structure can be seen in gitlab dtaas group. You can visit the gitlab documentation on groups for help on the management of gitlab groups.

You can clone the git repositories from the gitlab dtaas group to get a sample file system structure for the lib microservice.

⬇️ Install

The package is available in Github packages registry.

Set the registry and install the package with the following commands

sudo npm config set @into-cps-association:registry https://npm.pkg.github.com
sudo npm install -g @into-cps-association/libms

The npm install command asks for username and password. The username is your Github username and the password is your Github personal access token. In order for the npm to download the package, your personal access token needs to have read:packages scope.

⚙️ Configure

The microservices requires config specified in INI format. The template configuration file is:

PORT='4001'
MODE='local' or 'gitlab'
LOCAL_PATH ='/Users/<Username>/DTaaS/files'
GITLAB_GROUP ='dtaas'
GITLAB_URL='https://gitlab.com/api/graphql'
TOKEN='123-sample-token'
LOG_LEVEL='debug'
APOLLO_PATH='/lib' or ''
GRAPHQL_PLAYGROUND='false' or 'true'

The LOCAL_PATH variable is the absolute filepath to the location of the local directory which will be served to users by the Library microservice.

The GITLAB_URL, GITLAB_GROUP and TOKEN are only relevant for gitlab mode. The TOKEN should be set to your GitLab Group access API token. For more information on how to create and use your access token, gitlab page.

Once you've generated a token, copy it and replace the value of TOKEN with your token for the gitlab group,

Replace the default values the appropriate values for your setup.

NOTE:

  1. When _MODE=local, only LOCAL_PATH is used. Other environment variables are unused.
  2. When MODE=gitlab, GITLAB_URL, TOKEN, and GITLAB_GROUP are used; LOCAL_PATH is unused.

🚀 Use

Display help.

libms -h

The config is saved .env file by convention. The libms looks for .env file in the working directory from which it is run. If you want to run libms without explicitly specifying the configuration file, run

libms

To run libms with a custom config file,

libms -c FILE-PATH
libms --config FILE-PATH

If the environment file is named something other than .env, for example as .env.development, you can run

libms -c ".env.development"

You can press Ctl+C to halt the application.

The microservice is available at: 'localhost:PORT/lib'

The API page shows sample queries and responses.