Skip to content

Commit 41e7902

Browse files
hacdiasachingbrainlidel
authored
fix!: conform to Delegated Routing V1 HTTP spec (#41)
Conform to Routing V1 HTTP spec: https://specs.ipfs.tech/routing/http-routing-v1/ Renames project to include "Delegated" terminology that appeared in the spec recently. BREAKING CHANGE: method signatures have changed to be closer to the delegated http routing v1 API spec --------- Co-authored-by: achingbrain <[email protected]> Co-authored-by: Marcin Rataj <[email protected]>
1 parent 7dac713 commit 41e7902

File tree

21 files changed

+859
-181
lines changed

21 files changed

+859
-181
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
</a>
55
</p>
66

7-
# helia-routing-v1-http-api <!-- omit in toc -->
7+
# helia-delegated-routing-v1-http-api <!-- omit in toc -->
88

99
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
1010
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
11-
[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-routing-v1-http-api.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-routing-v1-http-api)
12-
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-routing-v1-http-api/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-routing-v1-http-api/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
11+
[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-delegated-routing-v1-http-api.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-delegated-routing-v1-http-api)
12+
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-delegated-routing-v1-http-api/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-delegated-routing-v1-http-api/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
1313

14-
> The Routing V1 HTTP API powered by Helia
14+
> The Delegated Routing V1 HTTP API powered by Helia
15+
16+
This repo contains a server implementation of the IPFS [Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) along with a client that can be used to interact with any compliant server implementation.
1517

1618
## Table of contents <!-- omit in toc -->
1719

@@ -22,13 +24,13 @@
2224

2325
## Structure
2426

25-
- [`/packages/client`](./packages/client) A Routing V1 HTTP API client
26-
- [`/packages/interop`](./packages/interop) Interop tests for the Routing V1 HTTP API server powered by Helia
27-
- [`/packages/server`](./packages/server) A Routing V1 HTTP API server powered by Helia
27+
- [`/packages/client`](./packages/client) A Delegated Routing V1 HTTP API client
28+
- [`/packages/interop`](./packages/interop) Interop tests for the Delegated Routing V1 HTTP API server powered by Helia
29+
- [`/packages/server`](./packages/server) A Delegated Routing V1 HTTP API server powered by Helia
2830

2931
## API Docs
3032

31-
- <https://ipfs.github.io/helia-routing-v1-http-api>
33+
- <https://ipfs.github.io/helia-delegated-routing-v1-http-api>
3234

3335
## License
3436

@@ -39,7 +41,7 @@ Licensed under either of
3941

4042
## Contribute
4143

42-
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-routing-v1-http-api/issues).
44+
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-delegated-routing-v1-http-api/issues).
4345

