https://github.com/andrew/js-ipfs-repo
Implementation of the IPFS Repo spec in JavaScript
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 35 committers (2.9%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (6.7%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
Implementation of the IPFS Repo spec in JavaScript
Basic Info
- Host: GitHub
- Owner: andrew
- License: mit
- Default Branch: master
- Homepage: https://github.com/ipfs/specs/tree/master/repo
- Size: 1.82 MB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 6
- Open Issues: 0
- Releases: 0
Fork of ipfs/js-ipfs-repo
Created over 6 years ago
· Last pushed over 6 years ago
https://github.com/andrew/js-ipfs-repo/blob/master/
# IPFS Repo JavaScript Implementation
[](http://ipn.io)
[](http://ipfs.io/)
[](http://webchat.freenode.net/?channels=%23ipfs)
[](https://github.com/RichardLitt/standard-readme)
[](https://travis-ci.com/ipfs/js-ipfs-repo)
[](https://codecov.io/gh/ipfs/js-ipfs-repo) [](https://david-dm.org/ipfs/js-ipfs-repo)
[](https://github.com/feross/standard)


> Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript
This is the implementation of the [IPFS repo spec](https://github.com/ipfs/specs/tree/master/repo) in JavaScript.
## Lead Maintainer
[Alex Potsides](https://github.com/achingbrain)
## Table of Contents
- [Background](#background)
- [Install](#install)
- [npm](#npm)
- [Use in Node.js](#use-in-nodejs)
- [Use in a browser with browserify, webpack or any other bundler](#use-in-a-browser-with-browserify-webpack-or-any-other-bundler)
- [Use in a browser Using a script tag](#use-in-a-browser-using-a-script-tag)
- [Usage](#usage)
- [API](#api)
- [Notes](#notes)
- [Contribute](#contribute)
- [License](#license)
## Background
Here is the architectural reasoning for this repo:
```bash
IPFSRepo
/
Datastore
/blocks /datastore
Datastore LevelDatastore
IPFSRepo - Default Node.js IPFSRepo - Default Browser
/ /
FsDatastore LevelJSDatastore
/blocks /datastore /blocks /datastore
FlatfsDatastore LevelDBDatastore LevelJSDatastore LevelJSDatastore
```
This provides a well defined interface for creating and interacting with an IPFS repo.
## Install
### npm
```sh
> npm install ipfs-repo
```
### Use in Node.js
```js
var IPFSRepo = require('ipfs-repo')
```
### Use in a browser with browserify, webpack or any other bundler
```js
var IPFSRepo = require('ipfs-repo')
```
### Use in a browser Using a script tag
Loading this module through a script tag will make the `IpfsRepo` obj available in the global namespace.
```html
```
## Usage
Example:
```js
const Repo = require('ipfs-repo')
const repo = new Repo('/tmp/ipfs-repo')
await repo.init({ cool: 'config' })
await repo.open()
console.log('repo is ready')
```
This now has created the following structure, either on disk or as an in memory representation:
```
blocks
SHARDING
_README
config
datastore
keys
version
```
## API
### Setup
#### `new Repo(path[, options])`
Creates an IPFS Repo.
Arguments:
* `path` (string, mandatory): the path for this repo
* `options` (object, optional): may contain the following values
* `autoMigrate` (bool, defaults to `true`): controls automatic migrations of repository.
* `lock` ([Lock](#lock) or string *Deprecated*): what type of lock to use. Lock has to be acquired when opening. string can be `"fs"` or `"memory"`.
* `storageBackends` (object, optional): may contain the following values, which should each be a class implementing the [datastore interface](https://github.com/ipfs/interface-datastore#readme):
* `root` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of values at the root (`repo.set()`, `repo.get()`)
* `blocks` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of values at `repo.blocks`.
* `keys` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of encrypted keys at `repo.keys`
* `datastore` (defaults to [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme)). Defines the back-end type used as the key-value store used for gets and puts of values at `repo.datastore`.
```js
const repo = new Repo('path/to/repo')
```
#### `Promise repo.init ()`
Creates the necessary folder structure inside the repo.
#### `Promise repo.open ()`
[Locks](https://en.wikipedia.org/wiki/Record_locking) the repo to prevent conflicts arising from simultaneous access.
#### `Promise repo.close ()`
Unlocks the repo.
#### `Promise repo.exists ()`
Tells whether this repo exists or not. Returned promise resolves to a `boolean`.
### Repos
Root repo:
#### `Promise repo.put (key, value:Buffer)`
Put a value at the root of the repo.
* `key` can be a buffer, a string or a [Key](https://github.com/ipfs/interface-datastore#keys).
#### `Promise repo.get (key)`
Get a value at the root of the repo.
* `key` can be a buffer, a string or a [Key](https://github.com/ipfs/interface-datastore#keys).
[Blocks](https://github.com/ipfs/js-ipfs-block#readme):
#### `Promise repo.isInitialized ()`
The returned promise resolves to `false` if the repo has not been initialized and `true` if it has.
#### `Promise repo.blocks.put (block:Block)`
* `block` should be of type [Block](https://github.com/ipfs/js-ipfs-block#readme).
#### `Promise repo.blocks.putMany (blocks)`
Put many blocks.
* `block` should be an Iterable or AsyncIterable that yields entries of type [Block](https://github.com/ipfs/js-ipfs-block#readme).
#### `Promise repo.blocks.get (cid)`
Get block.
* `cid` is the content id of [type CID](https://github.com/ipld/js-cid#readme).
Datastore:
#### `repo.datastore`
This contains a full implementation of [the `interface-datastore` API](https://github.com/ipfs/interface-datastore#api).
### Utils
#### `repo.config`
Instead of using `repo.set('config')` this exposes an API that allows you to set and get a decoded config object, as well as, in a safe manner, change any of the config values individually.
##### `Promise repo.config.set(key:string, value)`
Set a config value. `value` can be any object that is serializable to JSON.
* `key` is a string specifying the object path. Example:
```js
await repo.config.set('a.b.c', 'c value')
const config = await repo.config.get()
assert.equal(config.a.b.c, 'c value')
```
##### `Promise repo.config.set(value)`
Set the whole config value. `value` can be any object that is serializable to JSON.
##### `Promise> repo.config.get(key:string)`
Get a config value. Returned promise resolves to the same type that was set before.
* `key` is a string specifying the object path. Example:
```js
const value = await repo.config.get('a.b.c')
console.log('config.a.b.c = ', value)
```
##### `Promise
Owner
- Name: Andrew Nesbitt
- Login: andrew
- Kind: user
- Location: Bristol, UK
- Company: @ecosyste-ms and @octobox
- Website: https://nesbitt.io
- Twitter: teabass
- Repositories: 357
- Profile: https://github.com/andrew
Working on mapping the world of open source software @ecosyste-ms and empowering developers with @octobox
GitHub Events
Total
Last Year
Committers
Last synced: 10 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| David Dias | d****p@g****m | 168 |
| Jacob Heun | j****n@g****m | 55 |
| dignifiedquire | d****e@g****m | 27 |
| greenkeeperio-bot | s****t@g****o | 22 |
| achingbrain | a****x@a****t | 11 |
| Stephen Whitmore | s****e@g****m | 8 |
| Alan Shaw | a****w@p****i | 5 |
| Hugo Dias | m****l@h****e | 5 |
| Adam Uhlíř | a****m@u****v | 4 |
| Hugo Dias | h****s@g****m | 3 |
| Pau Ramon Revilla | m****m@g****m | 3 |
| Richard Schneider | m****u@g****m | 3 |
| Vasco Santos | v****s@m****o | 3 |
| Dmitriy Ryajov | d****v@g****m | 2 |
| Francisco Baio Dias | x****d@g****m | 2 |
| Lars-Magnus Skog | r****a@r****t | 2 |
| Brian Hoffman | h****c@u****m | 1 |
| Henrique Dias | h****s@g****m | 1 |
| Jacob Heun | j****e@a****t | 1 |
| Jonah Weissman | j****n@g****m | 1 |
| Jonathan | j****e@v****u | 1 |
| Justin Chase | j****e@g****m | 1 |
| Linus Unnebäck | l****s@f****e | 1 |
| Marcus Bernales | m****r@g****m | 1 |
| Pedro Santos | p****s@m****o | 1 |
| Pedro Santos | p****s@h****m | 1 |
| Pedro Teixeira | i@p****e | 1 |
| Richard Littauer | r****r@g****m | 1 |
| Steef Min | s****n@g****m | 1 |
| Vasco Santos | v****s@u****t | 1 |
| and 5 more... | ||
Committer Domains (Top 20 + Academic)
moxy.studio: 2
ua.pt: 1
pgte.me: 1
folkdatorn.se: 1
vt.edu: 1
andyet.net: 1
riseup.net: 1
uhlir.dev: 1
hugodias.me: 1
protocol.ai: 1
achingbrain.net: 1
greenkeeper.io: 1
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0