GithubHelp home page GithubHelp logo

shankar524 / go-app-invite-service Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 256 KB

Go service that allow to generate and validating invite tokens.

License: MIT License

Shell 0.63% Go 97.44% Makefile 1.93%
docker fx golang mysql redis service token gin-gonic

go-app-invite-service's Introduction

License: MIT CI

go-app-invite-service

Go service to allow generating and validating token. Admin can generate tokens, list tokens and invalidating tokens. There is a public api(throttled) which allows checking if token is valid or not This service allows generating invite token by admin. Invite token can validated. Functionalities:

  • For Admin:
    • Allows generating token(token cached in Redis)
    • Allows getting details of token
    • Allows listing tokens
    • Allows deactivating token
    • Requests are validated in admin routes(via api key validation)
  • for Public
    • Allows validating token(done via redis)
    • Request throttled for public routes

Design

System Design

Folder structure

├── api
│   ├── controller
│   ├── repository
│   ├── routes
│   └── service
├── bootstrap
├── cron
├── docs
│   └── swagger.yaml
├── img
├── lib
├── main.go
├── makefile
├── middlewares
└── models

Spinning up locally

  • install MySql Or run mysql docker image
    docker run \
      --detach \
      --name=mysql \
      --env="MYSQL_ROOT_PASSWORD=admin" \
      --env="MYSQL_USER=admin" \
      --env="MYSQL_PASSWORD=admin" \
      --env="MYSQL_DATABASE=test" \
      --publish 3306:3306 \
      mysql/mysql-server:latest
    
  • install Redis Or run Redis docker image
     docker run \
     -d --name redis \
     -p 6379:6379 \
     redis/redis-stack:latest
    
  • setup .env file
    APP_PORT=8080
    DB_USERNAME=admin
    DB_PASSWORD=admin
    DB_PORT=3306
    DB_HOST=localhost
    DB_NAME=test
    REDIS_HOST=localhost
    REDIS_PORT=6379
    REDIS_PASSWORD=
    API_KEY=test
    API_RATE=10
    
  • run app: make run

API Authentication

Admin api have authentication. API key based authentication for these routes. Add API_KEY value in .env file and supply it as api-key header field of each admin request

curl --location --request GET '<endpoint>/api/v1/admin/token' \
--header 'api-key: <api_key>'

API Documentation

API documentation is build with swagger. To run api documentation execute following command:

make doc

API Doc

go-app-invite-service's People

Contributors

shankar524 avatar

Stargazers

 avatar Sohel Mia avatar

Watchers

 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.