Code Monkey home page Code Monkey logo

lightbank's Introduction

lightbank

Database Config:

Create a file database.env and add the following lines:

export DB_HOST="127.0.0.1"
export DB_PORT="5432"
export DB_USER="postgres"
export DB_PASSWORD="postgres"
export DB_NAME="lightbank"
export DB_SSLMODE="disable"

Export the configuration, and run the following command:

go run main.go create-db

This will run migrations and create the database. To run API of lightbank, run without arguments:

go run main.go

after you can register your first user:

curl -X POST -H "Content-Type: application/json" -d '{"username":"admin","email":"[email protected]","password":"admin"}' http://localhost:8888/register

Output:

{
    "data": {
        "ID": 7,
        "Username": "admin",
        "Email": "[email protected]",
        "Accounts": [
            {
                "ID": 7,
                "Name": "admin's account",
                "Balance": 0
            }
        ]
    },
    "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcnkiOjE2Mzc1MjIwMzIsInVzZXJfaWQiOjd9.BWXKC0PqpyRcIO0C0aDAkYttqgSD6oIBfdFpiLO_pR0",
    "message": "all is fine"
}

Calls:

  • Register:

    http://localhost:8888/register
    
  • Login: Get jwt to authenticated user:

    curl -X POST -H "Content-Type: application/json" -d '{"username":"admin","password":"admin"}' http://localhost:8888/login
    
  • Find:

    curl -X GET -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcnkiOjE2Mzc1MjIwMzIsInVzZXJfaWQiOjd9.BWXKC0PqpyRcIO0C0aDAkYttqgSD6oIBfdFpiLO_pR0" http://localhost:8888/accounts/1
    
  • Transaction:

    curl -X POST -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcnkiOjE2Mzc1MjIwMzIsInVzZXJfaWQiOjd9.BWXKC0PqpyRcIO0C0aDAkYttqgSD6oIBfdFpiLO_pR0" -H "Content-Type: application/json" -d '{"UserID": 1,"From":1,"To":2,"amount":10}' http://localhost:8888/transaction
    

lightbank's People

Contributors

tonnytg avatar

lightbank's Issues

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.