Skip to content

Host Library Microservice

The lib microservice is a simplified file manager that serves files over GraphQL and HTTP API.

It has two features:

  • Provide a listing of directory contents.
  • Upload and download files

This document provides instructions for installing the npm package of the library microservice and running the same as a standalone service.

Setup the File System

Outside the DTaaS Platform

The package can be used independently of the DTaaS. In this use case, no specific file structure is required. Any valid file directory is sufficient.

Inside the DTaaS Platform

The users of the DTaaS expect the following file system structure for their reusable assets.

File System Layout

A skeleton file structure is available in the DTaaS codebase. This can be copied to create a file system for users.

⬇ Install

The npm package is available in Github packages registry and on npmjs. Prefer the package on npmjs over Github.

Set the registry and install the package with the one of the two following commands

npmjs

sudo npm install -g @into-cps-association/libms  # requires no login

Github

# requires login
sudo npm config set @into-cps-association:registry https://npm.pkg.github.com

The github package registry 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.

🚀 Use

Display help.

$libms -h
Usage: libms [options]

The lib microservice is a file server. It supports file transfer
over GraphQL and HTTP protocols.

Options:
  -c, --config <file>  provide the config file (default libms.yaml)
  -H, --http <file>    enable the HTTP server with the specified config
  -h, --help           display help for libms

Both the options are not mandatory.

Please see configuration for explanation of configuration conventions. The config is saved libms.yaml file by convention. If -c is not specified The libms looks for libms.yaml 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 libms.yaml, for example as libms-config.yaml, you can run

$libms -c "config/libms-config.yaml"

You can press Ctl+C to halt the application. If you wish to run the microservice in the background, use

$nohup libms [-c FILE-PATH] & disown

The lib microservice is now running and ready to serve files.

Protocol Support

The libms supports GraphQL protocol by default. This microservice can also serve files in a browser with files transferred over HTTP protocol.

This option needs to be enabled with -H http.json flag. A sample http config provided here can be used.

$nohup libms [-H http.json] & disown

The regular file upload and download options become available.

Service Endpoints

The GraphQL URL: localhost:PORT/lib

The HTTP URL: localhost:PORT/lib/files

The service API documentation is available on user page.