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

refactor!: extract fetch to separate module #2223

Merged
merged 1 commit into from
Nov 9, 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
1 change: 1 addition & 0 deletions .release-please.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"packages/peer-store": {},
"packages/protocol-autonat": {},
"packages/protocol-dcutr": {},
"packages/protocol-fetch": {},
"packages/protocol-identify": {},
"packages/protocol-perf": {},
"packages/protocol-ping": {},
Expand Down
33 changes: 32 additions & 1 deletion doc/migrations/v0.46-v1.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ A migration guide for refactoring your application code from libp2p `v0.46` to `
- [Ping](#ping)
- [Identify](#identify)
- [DCUtR](#dcutr)
- [Fetch](#fetch)
- [KeyChain](#keychain)
- [UPnPNat](#upnpnat)
- [Plaintext](#plaintext)
Expand Down Expand Up @@ -117,7 +118,7 @@ import { dcutrService } from 'libp2p/dcutr'

const node = await createLibp2p({
services: {
identify: dcutrService()
dcutr: dcutrService()
}
})
```
Expand All @@ -135,6 +136,36 @@ const node = await createLibp2p({
})
```

## Fetch

The Fetch service is now published in its own package.

**Before**

```ts
import { createLibp2p } from 'libp2p'
import { fetchService } from 'libp2p/fetch'

const node = await createLibp2p({
services: {
fetch: fetchService()
}
})
```

**After**

```ts
import { createLibp2p } from 'libp2p'
import { fetch } from '@libp2p/fetch'

const node = await createLibp2p({
services: {
fetch: fetch()
}
})
```

## KeyChain

The KeyChain object is no longer included on Libp2p and must be instantiated explicitly if desired.
Expand Down
2 changes: 0 additions & 2 deletions packages/libp2p/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default {
const { plaintext } = await import('@libp2p/plaintext')
const { circuitRelayServer, circuitRelayTransport } = await import('@libp2p/circuit-relay-v2')
const { identify } = await import('@libp2p/identify')
const { fetchService } = await import('./dist/src/fetch/index.js')

const peerId = await createEd25519PeerId()
const libp2p = await createLibp2p({
Expand Down Expand Up @@ -46,7 +45,6 @@ export default {
],
services: {
identify: identify(),
fetch: fetchService(),
relay: circuitRelayServer({
reservations: {
maxReservations: Infinity
Expand Down
14 changes: 14 additions & 0 deletions packages/libp2p/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@

> JavaScript implementation of libp2p, a modular peer to peer network stack

# About

Use the `createLibp2p` function to create a libp2p node.

## Example

```typescript
import { createLibp2p } from 'libp2p'

const node = await createLibp2p({
// ...other options
})
```

# Project status

We've come a long way, but this project is still in Alpha, lots of development is happening, API might change, beware of the Dragons 🐉..
Expand Down
30 changes: 0 additions & 30 deletions packages/libp2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@
],
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
],
"src/*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
]
}
},
"files": [
"src",
"dist",
Expand All @@ -47,10 +31,6 @@
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
},
"./fetch": {
"types": "./dist/src/fetch/index.d.ts",
"import": "./dist/src/fetch/index.js"
}
},
"eslintConfig": {
Expand All @@ -71,12 +51,6 @@
"dep-check": "aegir dep-check",
"prepublishOnly": "node scripts/update-version.js && npm run build",
"build": "aegir build",
"generate": "run-s generate:proto:*",
"generate:proto:circuit-relay": "protons ./src/circuit-relay/pb/index.proto",
"generate:proto:dcutr": "protons ./src/dcutr/pb/message.proto",
"generate:proto:fetch": "protons ./src/fetch/pb/proto.proto",
"generate:proto:identify": "protons ./src/identify/pb/message.proto",
"generate:proto:plaintext": "protons ./src/insecure/pb/proto.proto",
"test": "aegir test",
"test:node": "aegir test -t node -f \"./dist/test/**/*.{node,spec}.js\" --cov",
"test:chrome": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" --cov",
Expand Down Expand Up @@ -108,7 +82,6 @@
"it-drain": "^3.0.2",
"it-filter": "^3.0.1",
"it-first": "^3.0.1",
"it-length-prefixed": "^9.0.1",
"it-map": "^3.0.3",
"it-merge": "^3.0.0",
"it-pipe": "^3.0.1",
Expand All @@ -118,7 +91,6 @@
"p-defer": "^4.0.0",
"p-queue": "^7.3.4",
"private-ip": "^3.0.0",
"protons-runtime": "^5.0.0",
"rate-limiter-flexible": "^3.0.0",
"uint8arraylist": "^2.4.3",
"uint8arrays": "^4.0.6"
Expand All @@ -145,11 +117,9 @@
"execa": "^8.0.1",
"go-libp2p": "^1.1.1",
"it-pushable": "^3.2.0",
"npm-run-all": "^4.1.5",
"p-event": "^6.0.0",
"p-times": "^4.0.0",
"p-wait-for": "^5.0.2",
"protons": "^7.0.2",
"sinon": "^17.0.0",
"sinon-ts": "^2.0.0"
},
Expand Down
41 changes: 0 additions & 41 deletions packages/libp2p/src/fetch/README.md

This file was deleted.

Loading