Skip to content

Instantly share code, notes, and snippets.

View MuizMahdi's full-sized avatar
Unceasingly advancing

Muizz Mahdy MuizMahdi

Unceasingly advancing
View GitHub Profile
@MuizMahdi
MuizMahdi / Kong-pg-Konga.sh
Last active March 15, 2021 19:45
Kong-pg-Konga
# - Make sure that Postgres is running, then run Kong, and finally run Konga
#----------------------------------------------------------------|
# 1. Create Network: |
#----------------------------------------------------------------|
sudo docker network create {NETWORK}
#----------------------------------------------------------------|
class CreateOrderStageHandler implements Stage<CreateOrderCommand, String> {
private String process(CreateOrderCommand order) {
// Get shopper account Id
var shopperId = accountRepository.getAccountId(order.shopperName);
// Delete item from shopper's cart
cartRepository.deleteShopperItem(shopperId, order.item);
// Add the order
// In the API Controller
// ...
public String createOrder(CreateOrderCommand order) {
// ...
var orderCreationResult = new Pipeline<>(new CreateOrderStageHandler(order));
return orderCreationResult;
}
interface Stage<I, O> {
O process(I input);
}
class Pipeline<I, O> {
private final Stage<I, O> currentStage;
Pipeline(Stage<I, O> currentStage) {
this.currentStage = currentStage;
@Data
public class CreateOrderCommand {
String item, shopperName;
int quantity;
}