Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit 4477f4b

Browse files
authored
docs: publish api docs (#39)
Updates project config to publish api docs
1 parent 1d5c3b7 commit 4477f4b

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
node_modules
2-
coverage
3-
.nyc_output
2+
build
3+
dist
4+
.docs
5+
.coverage
6+
node_modules
47
package-lock.json
58
yarn.lock
6-
docs
7-
dist

README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# @libp2p/peer-record <!-- omit in toc -->
22

33
[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4-
[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
54
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
65
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-peer-record.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-peer-record)
7-
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-peer-record/actions/workflows/js-test-and-release.yml)
6+
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-peer-record/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-peer-record/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
87

98
> Used to transfer signed peer data across the network
109
1110
## Table of contents <!-- omit in toc -->
1211

1312
- [Install](#install)
13+
- [Browser `<script>` tag](#browser-script-tag)
1414
- [Description](#description)
1515
- [Envelope](#envelope)
1616
- [Usage](#usage)
@@ -22,16 +22,24 @@
2222
- [Subsystem receiving a record](#subsystem-receiving-a-record)
2323
- [Subsystem providing a record](#subsystem-providing-a-record)
2424
- [Future Work](#future-work)
25-
- [Example](#example)
25+
- [API Docs](#api-docs)
2626
- [License](#license)
27-
- [Contribute](#contribute)
27+
- [Contribution](#contribution)
2828

2929
## Install
3030

3131
```console
3232
$ npm i @libp2p/peer-record
3333
```
3434

35+
### Browser `<script>` tag
36+
37+
Loading this module through a script tag will make it's exports available as `Libp2pPeerRecord` in the global namespace.
38+
39+
```html
40+
<script src="https://unpkg.com/@libp2p/peer-record/dist/index.min.js"></script>
41+
```
42+
3543
## Description
3644

3745
Libp2p nodes need to store data in a public location (e.g. a DHT), or rely on potentially untrustworthy intermediaries to relay information over its lifetime. Accordingly, libp2p nodes need to be able to verify that the data came from a specific peer and that it hasn't been tampered with.
@@ -163,15 +171,9 @@ When a subsystem wants to provide a record, it will get it from the AddressBook,
163171
- With the modular dialer, users should easily be able to configure precedence. With dialer v1, anything we do to prioritise dials is gonna be spaghetti and adhoc. With the modular dialer, you’d be able to specify the order of dials when instantiating the pipeline.
164172
- Multiple parallel dials. We already have the issue where new addresses aren't added to existing dials.
165173

166-
## Example
174+
## API Docs
167175

168-
```JavaScript
169-
import { trackedMap } from '@libp2p/tracked-map'
170-
171-
const map = trackedMap<string, string>({ metrics })
172-
173-
map.set('key', 'value')
174-
```
176+
- <https://libp2p.github.io/js-libp2p-peer-record>
175177

176178
## License
177179

@@ -180,6 +182,6 @@ Licensed under either of
180182
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
181183
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
182184

183-
## Contribute
185+
## Contribution
184186

185187
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"types": "./dist/src/index.d.ts",
2323
"files": [
2424
"src",
25-
"dist/src",
25+
"dist",
2626
"!dist/test",
2727
"!**/*.tsbuildinfo"
2828
],
@@ -142,7 +142,8 @@
142142
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
143143
"test:node": "aegir test -t node --cov",
144144
"test:electron-main": "aegir test -t electron-main",
145-
"release": "aegir release"
145+
"release": "aegir release",
146+
"docs": "aegir docs"
146147
},
147148
"dependencies": {
148149
"@libp2p/crypto": "^1.0.0",

src/envelope/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Record, Envelope } from '@libp2p/interface-record'
1010
import { Uint8ArrayList } from 'uint8arraylist'
1111
import { unsigned } from 'uint8-varint'
1212

13-
export interface EnvelopeInit {
13+
export interface RecordEnvelopeInit {
1414
peerId: PeerId
1515
payloadType: Uint8Array
1616
payload: Uint8Array
@@ -82,7 +82,7 @@ export class RecordEnvelope implements Envelope {
8282
* The Envelope is responsible for keeping an arbitrary signed record
8383
* by a libp2p peer.
8484
*/
85-
constructor (init: EnvelopeInit) {
85+
constructor (init: RecordEnvelopeInit) {
8686
const { peerId, payloadType, payload, signature } = init
8787

8888
this.peerId = peerId

src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11

22
export { RecordEnvelope } from './envelope/index.js'
3+
export type { RecordEnvelopeInit } from './envelope/index.js'
34
export { PeerRecord } from './peer-record/index.js'
5+
export type { PeerRecordInit } from './peer-record/index.js'

0 commit comments

Comments
 (0)