libp2p / libp2p/js-libp2p

docs: Update `GETTING_STARTED.md` docs to give users default configs

Open
#2,091 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic/docs
Dominant language
TypeScript
Stars
2.6k
Forks
546
Avg merge
8h 18m
Merged PRs (30d)
16

Description

We a user lands on the https://github.com/libp2p/js-libp2p/blob/master/doc/GETTING_STARTED.md page, they should primarily see a defaultConfig that would allow them to get started on most networking setups. Here's an example

import { createLibp2p } from 'libp2p'
import { webSockets } from '@libp2p/websockets'
import { noise } from '@chainsafe/libp2p-noise'
import { mplex } from '@libp2p/mplex'
import { yamux } from '@chainsafe/libp2p-yamux',

import { bootstrap } from '@libp2p/bootstrap'

// Known peers addresses
const bootstrapMultiaddrs = [
  '/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
  '/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN'
]

const node = await createLibp2p({
  transports: [webSockets()],
  connectionEncryption: [noise()],
  streamMuxers: [yamux(), mplex()],
  peerDiscovery: [
    bootstrap({
      list: bootstrapMultiaddrs, // provide array of multiaddrs
    })
  ]
})

node.addEventListener('peer:discovery', (evt) => {
  console.log('Discovered %s', evt.detail.id.toString()) // Log discovered peer
})

node.addEventListener('peer:connect', (evt) => {
  console.log('Connected to %s', evt.detail.remotePeer.toString()) // Log connected peer
})

The user can then go through the remaining sections to learn more about peer discovery, connection encryption, transports, pubsub, stream muxers etc.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with doc/GETTING_STARTED.md and inspect its existing setup examples alongside the TypeScript configuration shown in the issue. Done means the page leads with a broadly usable default configuration and retains follow-on guidance for peer discovery, connection encryption, transports, pubsub, and stream muxers.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation, networking
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.