All Projects → HON9LIN → go-echo-boilerplate

HON9LIN / go-echo-boilerplate

Licence: MIT license
The fastest way to build a restful API with golang and echo framework. Includes common required features for modern web applications. A boilerplate project with golang and Echo.

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to go-echo-boilerplate

javacard-gradle-template
JavaCard project template for building CAP and running JCardSim with gradle + coverage
Stars: ✭ 27 (-49.06%)
Mutual labels:  coverage, project
echo-rest-api
Example of creating REST API with Echo framework
Stars: ✭ 39 (-26.42%)
Mutual labels:  echo, echo-framework
Moderncppstarter
🚀 Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format, reproducible dependency management and much more.
Stars: ✭ 2,381 (+4392.45%)
Mutual labels:  coverage, starter
Javascript Total
Сборник практических вопросов, задач разного уровня сложности, сниппетов (утилит), паттерны проектирования, а также полезные ссылки по JavaScript
Stars: ✭ 214 (+303.77%)
Mutual labels:  example, project
nodejs-starter-template
You can use this template when you're starting a new project by using Node.js, Express, and Mongoose. It contains general concepts, you can customize it according to your needs.
Stars: ✭ 54 (+1.89%)
Mutual labels:  starter, template-project
Echox
Echo cookbook and website
Stars: ✭ 275 (+418.87%)
Mutual labels:  echo, example
node-server-template
This is Node.js server tidy template / boilerplate with Express (with asyncified handlers, custom error handler) framework and MongoDb. The server use ES6 and above. On different branches you can see different techniques' and technologies' usage, such as Kafka, nodemailer, file download... You also can find postman collections.
Stars: ✭ 116 (+118.87%)
Mutual labels:  postman, restful-api
Suicrux
🚀 Ultimate universal starter with lazy-loading, SSR and i18n. [not maintained]
Stars: ✭ 958 (+1707.55%)
Mutual labels:  example, starter
angular-cli-skeleton
angular-cli skeleton to quickly start a new project with advanced features and best practices. All features are described in README.md.
Stars: ✭ 32 (-39.62%)
Mutual labels:  coverage, starter
echo-middleware
HTTP middleware implemented for the echo framework
Stars: ✭ 39 (-26.42%)
Mutual labels:  echo, echo-framework
Node Express Postgresql Sequelize
Node.js, Express.js, Sequelize.js and PostgreSQL RESTful API
Stars: ✭ 148 (+179.25%)
Mutual labels:  example, restful-api
javascript-starter
A few simple examples to help you get started using the Clarifai Javascript client and API
Stars: ✭ 18 (-66.04%)
Mutual labels:  example, starter
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+3258.49%)
Mutual labels:  example, starter
mutant-swarm
Mutation testing framework and code coverage for Hive SQL
Stars: ✭ 20 (-62.26%)
Mutual labels:  coverage, unit-test
Expo Three Demo
🍎👩‍🏫 Collection of Demos for THREE.js in Expo!
Stars: ✭ 76 (+43.4%)
Mutual labels:  example, project
inject
A web framework inspired by spring boot, base on echo framework and dependency injection
Stars: ✭ 17 (-67.92%)
Mutual labels:  echo, echo-framework
Rxjava2 Android Samples
RxJava 2 Android Examples - Migration From RxJava 1 to RxJava 2 - How to use RxJava 2 in Android
Stars: ✭ 4,950 (+9239.62%)
Mutual labels:  example, migration
Scala Pet Store
An implementation of the java pet store using FP techniques in scala
Stars: ✭ 812 (+1432.08%)
Mutual labels:  example, project
go-onion-architecture-sample
Sample RestAPI project write in Go
Stars: ✭ 40 (-24.53%)
Mutual labels:  restful-api, echo-framework
torchjs
Test framework to light up the world.
Stars: ✭ 40 (-24.53%)
Mutual labels:  coverage, unit-test

Golang Boilerplate Project using Echo Framework

The fastest way to build a restful api with Echo with a structured project that using PostgreSQL db and JWT base authentication middleware.

This project ships following features as default

  • ORM Integration
  • Easy Database Migration
  • Authentication Using Jwt
  • Easy dotenv Management
  • Easy to Mock all Interfaces
  • CORS Configuration

Inspired from Gin boilerplate.

License Go Version DB Version Build Status Go Report Card

Configured with

  • gorm: ORM library for Golang
  • jwt-go: JSON Web Tokens (JWT) as middleware
  • mockery: Go test mock library
  • godotenv: go dotenv library
  • Go Modules
  • Built-in CORS Middleware
  • Built-in RequestID Middleware
  • Feature PostgreSQL 12
  • Environment support
  • Unit test

Installation

$ go get github.com/triaton/go-echo-boilerplate
$ cd $GOPATH/src/github.com/triaton/go-echo-boilerplate
$ go mod init
$ go install

Running Your Application

Rename .env.example to .env and place your database credentials and jwt secret key

$ mv .env.example .env
$ go run main.go

Building Your Application

$ go build -v
$ ./go-echo-boilerplate

Testing Your Application

$ go test -v ./...

Generate Code Coverage

$ chmod +x generate-test-coverage.sh
$ ./generate-test-coverage.sh

This will generate cover.html with detailed coverage result.

Make mock interfaces with mockery

$ mockery --all --keep-tree

For more information please visit this link.

Add db model, controller and service

To add a controller

  • Add *_controller.go file
  • Define controller struct, define route entries, define route handlers and request dto interfaces. Please refer auth/auth_controller.go.
  • Add controller object to routes/api.go
...
func DefineApiRoute(e *echo.Echo) {
	controllers := []common.Controller{
		auth.AuthController{},
		blogs.BlogsController{},
		// add newly added controller here 
	}
	var routes []common.Route
...

To add a service

  • Add *_service.go file.
  • Define service interface, define service methods as well as singleton methods.
  • Please don't forget to add set method. It will be used when mocking service methods.

To add db models

  • add directory models and define *.model.go file.
  • Define model struct and include models.Base. Please refer blogs/models/blog.model.go.

Add migration

Edit database/migrations.go to add a new migration. For detailed guide, please visit this link.

Import Postman Collection (API's)

Download Postman -> Import -> Import From Link https://www.getpostman.com/collections/401dc48dd6e9b15cc287

Contribution

You are welcome to contribute to keep it up to date and always improving!

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].