4446
Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.
4547

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"name": "helia-routing-v1-http-api",
2+
"name": "helia-delegated-routing-v1-http-api",
33
"version": "1.0.0",
4-
"description": "The Routing V1 HTTP API powered by Helia",
4+
"description": "The Delegated Routing V1 HTTP API powered by Helia",
55
"license": "Apache-2.0 OR MIT",
6-
"homepage": "https://github.com/ipfs/helia-routing-v1-http-api#readme",
6+
"homepage": "https://github.com/ipfs/helia-delegated-routing-v1-http-api#readme",
77
"repository": {
88
"type": "git",
9-
"url": "git+https://github.com/ipfs/helia-routing-v1-http-api.git"
9+
"url": "git+https://github.com/ipfs/helia-delegated-routing-v1-http-api.git"
1010
},
1111
"bugs": {
12-
"url": "https://github.com/ipfs/helia-routing-v1-http-api/issues"
12+
"url": "https://github.com/ipfs/helia-delegated-routing-v1-http-api/issues"
1313
},
1414
"keywords": [
1515
"ipfs"

packages/client/.aegir.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,51 @@ const options = {
66
test: {
77
before: async () => {
88
const providers = new Map()
9+
const peers = new Map()
10+
const ipnsGet = new Map()
11+
const ipnsPut = new Map()
912
const echo = new EchoServer()
13+
echo.polka.use(body.raw({ type: 'application/vnd.ipfs.ipns-record'}))
1014
echo.polka.use(body.text())
1115
echo.polka.post('/add-providers/:cid', (req, res) => {
1216
providers.set(req.params.cid, req.body)
1317
res.end()
1418
})
1519
echo.polka.get('/routing/v1/providers/:cid', (req, res) => {
16-
const provs = providers.get(req.params.cid) ?? '[]'
20+
const records = providers.get(req.params.cid) ?? '[]'
1721
providers.delete(req.params.cid)
1822

19-
res.end(provs)
23+
res.end(records)
24+
})
25+
echo.polka.post('/add-peers/:peerId', (req, res) => {
26+
peers.set(req.params.peerId, req.body)
27+
res.end()
28+
})
29+
echo.polka.get('/routing/v1/peers/:peerId', (req, res) => {
30+
const records = peers.get(req.params.peerId) ?? '[]'
31+
peers.delete(req.params.peerId)
32+
33+
res.end(records)
34+
})
35+
echo.polka.post('/add-ipns/:peerId', (req, res) => {
36+
ipnsGet.set(req.params.peerId, req.body)
37+
res.end()
38+
})
39+
echo.polka.get('/routing/v1/ipns/:peerId', (req, res) => {
40+
const record = ipnsGet.get(req.params.peerId) ?? ''
41+
ipnsGet.delete(req.params.peerId)
42+
43+
res.end(record)
44+
})
45+
echo.polka.put('/routing/v1/ipns/:peerId', (req, res) => {
46+
ipnsPut.set(req.params.peerId, req.body)
47+
res.end()
48+
})
49+
echo.polka.get('/get-ipns/:peerId', (req, res) => {
50+
const record = ipnsPut.get(req.params.peerId) ?? ''
51+
ipnsPut.delete(req.params.peerId)
52+
53+
res.end(record)
2054
})
2155

2256
await echo.start()

packages/client/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
</a>
55
</p>
66

7-
# @helia/routing-v1-http-api-client <!-- omit in toc -->
7+
# @helia/delegated-routing-v1-http-api-client <!-- omit in toc -->
88

99
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
1010
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
11-
[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-routing-v1-http-api.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-routing-v1-http-api)
12-
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-routing-v1-http-api/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-routing-v1-http-api/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
11+
[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-delegated-routing-v1-http-api.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-delegated-routing-v1-http-api)
12+
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-delegated-routing-v1-http-api/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-delegated-routing-v1-http-api/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
1313

14-
> A Routing V1 HTTP API client
14+
> A Delegated Routing V1 HTTP API client
15+
16+
A client implementation of the IPFS [Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) that can be used to interact with any compliant server implementation.
1517

1618
## Table of contents <!-- omit in toc -->
1719

@@ -23,12 +25,12 @@
2325
## Install
2426

2527
```console
26-
$ npm i @helia/routing-v1-http-api-client
28+
$ npm i @helia/delegated-routing-v1-http-api-client
2729
```
2830

2931
## API Docs
3032

31-
- <https://ipfs.github.io/helia-routing-v1-http-api/modules/_helia_routing_v1_http_api_client.html>
33+
- <https://ipfs.github.io/helia-delegated-routing-v1-http-api/modules/_helia_delegated_routing_v1_http_api_client.html>
3234

3335
## License
3436

@@ -39,7 +41,7 @@ Licensed under either of
3941

4042
## Contribute
4143

42-
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-routing-v1-http-api/issues).
44+
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-delegated-routing-v1-http-api/issues).
4345

4446
Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.
4547

packages/client/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"name": "@helia/routing-v1-http-api-client",
3-
"version": "1.0.2",
4-
"description": "A Routing V1 HTTP API client",
2+
"name": "@helia/delegated-routing-v1-http-api-client",
3+
"version": "0.0.0",
4+
"description": "A Delegated Routing V1 HTTP API client",
55
"license": "Apache-2.0 OR MIT",
6-
"homepage": "https://github.com/ipfs/helia-routing-v1-http-api/tree/master/packages/client#readme",
6+
"homepage": "https://github.com/ipfs/helia-delegated-routing-v1-http-api/tree/master/packages/client#readme",
77
"repository": {
88
"type": "git",
9-
"url": "git+https://github.com/ipfs/helia-routing-v1-http-api.git"
9+
"url": "git+https://github.com/ipfs/helia-delegated-routing-v1-http-api.git"
1010
},
1111
"bugs": {
12-
"url": "https://github.com/ipfs/helia-routing-v1-http-api/issues"
12+
"url": "https://github.com/ipfs/helia-delegated-routing-v1-http-api/issues"
1313
},
1414
"keywords": [
1515
"IPFS"
@@ -132,18 +132,19 @@
132132
"dependencies": {
133133
"@libp2p/interface": "^0.1.2",
134134
"@libp2p/logger": "^3.0.2",
135-
"@libp2p/peer-id": "^3.0.2",
135+
"@libp2p/peer-id": "^3.0.3",
136136
"@multiformats/multiaddr": "^12.1.3",
137137
"any-signal": "^4.1.1",
138138
"browser-readablestream-to-it": "^2.0.3",
139+
"ipns": "^7.0.1",
139140
"it-all": "^3.0.2",
140141
"iterable-ndjson": "^1.1.0",
141142
"multiformats": "^12.1.1",
142143
"p-defer": "^4.0.0",
143144
"p-queue": "^7.3.4"
144145
},
145146
"devDependencies": {
146-
"@libp2p/peer-id-factory": "^3.0.3",
147+
"@libp2p/peer-id-factory": "^3.0.5",
147148
"aegir": "^41.0.0",
148149
"body-parser": "^1.20.2"
149150
}

0 commit comments

Comments
 (0)