-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: set up typedoc for API docs (#7)
- Loading branch information
Showing
29 changed files
with
671 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# deploy docs to gh-pages branch | ||
name: typedoc | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
deploy-docs-to-gh-pages: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
|
||
- name: Retrieve the cached "node_modules" directory (if present) | ||
uses: actions/cache@v2 | ||
id: node-cache | ||
with: | ||
path: node_modules | ||
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | ||
|
||
- name: Install dependencies (if the cached directory was not found) | ||
if: steps.node-cache.outputs.cache-hit != 'true' | ||
run: npm ci | ||
|
||
- name: Build the project | ||
run: npm run build | ||
|
||
- name: Unit tests | ||
run: npm run test | ||
|
||
- name: Create the docs directory | ||
run: npm run docs | ||
|
||
- name: Deploy 🚀 | ||
uses: JamesIves/[email protected] | ||
with: | ||
branch: gh-pages | ||
folder: docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ lerna-debug.log | |
node_modules/ | ||
dist/ | ||
packages/*/dist/ | ||
coverage/ | ||
coverage/ | ||
docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,65 @@ | ||
# nostr-relay | ||
|
||
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FCodyTseng%2Fnostr-relay.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FCodyTseng%2Fnostr-relay?ref=badge_shield) | ||
|
||
> Easily build your customized Nostr Relay. | ||
## Usage | ||
|
||
I think examples are the best way to explain how to use this library. | ||
|
||
```typescript | ||
import { NostrRelay, createOutgoingNoticeMessage } from '@nostr-relay/core'; | ||
import { EventRepositorySqlite } from '@nostr-relay/event-repository-sqlite'; | ||
import { Validator } from '@nostr-relay/validator'; | ||
import { WebSocketServer } from 'ws'; | ||
|
||
async function bootstrap() { | ||
const wss = new WebSocketServer({ port: 4869 }); | ||
|
||
// You can implement your own event repository. It just needs to implement a few methods. | ||
const eventRepository = new EventRepositorySqlite(); | ||
const relay = new NostrRelay(eventRepository); | ||
const validator = new Validator(); | ||
|
||
wss.on('connection', ws => { | ||
// Handle a new client connection. This method should be called when a new client connects to the Nostr Relay server. | ||
relay.handleConnection(ws); | ||
|
||
ws.on('message', async data => { | ||
try { | ||
// Validate the incoming message. | ||
const message = await validator.validateIncomingMessage(data); | ||
// Handle the incoming message. | ||
await relay.handleMessage(ws, message); | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
ws.send(JSON.stringify(createOutgoingNoticeMessage(error.message))); | ||
} | ||
} | ||
}); | ||
|
||
// Handle a client disconnection. This method should be called when a client disconnects from the Nostr Relay server. | ||
ws.on('close', () => relay.handleDisconnect(ws)); | ||
|
||
ws.on('error', error => { | ||
ws.send(JSON.stringify(createOutgoingNoticeMessage(error.message))); | ||
}); | ||
}); | ||
} | ||
bootstrap(); | ||
``` | ||
|
||
Full API documentation can be found [here](https://codytseng.github.io/nostr-relay/) | ||
|
||
## Examples | ||
|
||
- [nostr-relay-sqlite](https://github.com/CodyTseng/nostr-relay-sqlite) | ||
|
||
## Donate | ||
|
||
If you like this project, you can buy me a coffee :) ⚡️ [email protected] ⚡️ | ||
|
||
## License | ||
|
||
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FCodyTseng%2Fnostr-relay.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FCodyTseng%2Fnostr-relay?ref=badge_large) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
# @nostr-relay/common | ||
|
||
> Easily build your customized Nostr Relay. | ||
## API | ||
|
||
Full API documentation can be found [here](https://codytseng.github.io/nostr-relay/modules/_nostr_relay_common.html) | ||
|
||
## License | ||
|
||
MIT |
Oops, something went wrong.