Discover Packages
github.com/amallick86/country-api
command
module
Version:
v0.0.0-...-13bfd41
Opens a new window with list of versions in this module.
Published: Nov 25, 2022
License: MIT
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
country-api
Country-API Using golang
Technology Used
Golang
Postgresql (database)
Docker
JWT
Features of the project
Create User (username and password)
Login User (Generate Token Using JWT)
Renew Access Token using Refresh Token
Get Countries List from Third Party API and Save the data to the database (https://api.countrystatecity.in/v1/countries )
Get Countries List from Database with pagination
Get States List from Third Party API and Save the data to the database (https://api.countrystatecity.in/v1/states ) [data is so big so it takes few seconds]
Get States List from Database with pagination
Get Sates List of particular Country
Package Used
gin [ framework ] ( url :- https://github.com/gin-gonic/gin )
swagger [ api documentation ] ( url :- https://github.com/swaggo/gin-swagger )
ginCors [ cors ] ( url :- https://github.com/gin-contrib/cors )
JWT [ token ] ( url :- https://github.com/dgrijalva/jwt-go )
viper [ to read config file ] ( url :- https://github.com/spf13/viper )
Doumentation
http://localhost:8080/swagger/index.html#/
Steps to run
install docker on your machine
clone repo " git clone https://github.com/amallick86/country-api.git "
OPEN the project in "Goland" or "vs code"
For Windows ( OPEN start.sh and SELECT " LF " in end of line sequence )
RUN command " make dcup " OR (" docker-compose up ")[windows] || (" sudo docker-compose up ")[linux] on vs code terminal for up your composer and wait for it
Hit http://localhost:8080/swagger/index.html#/ url in chrome for the documentation
You can use above documentation to test all REST API
In above documentation click on " Authorize " button and paste your token that you get from login api, paste toke as " Bearer your_token "
Config File
On project level "app.env"
DB_DRIVER=postgres
DB_SOURCE=
SERVER_ADDRESS=
TOKEN_SYMMETRIC_KEY=
ACCESS_TOKEN_DURATION=15m
REFRESH_TOKEN_DURATION=24h
COUNTRY_STATE_API_TOKEN=
Steps to close the project
RUN command " make dcdown " OR " docker-compose down " for down your composer
RUN command " make drmi " OR " docker rmi country-api-api-1 " for remove image from your computer
Expand ▾
Collapse ▴
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Click to show internal directories.
Click to hide internal directories.