This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: split daemon out into module (#3423)
The daemon is a way of exposing IPFS functionality that's used by the CLI, in the same way that IPFS itself is used by the CLI so split it out into it's own module for better separation of concerns.
- Loading branch information
1 parent
af0b7f3
commit 950392e
Showing
18 changed files
with
267 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"keywords": [ | ||
"IPFS" | ||
], | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs#readme", | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-cli#readme", | ||
"bugs": "https://github.com/ipfs/js-ipfs/issues", | ||
"license": "(Apache-2.0 OR MIT)", | ||
"leadMaintainer": "Alex Potsides <[email protected]>", | ||
|
@@ -34,15 +34,13 @@ | |
"cid-tool": "^1.0.0", | ||
"cids": "^1.0.0", | ||
"debug": "^4.1.1", | ||
"dlv": "^1.1.3", | ||
"err-code": "^2.0.3", | ||
"execa": "^4.0.3", | ||
"get-folder-size": "^2.0.1", | ||
"ipfs-core": "^0.3.0", | ||
"ipfs-core-utils": "^0.5.3", | ||
"ipfs-daemon": "^0.3.1", | ||
"ipfs-http-client": "^48.1.2", | ||
"ipfs-http-gateway": "^0.1.3", | ||
"ipfs-http-server": "^0.1.3", | ||
"ipfs-repo": "^7.0.0", | ||
"ipfs-utils": "^5.0.0", | ||
"ipld-dag-cbor": "^0.17.0", | ||
|
@@ -53,12 +51,7 @@ | |
"it-glob": "0.0.10", | ||
"it-pipe": "^1.1.0", | ||
"jsondiffpatch": "^0.4.1", | ||
"just-safe-set": "^2.1.0", | ||
"libp2p": "^0.29.3", | ||
"libp2p-crypto": "^0.18.0", | ||
"libp2p-delegated-content-routing": "^0.8.0", | ||
"libp2p-delegated-peer-routing": "^0.8.0", | ||
"libp2p-webrtc-star": "^0.20.1", | ||
"mafmt": "^8.0.0", | ||
"multiaddr": "^8.0.0", | ||
"multiaddr-to-uri": "^6.0.0", | ||
|
@@ -83,13 +76,5 @@ | |
"string-argv": "^0.3.1", | ||
"temp-write": "^4.0.0", | ||
"typescript": "4.0.x" | ||
}, | ||
"optionalDependencies": { | ||
"prom-client": "^12.0.0", | ||
"prometheus-gc-stats": "^0.6.0" | ||
}, | ||
"peerDependencies": { | ||
"electron-webrtc": "^0.3.0", | ||
"wrtc": "^0.4.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ | |
{ | ||
"path": "../ipfs-core-utils" | ||
}, | ||
{ | ||
"path": "../ipfs-daemon" | ||
}, | ||
{ | ||
"path": "../ipfs-http-client" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"keywords": [ | ||
"IPFS" | ||
], | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs#readme", | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core#readme", | ||
"bugs": "https://github.com/ipfs/js-ipfs/issues", | ||
"license": "(Apache-2.0 OR MIT)", | ||
"leadMaintainer": "Alex Potsides <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "ipfs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contributor Code of Conduct | ||
|
||
The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Contributing guidelines | ||
|
||
IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). | ||
|
||
We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. | ||
|
||
We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. | ||
|
||
Thank you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. | ||
Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by | ||
a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is | ||
licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) | ||
are licensed under a dual MIT/Apache-2.0 license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
The MIT License (MIT) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# ipfs-daemon <!-- omit in toc --> | ||
|
||
> The implementation of the js-IPFS daemon | ||
## Lead Maintainer <!-- omit in toc --> | ||
|
||
[Alex Potsides](http://github.com/achingbrain) | ||
|
||
## Table of Contents <!-- omit in toc --> | ||
|
||
- [Install](#install) | ||
- [Want to hack on IPFS?](#want-to-hack-on-ipfs) | ||
- [License](#license) | ||
|
||
## Install | ||
|
||
You probably don't need to install this module directly, use it by installing the `ipfs` module: | ||
|
||
```console | ||
$ npm install -g ipfs | ||
// npm install output | ||
$ jsipfs daemon | ||
``` | ||
|
||
## Want to hack on IPFS? | ||
|
||
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) | ||
|
||
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](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). | ||
|
||
- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge | ||
- **Look at the [IPFS Roadmap](https://github.com/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](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next | ||
|
||
## License | ||
|
||
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.jparrowsec.cn%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.jparrowsec.cn%2Fipfs%2Fjs-ipfs?ref=badge_large) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "ipfs-daemon", | ||
"version": "0.3.1", | ||
"description": "JavaScript implementation of the IPFS specification", | ||
"keywords": [ | ||
"IPFS" | ||
], | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-daemon#readme", | ||
"bugs": "https://github.com/ipfs/js-ipfs/issues", | ||
"license": "(Apache-2.0 OR MIT)", | ||
"leadMaintainer": "Alex Potsides <[email protected]>", | ||
"files": [ | ||
"src", | ||
"dist" | ||
], | ||
"main": "src/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ipfs/js-ipfs.git" | ||
}, | ||
"scripts": { | ||
"lint": "aegir lint", | ||
"build": "npm run build:types", | ||
"build:types": "tsc --build", | ||
"test": "npm run test:node", | ||
"test:node": "aegir test -t node", | ||
"coverage": "nyc --reporter=text --reporter=lcov npm run test:node", | ||
"clean": "rimraf ./dist", | ||
"dep-check": "aegir dep-check -i @types/yargs -i typescript" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.1.1", | ||
"dlv": "^1.1.3", | ||
"ipfs-core": "^0.3.0", | ||
"ipfs-http-client": "^48.1.2", | ||
"ipfs-http-gateway": "^0.1.3", | ||
"ipfs-http-server": "^0.1.3", | ||
"ipfs-utils": "^5.0.0", | ||
"just-safe-set": "^2.1.0", | ||
"libp2p": "^0.29.3", | ||
"libp2p-delegated-content-routing": "^0.8.0", | ||
"libp2p-delegated-peer-routing": "^0.8.0", | ||
"libp2p-webrtc-star": "^0.20.1", | ||
"multiaddr": "^8.0.0" | ||
}, | ||
"devDependencies": { | ||
"aegir": "^28.2.0", | ||
"node-fetch": "^2.6.1", | ||
"typescript": "4.0.x" | ||
}, | ||
"optionalDependencies": { | ||
"prom-client": "^12.0.0", | ||
"prometheus-gc-stats": "^0.6.0" | ||
}, | ||
"peerDependencies": { | ||
"electron-webrtc": "^0.3.0", | ||
"wrtc": "^0.4.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const { expect } = require('aegir/utils/chai') | ||
const Daemon = require('../') | ||
const fetch = require('node-fetch') | ||
|
||
describe('daemon', () => { | ||
let daemon | ||
|
||
it('should start a http api server', async () => { | ||
daemon = new Daemon({}) | ||
|
||
await daemon.start() | ||
|
||
const { | ||
uri | ||
} = daemon._httpApi._apiServers[0].info | ||
|
||
const httpId = (await fetch(`${uri}/api/v0/id`, { | ||
method: 'POST' | ||
})).json() | ||
|
||
const apiId = await daemon._ipfs.id() | ||
|
||
await expect(httpId).to.eventually.have.property('PublicKey', apiId.publicKey) | ||
|
||
await daemon.stop() | ||
}) | ||
|
||
it('should start a http gateway server', async () => { | ||
daemon = new Daemon({}) | ||
|
||
await daemon.start() | ||
|
||
const { | ||
uri | ||
} = daemon._httpGateway._gatewayServers[0].info | ||
|
||
const result = await (await fetch(`${uri}/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn`, { | ||
method: 'POST' | ||
})).text() | ||
|
||
expect(result).to.include('Index of /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/') | ||
|
||
await daemon.stop() | ||
}) | ||
|
||
it('should stop', async () => { | ||
daemon = new Daemon({}) | ||
|
||
await daemon.start() | ||
await daemon.stop() | ||
|
||
const { | ||
uri | ||
} = daemon._httpApi._apiServers[0].info | ||
|
||
await expect(fetch(`${uri}/api/v0/id`, { | ||
method: 'POST' | ||
})).to.eventually.be.rejectedWith(/ECONNREFUSED/) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": [ | ||
"src", | ||
"package.json" | ||
], | ||
"references": [ | ||
{ | ||
"path": "../ipfs-core" | ||
}, | ||
{ | ||
"path": "../ipfs-core-utils" | ||
}, | ||
{ | ||
"path": "../ipfs-http-client" | ||
}, | ||
{ | ||
"path": "../ipfs-http-gateway" | ||
}, | ||
{ | ||
"path": "../ipfs-http-server" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"keywords": [ | ||
"IPFS" | ||
], | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs#readme", | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-gateway#readme", | ||
"bugs": "https://github.com/ipfs/js-ipfs/issues", | ||
"license": "(Apache-2.0 OR MIT)", | ||
"leadMaintainer": "Alex Potsides <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"keywords": [ | ||
"IPFS" | ||
], | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs#readme", | ||
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-server#readme", | ||
"bugs": "https://github.com/ipfs/js-ipfs/issues", | ||
"license": "(Apache-2.0 OR MIT)", | ||
"leadMaintainer": "Alex Potsides <[email protected]>", | ||
|
Oops, something went wrong.