Coder Social home page Coder Social logo

ndungudedan / backend-satstogo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from satstogo-devs/backend-satstogo

0.0 0.0 0.0 195 KB

Backend for SatsToGo - We aim to encourage punctual attendance through SATS rewards by developing an LN Bits extension for time and attendance tracking.

Python 99.68% Shell 0.32%

backend-satstogo's Introduction

SATSTOGO BACKEND

Please install the necessary packages before proceeding:

pip install -r requirements.txt

To run the project, use the command:

python3 manage.py runserver

To run database migrations:

python3 manage.py makemigrations
python3 manage.py migrate

Authentication APIs

The following flow is expected for the authentication APIs:

  1. To Login a user, perform a GET request to the endpoint api/auth-login/ with the param k1. A successful login reluts in the response: {"status": "OK"} while the opposite results: {"status": "ERROR", "message": "Magic String Not Found"}

  2. To register a new user, make a GET API call to api/auth/. This endpoint responds with:

    {"status": "OK","magic_string":hex_data,"auth_url":auth_url,"encoded":encoded}

    After you get this reponse, please open a websocket connection at ws/notifications/{k1}/ where k1 is the magic string received.

  3. When the user connects the LN wallet, you will receive a message on the websocket connnection in the form {"status": "OK","message":"Verification Successful"}

Testing Websocket

This Javascript code snnippet can be used to test Websocket connections:

const chatSocket = new WebSocket('ws://127.0.0.1:8000/ws/notifications/654/');

chatSocket.onopen = function() {
  console.log('WebSocket connection established.');
  const message = {
    'message': 'Hello, world!'
  };
  chatSocket.send(JSON.stringify(message));
};
chatSocket.onmessage = function(event) {
  const message = JSON.parse(event.data);
  console.log('Received message:', message);
};
chatSocket.onclose = function(e) {
    console.error('Chat socket closed unexpectedly');
};

RESOURCES

backend-satstogo's People

Contributors

ndungudedan avatar dayvvo avatar naiyoma 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.