A microservice skeleton which can help you to build API faster.
- Getting started
- Preparation
- Set the env
- Running the service
- Api documentation
- Available command
- Copyright
Hi, in this section, you need to set up the repository in your machine.
👉 Just follow the instruction, and you will in set!
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
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.
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
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
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 |
Trisnul