Skip to content

Example of how to customize the JS-IPFS repository

Notifications You must be signed in to change notification settings

ipfs-examples/js-ipfs-custom-ipfs-repo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IPFS in JavaScript logo

Custom IPFS repo

How to customize a IPFS repository


Explore the docs · View Demo · Report Bug · Request Feature/Example

Table of Contents

About The Project

Getting Started

Prerequisites

Make sure you have installed all of the following prerequisites on your development machine:

Installation and Running example

> npm install
> npm start

Usage

This example shows you how to customize your repository, including where your data is stored and how the repo locking is managed. Customizing your repo makes it easier to extend IPFS for your particular needs. You may want to customize your repo if:

  • If you want to store data somewhere that’s not on your local disk, like S3, a Redis instance, a different machine on your local network, or in your own database system, like MongoDB or PostgreSQL, you might use a custom datastore.
  • If you have multiple browser windows or workers sharing the same IPFS storage, you might want to use a custom lock to coordinate between them. (Locking is currently only used to ensure a single IPFS instance can access a repo at a time. This check is done on repo.open(). A more complex lock, coupled with a custom datastore, could allow for safe writes to a single datastore from multiple IPFS nodes.)

You can find full details on customization in the IPFS Repo Docs.

Custom storageBackends

This example leverages datastore-fs to store all data in the IPFS Repo. You can customize each of the 4 storageBackends to meet the needs of your project. For an example on how to manage your entire IPFS REPO on S3, you can see the datastore-s3 example.

Custom Repo Lock

This example uses one of the locks that comes with IPFS Repo. If you would like to control how locking happens, such as with a centralized S3 IPFS Repo, you can pass in your own custom lock. See custom-lock.js for an example of a custom lock that can be used for datastore-s3. This is also being used in the full S3 example.

import S3Lock from './custom-lock.js'

const repo = new Repo('/tmp/.ipfs', {
  ...
  lock: new S3Lock(s3DatastoreInstance)
})

For more examples, please refer to the Documentation

References

Documentation

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the IPFS Project
  2. Create your Feature Branch (git checkout -b feature/amazing-feature)
  3. Commit your Changes (git commit -a -m 'feat: add some amazing feature')
  4. Push to the Branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Want to hack on IPFS?

The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:

Read the Code of Conduct and JavaScript Contributing Guidelines.

  • Check out existing issues The issue list has many that are marked as 'help wanted' or 'difficulty:easy' which make great starting points for development, many of which can be tackled with no prior IPFS knowledge
  • Look at the IPFS Roadmap This are the high priority items being worked on right now
  • Perform code reviews More eyes will help a. speed the project along b. ensure quality, and c. reduce possible future bugs.
  • Add tests. There can never be enough tests.
  • Join the Weekly Core Implementations Call it's where everyone discusses what's going on with IPFS and what's next

About

Example of how to customize the JS-IPFS repository

Resources

Stars

Watchers

Forks