Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rsksmart/rif-marketplace-upload-service

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rsksmart/rif-marketplace-upload-service

Service for Uploading files to Storage Providers(IPFS, Swarm, ...)

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

RIF Marketplace Upload Service

CircleCI Dependency Status standard-readme compliant js-standard-style Managed by tAsEgir

Service that allow to upload file to IPFS

Warning: This project is in alpha state. There might (and most probably will) be changes in the future to its API and working. Also, no guarantees can be made about its stability, efficiency, and security at this stage.

Lead Maintainer

Nazar Duchak

See what "Lead Maintainer" means here.

Table of Contents

Introduction

This is a backend service for uploading files to IPFS which communicate with pinners using libp2p. It is build using FeathersJS

API

Upload

This api allow you to upload file

POST: /upload

MultiPartFormData: {
  files: File1,
  files: File2,
  account: string,
  offerId: string,
  peerId: string,
  contractAddress: string
}
{
  message: 'File uploaded',
  fileHash: 'Qmasv234cksldmfFileHash'
}

Get File Size

This api allow you to get size of the file by file hash

GET: /fileSize?hash=<fileHash>
{
  fileHash: 'Qmasv234cksldmfFileHash',
  fileSizeBytes: 10231
}

Get File Size Limit

This endpoint exposes the max supported size in bytes

GET: /fileSizeLimit
{
  fileSizeLimit: 1073741824
}

Configuration

Required reading: node-config docs

There are several ways how to configure this application:

  1. Using JSON file
  2. Using Environmental variables
  3. Using CLI parameters

To run this upload service there is minimum configuration needed, which is supported with all the configuration ways mentioned above:

  • Database connection
  • Storage provider connection (IPFS)
  • Libp2p bootstrap nodes list

For general overview of complete configuration options see Config interface that describe configuration object's properties. If you need advanced configuration you can build your own JSON configuration file and load that either using the --config CLI parameter or using environment variable RIFMUS_CONFIG.

Environment variables overview

  • RIFMUS_PORT (number): port on which the server should listen to
  • RIFMUS_DB (string): database connection URI
  • RIFMUS_NETWORK_ID (number): network id
  • RIFMUS_IPFS_URL (string): IPFS Node url
  • RIFMUS_COMMS_LISTEN (array) - Defines an array of multiaddress that the Upload service libp2p node will listen on. Same as libp2p config's address.listen property.
  • RIFMUS_COMMS_BOOTSTRAP_ENABLED (true/false) - Defines if bootstrap should be used. Same as libp2p config's bootstrap.enabled property.
  • RIFMUS_COMMS_BOOTSTRAP_LIST (array) - Defines an array of multiaddress that the Upload service libp2p node will use to bootstrap its connectivity. Same as libp2p config's bootstrap.list property.
  • CORS settings (see more on expressjs documentation):
    • RIFMUS_CORS_ORIGIN (boolean | string | regexp): Configures the Access-Control-Allow-Origin CORS header
    • RIFMUS_CORS_METHODS (string) Configures the Access-Control-Allow-Methods CORS header
  • Logging related (see bellow):
    • LOG_LEVEL (string)
    • LOG_FILTER (string)
    • LOG_PATH (string)
    • LOG_NO_COLORS (boolean) - if set the output won't be colorized

Usage

$ npm install -g @rsksmart/rif-marketplace-upload-service

// Connection to your database
$ export RIFMUS_DB=myDbFile.sqlite

// Database migrations
$ rif-marketplace-upload-service db-migration --up

// Start the server
$ rif-marketplace-upload-service start --port 8000

Commands

rif-marketplace-cache db-migration

migrate database schema

USAGE
  $ rif-marketplace-upload-service db-migration

OPTIONS
  -d, --down                           Undo db migrations
  -d, --generate=generate              Generate migrations using template [--generate=migration_name]
  -m, --migration=migration            Migration file
  -t, --to=to                          Migrate to
  -u, --up                             Migrate DB
  --config=config                      path to JSON config file to load
  --db=db                              database connection URI
  --log=error|warn|info|verbose|debug  [default: info] what level of information to log
  --log-filter=log-filter              what components should be logged (+-, chars allowed)
  --log-path=log-path                  log to file, default is STDOUT

EXAMPLES
  $ rif-marketplace-upload-service db-migration --up
  $ rif-marketplace-upload-service db-migration --down
  $ rif-marketplace-upload-service db-migration --up --to 0-test
  $ rif-marketplace-upload-service db-migration --up --migrations 01-test --migrations 02-test
  $ rif-marketplace-upload-service db-migration --up --db ./test.sqlite --to 09-test
  $ rif-marketplace-upload-service db-migration --down --db ./test.sqlite --to 09-test
  $ rif-marketplace-upload-service db-migration --generate my_first_migration

rif-marketplace-upload-service purge

purge cached data

USAGE
  $ rif-marketplace-upload-service purge

OPTIONS
  --config=config                      path to JSON config file to load
  --log=error|warn|info|verbose|debug  [default: warn] what level of information to log
  --log-filter=log-filter              what components should be logged (+-, chars allowed)
  --log-path=log-path                  log to file, default is STDOUT

EXAMPLE
  $ rif-marketplace-upload-service purge
rif-marketplace-upload-service start

start the upload service

USAGE
  $ rif-marketplace-upload-service start

OPTIONS
  -p, --port=port                      port to attach the server to
  --config=config                      path to JSON config file to load
  --db=db                              database connection URI
  --log=error|warn|info|verbose|debug  [default: warn] what level of information to log
  --log-filter=log-filter              what components should be logged (+-, chars allowed)
  --log-path=log-path                  log to file, default is STDOUT

EXAMPLE
  $ rif-marketplace-upload-service start

License

MIT

Keywords

FAQs

Package last updated on 04 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc