Code Monkey home page Code Monkey logo

gun-restrict-examples's Introduction

Build Status js-standard-style Greenkeeper badge

gun-restrict-examples

Examples of how to restrict writes and still have public reads with GUN

Setup

Clone or download the repo.

cd into directory and run npm install

Restricted writes with SEA

Open a terminal and start the services

$ npm run sea

This will start 3 servers

  • The GUN server at localhost port 8000
  • The authenticated site on localhost port 3000
  • The unauthenticated site on localhost port 4000

Open your browser at http://localhost:3000

Login with whatever username/password you want. If the user doesn't exist it will be created.

Add some messages

Use the link to open the unathorized site

What to expect

Everything you write on the authenticated site will be synced to the unathenticated, but not the other way around.

Shut down the services with CTRL + C in the terminal

Restricted put with token example

Open a terminal and start the services

$ npm start

This will start 3 servers

  • The GUN server at localhost port 8000
  • The authenticated site on localhost port 3000
  • The unauthenticated site on localhost port 4000

Open 2 browsers.

What to expect

Everything you write on the authenticated site will be synced to the unathenticated, but not the other way around.

Explore more

If you want to se GUN in action without restrictions stop the running service pressing CTRL + C in the terminal.

Start an unrestricted GUN server.

$ npm run unrestricted

Now your sync will work both ways.

Acknowledgements

The solutions are based on an answer from stackoverflow, the SEA contact example and of course the GUN Gitter

License

MIT

Robohash image of gun-restrict-examples

gun-restrict-examples's People

Contributors

amark avatar greenkeeper[bot] avatar renovate-bot avatar zrrrzzt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.