Fileverse Storage is a decentralized file storage service that handles secure file uploads through authorized UCANs (User Controlled Authorization Networks). It powers dSheet, Fileverse Portal, and other Fileverse applications, enabling decentralized, secure, and privacy-preserving file storage on IPFS.
- Decentralized Storage: Files are stored on IPFS using multiple providers (Pinata, Filebase, Web3.Storage)
- UCAN Authentication: Secure authentication using User Controlled Authorization Networks
- Storage Quotas: Built-in storage limit management and extension capabilities
- Community Sharing: Publish and discover files in the community marketplace
- Background Processing: Automatic cleanup of unpinned files and gate hashes
- Multi-Provider Support: Flexible IPFS storage with fallback providers
- Real-time Monitoring: Comprehensive logging and error reporting
- Node.js (v16 or higher)
- MongoDB database
- IPFS storage provider accounts (Pinata, Filebase, or Web3.Storage)
- Environment variables configured (see Configuration section)
-
Clone the repository
git clone <repository-url> cd fileverse-storage-v2
-
Install dependencies
npm install
-
Set up environment variables Create a
.env
file in the root directory with the required configuration (see Configuration section) -
Build the project
npm run build
Create a .env
file with the following variables:
# Database
MONGODB_URI=your_mongodb_connection_string
# IPFS Providers
PINATA_API_KEY=your_pinata_api_key
PINATA_SECRET_API_KEY=your_pinata_secret_key
FILEBASE_ACCESS_KEY=your_filebase_access_key
FILEBASE_SECRET_KEY=your_filebase_secret_key
WEB3_STORAGE_TOKEN=your_web3_storage_token
# Server
PORT=3000
NODE_ENV=development
# Blockchain
DEFAULT_CHAIN_ID=1
# Start development server with hot reload
npm run dev
# Start background job for unpinning gate hashes
npm run dev:unpin-gate-cron
# Start background job for unpinning deleted files
npm run dev:unpin-deleted-file-cron
# Build and start production server
npm run build
npm start
# Start background jobs
npm run start:unpin-gate-cron
npm run start:unpin-deleted-file-cron
curl http://localhost:3000/ping
# Response: {"reply":"pong"}
All authenticated endpoints require UCAN tokens in headers:
authorization
: Bearer tokencontract
: Contract addressinvoker
: Invoker addresschain
: Chain ID
POST /upload/
Content-Type: multipart/form-data
Authorization: Bearer <ucan_token>
Contract: <contract_address>
Invoker: <invoker_address>
Chain: <chain_id>
file: <file_data>
appFileId: <optional_app_file_id>
sourceApp: <optional_source_app>
ipfsType: <optional_ipfs_type>
tags: <optional_tags_array>
POST /upload/public
Content-Type: multipart/form-data
file: <file_data>
POST /upload/comment
Content-Type: multipart/form-data
file: <file_data>
GET /limit/check
Contract: <contract_address>
Invoker: <invoker_address>
Chain: <chain_id>
GET /limit/use
Contract: <contract_address>
Invoker: <invoker_address>
Chain: <chain_id>
PUT /limit/extend
Contract: <contract_address>
Invoker: <invoker_address>
Chain: <chain_id>
POST /community/publish
Content-Type: application/json
{
"publishedBy": "address",
"thumbnailIPFSHash": "hash",
"title": "file_title",
"category": "category",
"fileLink": "ipfs_link",
"dsheetId": "sheet_id",
"userHash": "user_hash",
"portalAddress": "portal_address"
}
GET /community/list?page=1&limit=10&category=docs&search=keyword&onlyFavorites=false&publishedBy=address
GET /community/:dsheetId
Contract: <contract_address>
POST /community/favourite
Content-Type: application/json
{
"dsheetId": "sheet_id",
"isFavourite": true
}
DELETE /file/:appFileId
Contract: <contract_address>
POST /users/address
src/
βββ app.ts # Express app configuration
βββ index.ts # Application entry point
βββ config/ # Configuration management
βββ domain/ # Business logic
β βββ communityFiles/ # Community file operations
β βββ contract/ # Blockchain contract interactions
β βββ file/ # File operations
β βββ ipfs/ # IPFS storage providers
β βββ limit/ # Storage quota management
β βββ upload.ts # File upload logic
βββ infra/ # Infrastructure layer
β βββ database/ # Database models and connection
β βββ ucan.ts # UCAN token verification
βββ interface/ # API routes and middleware
β βββ agenda/ # Background job scheduling
β βββ middleware/ # Express middleware
β βββ [routes]/ # API endpoint handlers
βββ types/ # TypeScript type definitions
npm run dev
- Start development servernpm run build
- Build TypeScript to JavaScriptnpm run start
- Start production servernpm run clean
- Remove build directorynpm run dev:unpin-gate-cron
- Start gate unpinning job (dev)npm run dev:unpin-deleted-file-cron
- Start deleted file unpinning job (dev)
The project uses TypeScript with strict type checking. Follow these guidelines:
- Use meaningful variable and function names
- Add proper type annotations
- Handle errors appropriately
- Write comprehensive tests for new features
- Follow the existing folder structure
- File: Stores file metadata and IPFS hashes
- CommunityFiles: Manages community-shared files
- Limit: Tracks storage quotas and usage
The application includes comprehensive logging using Bunyan and error reporting. Logs are structured and include:
- Request/response logging via Morgan
- Application-level logging via Bunyan
- Error tracking and reporting
- Performance monitoring
The application is configured for deployment on platforms like Heroku:
- Procfile is included for process management
- Build process is automated via npm scripts
- Environment variables should be configured in your deployment platform
- Background jobs should be deployed as separate processes
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature
- Make your changes and add tests
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin feature/your-feature
- Submit a pull request
This project is licensed under the ISC License.
For support and questions, please refer to the Fileverse documentation or create an issue in this repository.
Made with β€οΈ by the Fileverse team