From 2306bb17081b384979947877a524ffb7180fcdf7 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Fri, 30 Jul 2021 13:55:43 +1000 Subject: [PATCH] Add breakdown of what examples demonstrate Also move explanation to each readme. --- README.md | 73 +----------------------- examples/cli-chat/README.md | 36 +++++++++++- examples/eth-dm/README.md | 29 +++++++++- examples/examples.md | 8 +++ examples/min-js-web-chat/README.md | 81 ++++++--------------------- examples/web-chat/README.md | 26 ++++++++- guides/relay-receive-send-messages.md | 2 +- 7 files changed, 113 insertions(+), 142 deletions(-) create mode 100644 examples/examples.md diff --git a/README.md b/README.md index b4753b3649..303d622e77 100644 --- a/README.md +++ b/README.md @@ -300,77 +300,8 @@ For more general discussion and latest news, join #dappconnect on [Vac Discord]( ## Examples -## Web Chat App (ReactJS) - -A ReactJS chat app is provided as a showcase of the library used in the browser. -It implements [Waku v2 Toy Chat](https://rfc.vac.dev/spec/22/) protocol. -A deployed version is available at https://status-im.github.io/js-waku/. - -Find the code in the [examples folder](https://github.com/status-im/js-waku/tree/main/examples/web-chat). - -To run a development version locally, do: - -```shell -git clone https://github.com/status-im/js-waku/ ; cd js-waku -npm install # Install dependencies for js-waku -npm run build # Build js-waku -cd examples/web-chat -npm install # Install dependencies for the web app -npm run start # Start development server to serve the web app on http://localhost:3000/js-waku -``` - -Use `/help` to see the available commands. - -## CLI Chat App (NodeJS) - -A node chat app is provided as a working example of the library. -It implements [Waku v2 Toy Chat](https://rfc.vac.dev/spec/22/) protocol. - -Find the code in the [examples folder](https://github.com/status-im/js-waku/tree/main/examples/cli-chat). - -To run the chat app, first ensure you have [Node.js](https://nodejs.org/en/) v14 or above: - -```shell -node --version -``` - -Then, install and run: - -```shell -git clone https://github.com/status-im/js-waku/ ; cd js-waku -npm install # Install dependencies for js-waku -npm run build # Build js-waku -cd examples/cli-chat -npm install # Install dependencies for the cli app -npm run start -- --autoDial -``` - -You can also specify an optional `listenAddr` parameter (.e.g `--listenAddr /ip4/0.0.0.0/tcp/7777/ws`). -This is only useful if you want a remote node to dial to your chat app, -it is not necessary in normal usage when you just connect to the fleet. - -## Ethereum Direct Message - -A PoC implementation of [20/ETH-DM](https://rfc.vac.dev/spec/20/). - -Ethereum Direct Message, or Eth-DM, is a protocol that allows sending encrypted message to a recipient, -only knowing their Ethereum Address. - -This is protocol has been created to demonstrated how encryption and signature could be added to messages -sent over the Waku v2 network. - -The `main` branch's HEAD is deployed on GitHub Pages at https://status-im.github.io/js-waku/eth-dm/. - -To run a development version locally, do: - -```shell -git clone https://github.com/status-im/js-waku/ ; cd js-waku -npm install # Install dependencies for js-waku -npm run build # Build js-waku -cd examples/eth-dm -npm install # Install dependencies for the web app -npm run start # Start development server to serve the web app on http://localhost:3000/js-waku/eth-dm -``` +We have a number of code examples available, +you can find them in the [examples](https://github.com/status-im/js-waku/blob/main/examples/examples.md) directory. ## Contributing diff --git a/examples/cli-chat/README.md b/examples/cli-chat/README.md index 14a50e890a..f033c41865 100644 --- a/examples/cli-chat/README.md +++ b/examples/cli-chat/README.md @@ -1,3 +1,35 @@ -# A NodeJS CLI Chat App powered by js-waku +# CLI Chat App -See js-waku [README](../../README.md#cli-chat-app-nodejs) for details. +**Demonstrates**: + +- Group chat +- Node JS/TypeScript +- Waku Relay +- Waku Light Push +- Waku Store + +A node chat app is provided as a working example of the library. +It implements [Waku v2 Toy Chat](https://rfc.vac.dev/spec/22/) protocol. + +Find the code in the [examples folder](https://github.com/status-im/js-waku/tree/main/examples/cli-chat). + +To run the chat app, first ensure you have [Node.js](https://nodejs.org/en/) v14 or above: + +```shell +node --version +``` + +Then, install and run: + +```shell +git clone https://github.com/status-im/js-waku/ ; cd js-waku +npm install # Install dependencies for js-waku +npm run build # Build js-waku +cd examples/cli-chat +npm install # Install dependencies for the cli app +npm run start -- --autoDial +``` + +You can also specify an optional `listenAddr` parameter (.e.g `--listenAddr /ip4/0.0.0.0/tcp/7777/ws`). +This is only useful if you want a remote node to dial to your chat app, +it is not necessary in normal usage when you just connect to the fleet. diff --git a/examples/eth-dm/README.md b/examples/eth-dm/README.md index ff2fb69c5d..1428a1e29e 100644 --- a/examples/eth-dm/README.md +++ b/examples/eth-dm/README.md @@ -1,3 +1,30 @@ # Ethereum Direct Message Web App -See js-waku [README](../../README.md#ethereum-direct-message) for details. +**Demonstrates**: + +- Private Messaging +- React/TypeScript +- Waku Light Push +- Signature with Web3 +- Asymmetric Encryption + +A PoC implementation of [20/ETH-DM](https://rfc.vac.dev/spec/20/). + +Ethereum Direct Message, or Eth-DM, is a protocol that allows sending encrypted message to a recipient, +only knowing their Ethereum Address. + +This is protocol has been created to demonstrated how encryption and signature could be added to messages +sent over the Waku v2 network. + +The `main` branch's HEAD is deployed on GitHub Pages at https://status-im.github.io/js-waku/eth-dm/. + +To run a development version locally, do: + +```shell +git clone https://github.com/status-im/js-waku/ ; cd js-waku +npm install # Install dependencies for js-waku +npm run build # Build js-waku +cd examples/eth-dm +npm install # Install dependencies for the web app +npm run start # Start development server to serve the web app on http://localhost:3000/js-waku/eth-dm +``` diff --git a/examples/examples.md b/examples/examples.md new file mode 100644 index 0000000000..92031248ee --- /dev/null +++ b/examples/examples.md @@ -0,0 +1,8 @@ +## Examples + +Here is the list of the code examples and the features they demonstrate: + +- [Web Chat App](web-chat): Group chat, React/TypeScript, Relay, Store. +- [CLI Chat App](cli-chat): Group chat, Node JS/TypeScript, Relay, Light Push, Store. +- [Ethereum Direct Message Web App](eth-dm): Private Messaging, React/TypeScript, Light Push, Signature with Web3, Asymmetric Encryption. +- [Minimal JS Web Chat App](min-js-web-chat): Group chat, React/JavaScript, Relay, Protobuf using `protons`. diff --git a/examples/min-js-web-chat/README.md b/examples/min-js-web-chat/README.md index 02aac3f6ea..05fec0419d 100644 --- a/examples/min-js-web-chat/README.md +++ b/examples/min-js-web-chat/README.md @@ -1,70 +1,21 @@ -# Getting Started with Create React App +# Minimal ReactJS Web Chat App -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +**Demonstrates**: -## Available Scripts +- Group chat +- React/JavaScript +- Waku Relay +- Protobuf using `protons`. -In the project directory, you can run: +A barebone chat app to illustrate the [ReactJS Relay guide](/guides/reactjs-relay.md). -### `yarn start` +To run a development version locally, do: -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.\ -You will also see any lint errors in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) - -### Analyzing the Bundle Size - -This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) - -### Making a Progressive Web App - -This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) - -### Advanced Configuration - -This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) - -### Deployment - -This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) - -### `yarn build` fails to minify - -This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) +```shell +git clone https://github.com/status-im/js-waku/ ; cd js-waku +npm install # Install dependencies for js-waku +npm run build # Build js-waku +cd examples/min-js-web-chat +npm install # Install dependencies for the web app +npm run start # Start development server to serve the web app on http://localhost:3000/ +``` diff --git a/examples/web-chat/README.md b/examples/web-chat/README.md index b1d1a966d2..7f5277d377 100644 --- a/examples/web-chat/README.md +++ b/examples/web-chat/README.md @@ -1,3 +1,25 @@ -# A React Web Chat App powered by js-waku +# Web Chat App -See js-waku [README](../../README.md#web-chat-app-reactjs) for details. +**Demonstrates**: + +- Group chat +- React/TypeScript +- Waku Relay +- Waku Store + +A ReactJS chat app is provided as a showcase of the library used in the browser. +It implements [Waku v2 Toy Chat](https://rfc.vac.dev/spec/22/) protocol. +A deployed version is available at https://status-im.github.io/js-waku/. + +To run a development version locally, do: + +```shell +git clone https://github.com/status-im/js-waku/ ; cd js-waku +npm install # Install dependencies for js-waku +npm run build # Build js-waku +cd examples/web-chat +npm install # Install dependencies for the web app +npm run start # Start development server to serve the web app on http://localhost:3000/js-waku +``` + +Use `/help` to see the available commands. diff --git a/guides/relay-receive-send-messages.md b/guides/relay-receive-send-messages.md index 0b508b1790..9f7ddf3dc0 100644 --- a/guides/relay-receive-send-messages.md +++ b/guides/relay-receive-send-messages.md @@ -170,7 +170,7 @@ waku.relay.addObserver(processIncomingMessage, ['/relay-guide/1/chat/proto']); That is it! Now, you know how to send and receive messages over Waku using the Waku Relay protocol. -Feel free to check out other [guides](menu.md) or [examples](../examples). +Feel free to check out other [guides](menu.md) or [examples](/examples/examples.md). Here is the final code: