npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rsksmart/rif-marketplace-upload-service

v0.2.1

Published

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

Downloads

18

Readme

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