Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: conform to Delegated Routing V1 HTTP spec #41

Merged
merged 19 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
</a>
</p>

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

[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
[![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)
[![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)
[![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)
[![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)

> The Routing V1 HTTP API powered by Helia
> The Delegated Routing V1 HTTP API powered by Helia

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.

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

Expand All @@ -22,13 +24,13 @@

## Structure

- [`/packages/client`](./packages/client) A Routing V1 HTTP API client
- [`/packages/interop`](./packages/interop) Interop tests for the Routing V1 HTTP API server powered by Helia
- [`/packages/server`](./packages/server) A Routing V1 HTTP API server powered by Helia
- [`/packages/client`](./packages/client) A Delegated Routing V1 HTTP API client
- [`/packages/interop`](./packages/interop) Interop tests for the Delegated Routing V1 HTTP API server powered by Helia
- [`/packages/server`](./packages/server) A Delegated Routing V1 HTTP API server powered by Helia

## API Docs

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

## License

Expand All @@ -39,7 +41,7 @@ Licensed under either of

## Contribute

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

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.

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "helia-routing-v1-http-api",
"name": "helia-delegated-routing-v1-http-api",
"version": "1.0.0",
"description": "The Routing V1 HTTP API powered by Helia",
"description": "The Delegated Routing V1 HTTP API powered by Helia",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/ipfs/helia-routing-v1-http-api#readme",
"homepage": "https://github.com/ipfs/helia-delegated-routing-v1-http-api#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/ipfs/helia-routing-v1-http-api.git"
"url": "git+https://github.com/ipfs/helia-delegated-routing-v1-http-api.git"
},
"bugs": {
"url": "https://github.com/ipfs/helia-routing-v1-http-api/issues"
"url": "https://github.com/ipfs/helia-delegated-routing-v1-http-api/issues"
},
"keywords": [
"ipfs"
Expand Down
38 changes: 36 additions & 2 deletions packages/client/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,51 @@ const options = {
test: {
before: async () => {
const providers = new Map()
const peers = new Map()
const ipnsGet = new Map()
const ipnsPut = new Map()
const echo = new EchoServer()
echo.polka.use(body.raw({ type: 'application/vnd.ipfs.ipns-record'}))
echo.polka.use(body.text())
echo.polka.post('/add-providers/:cid', (req, res) => {
providers.set(req.params.cid, req.body)
res.end()
})
echo.polka.get('/routing/v1/providers/:cid', (req, res) => {
const provs = providers.get(req.params.cid) ?? '[]'
const records = providers.get(req.params.cid) ?? '[]'
providers.delete(req.params.cid)

res.end(provs)
res.end(records)
})
echo.polka.post('/add-peers/:peerId', (req, res) => {
peers.set(req.params.peerId, req.body)
res.end()
})
echo.polka.get('/routing/v1/peers/:peerId', (req, res) => {
const records = peers.get(req.params.peerId) ?? '[]'
peers.delete(req.params.peerId)

res.end(records)
})
echo.polka.post('/add-ipns/:peerId', (req, res) => {
ipnsGet.set(req.params.peerId, req.body)
res.end()
})
echo.polka.get('/routing/v1/ipns/:peerId', (req, res) => {
const record = ipnsGet.get(req.params.peerId) ?? ''
ipnsGet.delete(req.params.peerId)

res.end(record)
})
echo.polka.put('/routing/v1/ipns/:peerId', (req, res) => {
ipnsPut.set(req.params.peerId, req.body)
res.end()
})
echo.polka.get('/get-ipns/:peerId', (req, res) => {
const record = ipnsPut.get(req.params.peerId) ?? ''
ipnsPut.delete(req.params.peerId)

res.end(record)
})

await echo.start()
Expand Down
16 changes: 9 additions & 7 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
</a>
</p>

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

[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
[![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)
[![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)
[![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)
[![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)

> A Routing V1 HTTP API client
> A Delegated Routing V1 HTTP API client

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.

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

Expand All @@ -23,12 +25,12 @@
## Install

```console
$ npm i @helia/routing-v1-http-api-client
$ npm i @helia/delegated-routing-v1-http-api-client
```

## API Docs

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

## License

Expand All @@ -39,7 +41,7 @@ Licensed under either of

## Contribute

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

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.

Expand Down
17 changes: 9 additions & 8 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@helia/routing-v1-http-api-client",
"version": "1.0.2",
"description": "A Routing V1 HTTP API client",
"name": "@helia/delegated-routing-v1-http-api-client",
"version": "0.0.0",
"description": "A Delegated Routing V1 HTTP API client",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/ipfs/helia-routing-v1-http-api/tree/master/packages/client#readme",
"homepage": "https://github.com/ipfs/helia-delegated-routing-v1-http-api/tree/master/packages/client#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/ipfs/helia-routing-v1-http-api.git"
"url": "git+https://github.com/ipfs/helia-delegated-routing-v1-http-api.git"
},
"bugs": {
"url": "https://github.com/ipfs/helia-routing-v1-http-api/issues"
"url": "https://github.com/ipfs/helia-delegated-routing-v1-http-api/issues"
},
"keywords": [
"IPFS"
Expand Down Expand Up @@ -132,18 +132,19 @@
"dependencies": {
"@libp2p/interface": "^0.1.2",
"@libp2p/logger": "^3.0.2",
"@libp2p/peer-id": "^3.0.2",
"@libp2p/peer-id": "^3.0.3",
"@multiformats/multiaddr": "^12.1.3",
"any-signal": "^4.1.1",
"browser-readablestream-to-it": "^2.0.3",
"ipns": "^7.0.1",
"it-all": "^3.0.2",
"iterable-ndjson": "^1.1.0",
"multiformats": "^12.1.1",
"p-defer": "^4.0.0",
"p-queue": "^7.3.4"
},
"devDependencies": {
"@libp2p/peer-id-factory": "^3.0.3",
"@libp2p/peer-id-factory": "^3.0.5",
"aegir": "^41.0.0",
"body-parser": "^1.20.2"
}
Expand Down
Loading
Loading