This repository is part of the PSF File Pinning Service network. It is the back-end component for uploading files to the PSFFPP network. The front-end user interface code base in the explorer.psffpp.com code base.
A live version of the this back-end codebase is available at file-stage.fullstack.cash. A live version of the front-end user interface is available at explorer.psffpp.com.
This code base is forked from ipfs-service-provider. It has adds these features:
-
It adds a REST API endpoint allowing files to be uploaded via HTTP. All files received will be added to the embedded Helia IPFS node. This will stage the file so that it can be picked up by nodes running the ipfs-file-pin-service software, if the user makes a Pin Claim for the uploaded file.
-
Uploaded files are automatically deleted after 24 hours. This is long enough to stage the file for a Pin Claim. This software is not intended to host files for free for a long period of time.
Optional Features:
- Setting the
enableBchPayments
flag in the config will turn on BCH payments. This will:- Opens the
POST /ipfs/getPaymentAddr
endpoint that allows users to obtain a BCH payment address. - Opens the
POST /ipfs/createPinClaim
endpoint that allows users to pay a Pin Claim via the BCH payment address. - The app will generate its own wallet.json file on startup, if it does not already exist. That wallet can be loaded with BCH and PSF tokens. The app will then be able to generate Pin Claims for payment in BCH. It will burn its own stash of PSF tokens to generate the PSF token and pass on the cost (plus a markup) to the end user in BCH.
- Opens the
- node ^20.16.0
- npm ^10.8.1
- Docker ^24.0.7
- Docker Compose ^1.27.4
The docker directory contains a Dockerfile for building a production deployment.
docker-compose pull
docker-compose up -d
- You can bring the containers down with
docker-compose down
- You can bring the containers back up with
docker-compose up -d
.
Optional: If you want to enable BCH payments:
- Generate a wallet.json file with psf-bch-wallet and put it in the same directory as the docker-compose.yml file.
- Add a property
nextAddress
to the wallet file, with a value of2
. - Uncomment the volume line in docker-compose.yml, so the wallet file is mounted on startup.
- Uncomment the
ENABLE_BCH_PAYMENTS
environment variable in the start-production.sh file.
A development environment will allow you modify the code on-the-fly and contribute to the code base of this repository. Ubuntu v20 is the recommended OS for creating a dev environment. Other operating systems may cause issues.
git clone https://github.com/Permissionless-Software-Foundation/ipfs-file-stager
cd ipfs-file-stager
./install-mongo-sh
npm install
npm start
This app is intended to be started via a bash shell script. See the environment variables used to configure this app in the config/env/common.js file.
The file layout of this repository follows the file layout of Clean Architecture. Understaning the principles laid out this article will help developers navigate the code base.
npm start
Start server on live modenpm run docs
Generate API documentationnpm test
Run mocha tests
API documentation is written inline and generated by apidoc. Docs can be generated with this command:
npm run docs
Visit http://localhost:5020/
to view docs
There is additional developer documentation in the dev-docs directory.
- koa2
- koa-router
- koa-bodyparser
- koa-generic-session
- koa-logger
- MongoDB
- Mongoose
- Passport
- Nodemon
- Mocha
- apidoc
- ESLint
- ipfs-coord
Snapshots pinned to IPFS will be listed here.