Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/BuildApp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
SHA: ${{ steps.short-sha.outputs.sha }}
with:
args: >
-Dsonar.organization=pangolin-do-golang
-Dsonar.projectKey=pangolin-do-golang_tech-challenge
-Dsonar.organization=pangolin-golang
-Dsonar.projectKey=pangolin-do-golang_tech-challenge-order-api
-Dsonar.projectVersion=${{ env.SHA }}
-Dsonar.qualitygate.wait=true
-Dsonar.verbose=true
Expand Down
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:

# Next hooks are Code Quality hooks.
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-golang
args:
- --autofix
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Miro Board: https://miro.com/app/board/uXjVKVoZwos=/?share_link_id=718027124865

# Tech Challenge
# Tech Challenge Order API

## Install

Expand Down Expand Up @@ -45,7 +45,7 @@ docker compose build

docker compose up -d

curl --request GET --url http://localhost:8080/health
curl --request GET --url http://localhost:8082/health

## Expected response
= Status Code 200
Expand Down Expand Up @@ -137,10 +137,7 @@ kubectl port-forward svc/tech-challenge-service 4000:80 -n dev
- `cmd`: Application entry point directory for the application's main entry points, dependency injection, or commands. The web subdirectory contains the main entry point to the REST API.
- `internal`: Directory to contain application code that should not be exposed to external packages.
- `core`: Directory that contains the application's core business logic.
- `cart`: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Cart.
- `customer`: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Customer.
- `order`: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Order.
- `product`: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Product.
- `adapters`: Directory to contain external services that will interact with the application core.
- `db`: Directory contains the implementation of the repositories.
- `rest`: Directory that contains the definition of the application's controllers and handlers for manipulating data provided by the controller
Expand Down
37 changes: 7 additions & 30 deletions cmd/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ import (
"os"

"github.com/joho/godotenv"
_ "github.com/pangolin-do-golang/tech-challenge/docs"
dbAdapter "github.com/pangolin-do-golang/tech-challenge/internal/adapters/db"
"github.com/pangolin-do-golang/tech-challenge/internal/adapters/rest/server"
"github.com/pangolin-do-golang/tech-challenge/internal/core/cart"
"github.com/pangolin-do-golang/tech-challenge/internal/core/customer"
"github.com/pangolin-do-golang/tech-challenge/internal/core/order"
"github.com/pangolin-do-golang/tech-challenge/internal/core/product"
_ "github.com/pangolin-do-golang/tech-challenge-order-api/docs"
dbAdapter "github.com/pangolin-do-golang/tech-challenge-order-api/internal/adapters/db"
"github.com/pangolin-do-golang/tech-challenge-order-api/internal/adapters/rest/server"
"github.com/pangolin-do-golang/tech-challenge-order-api/internal/core/order"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)

// @title Tech Challenge Food API
// @title Tech Challenge Order Food API
// @version 0.1.0
// @description Fast Food API for FIAP Tech course

Expand All @@ -29,25 +26,11 @@ func main() {
panic(err)
}

customerRepository := dbAdapter.NewPostgresCustomerRepository(db)
customerService := customer.NewService(customerRepository)

productRepository := dbAdapter.NewPostgresProductRepository(db)
productService := product.NewProductService(productRepository)

cartRepository := dbAdapter.NewPostgresCartRepository(db)
cartProductsRepository := dbAdapter.NewPostgresCartProductsRepository(db)
cartService := cart.NewService(cartRepository, cartProductsRepository)

orderRepository := dbAdapter.NewPostgresOrderRepository(db)
orderProductRepository := dbAdapter.NewPostgresOrderProductsRepository(db)
orderService := order.NewOrderService(orderRepository, orderProductRepository, cartService, productService)
orderService := order.NewOrderService(orderRepository)

restServer := server.NewRestServer(&server.RestServerOptions{
OrderService: orderService,
ProductService: productService,
CartService: cartService,
CustomerService: customerService,
OrderService: orderService,
})

restServer.Serve()
Expand All @@ -68,13 +51,7 @@ func initDb() (*gorm.DB, error) {
}

err = db.AutoMigrate(
&dbAdapter.CustomerPostgres{},
&dbAdapter.ProductPostgres{},
&dbAdapter.OrderPostgres{},
&dbAdapter.CartPostgres{},
&dbAdapter.CartProductsPostgres{},
&dbAdapter.OrderPostgres{},
&dbAdapter.OrderProductPostgres{},
)
if err != nil {
log.Fatalln(err)
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ services:
server:
build:
context: .
container_name: go_tech_challenge_app
container_name: go_tech_challenge_order_app
restart: always
links:
- pgsql:pgsql
ports:
- "8080:8080"
- "8082:8080"
depends_on:
pgsql:
condition: service_started
Expand Down
Loading
Loading