@gun-vue/relay
v0.5.0
Published
A one liner gun js server easy to run on any free tier nodejs cloud like **[Glitch.com](https://glitch.com/~etogun)**, www.heroku.com or others, on a private VPS server or any other device like RaspberryPi or simply an Android phone.
Downloads
18
Readme
A simple Gun DB relay peer
A one liner gun js server easy to run on any free tier nodejs cloud like Glitch.com, www.heroku.com or others, on a private VPS server or any other device like RaspberryPi or simply an Android phone.
Run in a cloud for free
There's a plenty of cloud providers with free tiers suitable to the needs of running a Gun relay node.
More links to be added here later.
Run on any device
All you need to run a Gun relay is a NodeJS >=16.x
environment with npm
package manager to import and run the script. It's already up and running in major clouds, but you may need to install NodeJS on your computer, or configure a RaspberryPi.
Computer
Open your terminal and check the version of Node with
node -v
. You may need to Install NodeJS or update it.Android device
You can easily run NodeJS apps on an Android phone with Termux app. Consider installing it from F-Droid to get the fresh and stable version.
RaspberryPi
Flash your image and configure your Pi to run a local Gun server
How to use
- Run this in the command line and follow the steps to create a new NodeJS project
npm init
- Then install the package as a dependency
npm i @gun-vue/relay
- Add this line to the generated
package.json
file
"scripts": {
"start": "node start.js"
}
- Create a
start.js
script and edit it as follows: - Import the
relay
and initiate it.
import relay from "@gun-vue/relay";
relay.init();
- Save the
start.js
and run it.
node start.js
You'll see the message from the relay server running with it's address to use as a Gun peer in your app:
Hello wonderful person! :) Thanks for using GUN, please ask for help on http://chat.gun.eco if anything takes you longer than 5min to figure out!
AXE relay enabled!
Server started at http://localhost:4200/gun
Multicast on 233.255.255.255:8765
You've got your Gun relay up and running!
Options
You can use customize your server with an options object:
relay.init({
host: "localhost", // A host name used by the server to publish it's state to the graph. Set your peer URL without a protocol, like 'relay.some-site.com'
port: 4200, // Gun server port. You may use a more standard 8080.
store: false, // Put true if you want to have Gun store data on disk.
path: "public", // A public directory to expose your app with the build in express server. Insert a path like '../app/dist'
});
The options may be also set with .env
file. The defaults are:
RELAY_HOST="localhost"
RELAY_STORE=false
RELAY_PORT=4200
RELAY_PATH="public"
RELAY_QR=false