/micro

Primary LanguageGoMIT LicenseMIT

Docs

A microservice skeleton which can help you to build API faster.

License Go Postgres Docker

Table of Contents

🏃 Getting Started

Hi, in this section, you need to set up the repository in your machine.

👉 Just follow the instruction, and you will in set!

Preparation

Clone this repo:

git clone https://github.com/trisna-ashari/micro.git

Download project dependencies:

go mod download
go mod tidy

Install proto generator:

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

Set the env

Before you start to run this service, you should set configs with yours.

Create .env file. Take a look at: .env.example.

cp .env.dev.example .env

👉 Adjust the credential with installed dependency in your machine.

Running the service

Run migration:

go run main.go db:migrate

Run initial seeder:

go run main.go db:init

Fast run with:

go run main.go

# running on default port 6969

Run GRPC server:

Open new terminal then run this command

go run main.go grpc:start

# running on default port 4949

👉 Hot reload very useful on development processes

📖 Api documentation

This service has builtin API documentation using swagger. Just run this service and open this link in your browser:

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

To rebuild api docs, simply run:

swag init

▶ Available command

This is built-in command in this service:

Direct Command Build Command Description
go run main.go db:migrate db:migrate Run database migration based on defined struct in domain/entity path
go run main.go db:init db:init Run database seed based on predefined initial factory in domain/seeds/init_factory.go
go run main.go grpc:start grpc:start Run the GRPC server

© Copyright

Trisnul