Coder Social home page Coder Social logo

nevkontakte / go-nats-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oderwat/go-nats-app

0.0 0.0 0.0 4.08 MB

A Go code only PWA as proof of concept for using (embedded) NATS as communication between front and back end.

License: MIT License

Go 99.40% CSS 0.60%

go-nats-app's Introduction

Go-Nats-App

This is a demo of a Go-App based PWA that uses NATS for the communication between frontend and backend.

How to run it?

Clone the repository, cd into it and run go run mage.go run (or mage run if you installed mage already).

Then open http://127.0.0.1:8500 once or multiple times in your browser and chat with yourself.

preview

Features of this demo:

  • There is no java-script! Everything is Go code.
    • Frontend & Backend uses Go-App.
    • Build tooling made with Mage.
  • The frontend is a PWA and can be installed on your phone or desktop. It runs in the browser as WASM code with a service-worker.
  • We are using an embedded NATS-Server in the backend to offer three services:
    • Govatar image (jpeg / random / female).
    • Chat broker (3 lines of code + error handling = 10 lines).
    • (New) Each PWA has a echo "req" service under the subject "echo.". Like "echo.late-meadow" in our example picture. An example command-line is shown in the site.
  • We use the original nats.go client in the frontend.
  • Go-App code is smaller when building WASM and normal code separately.
  • We compress the WASM code on the fly.
  • You can run the embedded nats-server as leaf-node of a cluster (that is what we do in another proof of concept).

What does not work:

  • This will not work with TLS (wss://) with before the next release of Nats.go (after 1.20.0). If you need TLS for the websocket you can use go get https://github.com/nats-io/nats.go@main which shoud work for that. The code in the demo does contain everything needed though (implementation of SkipTLSHandshake() on the CustomDialer).
  • The IPs and ports are hardcoded and as everything binds to localhost it will not work behind reverse proxies or through tunnels like sish or ngrok.
  • a lot more. It is just a proof of concept / demo.

Disclaimer

  • We do not care what you do with the code as long as you do not bug us or destroy humanity with it :)
  • This uses the MIT Licence and is as it is what it is.
  • Parts of the code were quickly grabbed from other internal prototypes or written without much though. It is most likely full of bugs :)

Greetings

  • to the NATS Team
  • to the Go-App developer
  • all the contributors
  • and to everybody else :)

go-nats-app's People

Contributors

oderwat avatar nevkontakte 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.