Coder Social home page Coder Social logo

api_account_management's Introduction

Account Management API

These are two RESTful HTTP APIs for creating and verifying user accounts and passwords. The APIs are packaged in a Docker container and hosted on Docker Hub. This README provides an overview of the project, instructions for running the container with Docker, and details on using the APIs.

Directory Structure

.
├── Dockerfile
├── README.md
├── api
│   ├── api.go
│   ├── api_test.go
│   ├── main_test.go
│   ├── routes.go
│   └── server.go
├── db
│   └── db.go
├── docker-compose.yml
├── docs
│   ├── docs.go
│   ├── swagger.json
│   └── swagger.yaml
├── errors
│   └── errors.go
├── go.mod
├── go.sum
├── main.go
├── models
│   ├── account.go
│   ├── account_test.go
│   └── models.go
├── services
│   └── account.go
└── utils
    ├── hash.go
    ├── random.go
    └── validation.go

APIs Overview

API 1: Sign up - Create Account

This API allows you to create a new user account with a desired username and password.

  • Endpoint: /v1/signup
  • HTTP Method: POST

Inputs:

{
  "username": "string", // length: 3~32
  "password": "string" // length: 8~32, with 1 lowercase letter, 1 uppercase letter and 1 number
}

Outputs:

{
  "success": true, // boolean, true or false
  "reason": "string" // reason for failure if applicable
}

API 2: Log in - Verify Account and Password

This API allows you to verify if a given username and password combination is valid.

  • Endpoint: /v1/login
  • HTTP Method: POST

Inputs:

{
  "username": "string", // length: 3~32
  "password": "string" // length: 8~32, with 1 lowercase letter, 1 uppercase letter and 1 number
}

Outputs:

{
  "success": true, // boolean, true or false
  "reason": "string" // reason for failure if applicable
}

Getting Started

To use the Account Management APIs, there are three options for you to deploy them. Follow these steps:

Install Docker before deployment.

One-click deployment

wget https://github.com/ushio0107/api_account_management/releases/download/v1.0/release_v1.0.tar.gz
./start.sh
Choose deployment method:
1. Pull Docker image from Docker Hub and run
2. Clone repo and run using Docker Compose
3. Run docker-compose up to deploy
Enter your choice (1/3): 

Option1. Just run the ./start.sh

Both of two options are provided in ./start.sh

./start.sh
> Choose deployment method:
> 1. Pull Docker image from Docker Hub and run
> 2. Clone repo and run using Docker Compose
> Enter your choice (1/2):

Option2. Pull the Docker Image from Docker Hub and Deploy:

Docker Hub Repository

docker network create <YOUR_NETWORK>
# Pull Docker image
docker pull ushio0107/account_management_api
docker pull mongo:4.4
# Run Docker
docker run --name mongo \
  --network <YOUR_NETWORK>
	-e MONGO_INITDB_ROOT_USERNAME=<DB_USERNAME> \
	-e MONGO_INITDB_ROOT_PASSWORD=<DB_PASSWORD> \
	-v ./data:/data/db \
	-p 27017:27017 \
	-d mongo:4.4 
docker run --network <YOUR_NETWORK> -e <YourEnvironmentVariable> ushio0107/account_management_api

Option3. Clone the Repo

git clone [email protected]:ushio0107/api_account_management.git
cd api_account_management
vi .env # Set your environment variable if need.
docker-compose up

You can also modify the docker-compose.yml to make the container api deployed by Dockerfile not the image from Docker hub.

api:
    container_name: account_api
    build:
    # build from Dockerfile
      context: .
      dockerfile: Dockerfile
    # image: ushio0107/account_management_api

Access the APIs:

The APIs are documented by Swagger, starts the container of the APIs and accesses the link below to access the APIs.

http://localhost:8080/swagger/index.html

Click the button Try it out, then input the parameter. login sigup

Demo

  • Sign up signup_demo
  • Log in login_demo

API Documentation

For detailed information on how to use the APIs, including sample request and response, please refer to the link.

api_documentation

Source Code

The source code for the solution is available on GitHub at github.com/ushio0107/api_account_management.

api_account_management's People

Contributors

ushio0107 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.