diff --git a/README.md b/README.md index e777b06..60658b3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# js-datastore-s3 +# js-datastore-s3 [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai/) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) @@ -9,13 +9,15 @@ > Datastore implementation backed by s3. -## Lead Maintainer +## Lead Maintainer [Jacob Heun](https://github.com/jacobheun) -## Table of Contents +## Table of Contents - [Install](#install) - [Usage](#usage) + - [Create a Repo](#create-a-repo) + - [Examples](#examples) - [Contribute](#contribute) - [License](#license) @@ -39,20 +41,8 @@ const store = new S3Store('.ipfs/datastore', { ``` ### Create a Repo -You can quickly create an S3 backed repo using the `createRepo` convenience function. -```js -const IPFS = require('ipfs') -const { createRepo } = require('datastore-s3') - -const ipfs = new IPFS({ - repo: createRepo({ - path: '/my/ipfs' - }, { - bucket: 'MyS3Bucket' - }) -}) -``` +See [examples/full-s3-repo](./examples/full-s3-repo) for how to quickly create an S3 backed repo using the `createRepo` convenience function. ### Examples You can see examples of S3 backed ipfs in the [examples folder](examples/) diff --git a/src/s3-repo.js b/examples/full-s3-repo/create-s3-repo.js similarity index 74% rename from src/s3-repo.js rename to examples/full-s3-repo/create-s3-repo.js index 3013fde..5530532 100644 --- a/src/s3-repo.js +++ b/examples/full-s3-repo/create-s3-repo.js @@ -44,8 +44,7 @@ const createRepo = (S3Store, options, s3Options) => { accessKeyId, secretAccessKey }), - createIfMissing, - sharding: true + createIfMissing } // If no lock is given, create a mock lock @@ -60,11 +59,26 @@ const createRepo = (S3Store, options, s3Options) => { pins: S3Store }, storageBackendOptions: { - root: storeConfig, - blocks: storeConfig, - keys: storeConfig, - datastore: storeConfig, - pins: storeConfig + root: { + ...storeConfig, + sharding: false + }, + blocks: { + ...storeConfig, + sharding: true + }, + keys: { + ...storeConfig, + sharding: false + }, + datastore: { + ...storeConfig, + sharding: false + }, + pins: { + ...storeConfig, + sharding: true + } }, lock: lock }) diff --git a/examples/full-s3-repo/index.js b/examples/full-s3-repo/index.js index e251c24..5942148 100644 --- a/examples/full-s3-repo/index.js +++ b/examples/full-s3-repo/index.js @@ -1,8 +1,8 @@ 'use strict' const IPFS = require('ipfs') -const { createRepo } = require('datastore-s3') const toBuffer = require('it-to-buffer') +const createRepo = require('./create-s3-repo') ;(async () => { // Create the repo diff --git a/examples/full-s3-repo/package.json b/examples/full-s3-repo/package.json index 7e9619e..59ce9ff 100644 --- a/examples/full-s3-repo/package.json +++ b/examples/full-s3-repo/package.json @@ -10,10 +10,10 @@ "author": "", "license": "ISC", "dependencies": { - "aws-sdk": "^2.579.0", + "aws-sdk": "^2.885.0", "datastore-s3": "../../", - "ipfs": "^0.50.2", - "ipfs-repo": "^6.0.3", - "it-to-buffer": "^1.0.2" + "ipfs": "^0.54.4", + "ipfs-repo": "^9.0.0", + "it-to-buffer": "^2.0.0" } } diff --git a/package.json b/package.json index 09c5c44..6ae8bb3 100644 --- a/package.json +++ b/package.json @@ -46,14 +46,9 @@ "aws-sdk": "^2.579.0", "chai": "^4.2.0", "dirty-chai": "^2.0.1", - "ipfs-repo": "9.0.0", "stand-in": "^4.2.0", "util": "^0.12.3" }, - "peerDependencies": { - "aws-sdk": "2.x", - "ipfs-repo": "^9.0.0" - }, "contributors": [ "Jacob Heun ", "achingbrain ", diff --git a/src/index.js b/src/index.js index 7cca370..1a68c9f 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,6 @@ const { Key, Errors } = require('interface-datastore') -const createRepo = require('./s3-repo') /** * @typedef {import('interface-datastore').Pair} Pair @@ -268,6 +267,3 @@ class S3Datastore extends Adapter { } module.exports = S3Datastore -module.exports.createRepo = (...args) => { - return createRepo(S3Datastore, ...args) -} diff --git a/test/index.spec.js b/test/index.spec.js index 22de60a..d2eceb8 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -13,7 +13,6 @@ const S3 = require('aws-sdk').S3 const S3Mock = require('./utils/s3-mock') const { s3Resolve, s3Reject, S3Error } = S3Mock const S3Store = require('../src') -const { createRepo } = require('../src') describe('S3Datastore', () => { describe('construction', () => { @@ -202,20 +201,6 @@ describe('S3Datastore', () => { }) }) - describe('createRepo', () => { - it('should be able to create a repo', () => { - const path = '.ipfs' - const repo = createRepo({ - path - }, { - bucket: 'my-ipfs-bucket' - }) - - expect(repo).to.exist() - expect(repo.path).to.eql(path) - }) - }) - describe('interface-datastore', () => { require('interface-datastore/src/tests')({ setup () {