Skip to content
Bo edited this page Jun 5, 2022 · 20 revisions

You can easily run NodeJS apps on an Android phone with Termux

Termux is an Android terminal emulator and Linux environment app that works directly with no rooting or setup required. A minimal base system is installed automatically - additional packages are available using the APT package manager.

APK: https://f-droid.org/en/packages/com.termux/

Setup

Here is a simple gun relay server.

Start a new repo:

// server.js

;(function(){
  var gun = require('gun/examples/http');
  if(!gun.back){ return } // http example auto spawns subprocess

  var fs = require('fs');
  var server = gun.back('opt.web');
  var route = server.route = {}

  fs.readdir('./route', function(err, dir){
      if(err || !dir){ return }
      dir.forEach(function(file){
          if(!file){ return }
          route[file.split('.')[0]] = require('./route/'+file);
      });
  });
 
// with this line you can type a message on http://localhost:8765/basic/paste.html and check if the server works.
  gun.get('test').on(data => console.log(data))

}());

-npm gun -npm start

Use cases

Decentralized Subscription Service (decentralized database/storage server)

You can use it to collect data 24/7 with your mobile from a subscribe form, or customer/user chat, or whichever datasource, which is on your static website on a CDN.
Without the need for any DynDNS service or centralized back-ends! Without the need to stay 24/7 online with your phone!

!!!Heroku becomes unnecessary or fallback if you use Decentralized-STUN-Service. But this concept is for showing how to decentralize your back-end with gun for something simple like <input>!!!

image

Decentralized STUN Service (decentralized database/storage server with STUN)

Run your own IP Lookup server (or multiple) if you like https://github.com/mpolden/echoip
A simple service for looking up your IP address. This is the code that powers https://ifconfig.co/

image

Decentralized CDN Service

Peer-CDN https://rafallorenz.com/peer-cdn/docs/installation.html
Serve your website/apps build files from your gun nodes and peers.
The source-code of your website/app in this example comes from Android, but can come from anywhere you like.

image

Gun emailserver

A Gun based email server on your mobile. by by classic email provider! (take a look on Cloudflare Email Routing https://developers.cloudflare.com/email-routing/ to improve further)

Make your mobile gun server available from the outside (centralized way, for fallback or scaling eventually)

https://www.noip.com/integrate/request (free user account neccessary)

Contribute

feel free to add more use cases...

This wiki is where all the GUN website documentation comes from.

You can read it here or on the website, but the website has some special features like rendering some markdown extensions to create interactive coding tutorials.

Please feel free to improve the docs itself, we need contributions!

Clone this wiki locally