This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { articleTestFactory } from '~/domain/article'; | |
import { shoppingCartTestFactory, itemTestFactory } from '~/domain/shoppingCart'; | |
import { InMemoryShoppingCartRepository } from '~/infrastructure/InMemoryShoppingCartRepository'; | |
import { InMemoryArticleRepository } from '~/infrastructure/InMemoryArticleRepository'; | |
describe('addArticleToCart', () => { | |
it('should update, persist and return the cart with a new article', async () => { | |
// Arrange | |
const shoppingCartRepository = new InMemoryShoppingCartRepository(); | |
const shoppingCart = shoppingCartTestFactory({items: []}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Repository implementation example | |
class InMemoryShoppingCartRepository implements ShoppingCartRepository { | |
findById(shoppingCartId: ShoppingCartId) { | |
// implementation | |
} | |
store(ShoppingCart: ShoppingCart): Promise<void> { | |
// implementation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Repository interface example | |
interface ShoppingCartRepository { | |
findById(shoppingCartId: ShoppingCartId): Promise<ShoppingCart>; | |
store(shoppingCart: ShoppingCart): Promise<void>; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Our ShoppingCart example of an Entity is actually also an aggregate. | |
class ShoppingCart { | |
id: ShoppingCartId; | |
items: Array<ShoppingCartItem> | |
addItem(item: ShoppingCartItem) { | |
// implementation | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For e-commerce, an example of a domain service would be the checkout step | |
function checkout(shoppingCart: ShoppingCart, ...) { | |
// do service stuff | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An example of an Entity | |
class ShoppingCart { | |
id: ShoppingCartId; | |
items: Array<ShoppingCartItem> | |
addItem(item: ShoppingCartItem) { | |
// implementation | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An example of a Value Object | |
class Price { | |
amountInEuroCents: number | |
inEuros(): number { | |
// implementation | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"heroku-postbuild": "./scripts/heroku.build", | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
usage() { | |
echo "OVERVIEW: Build apps according to BUILD_ENV value. Meant to be used for Heroku deployment" | |
exit | |
} | |
if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then | |
usage | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const morgan = require('morgan'); | |
const path = require('path'); | |
const PORT = process.env.PORT || 3000; | |
const app = express(); | |
const logger = morgan( | |
process.env.NODE_ENV !== 'production' ? 'dev' : 'combined', |
NewerOlder