Last active
August 22, 2019 13:30
-
-
Save bruno-brant/386303e4a3ff565ab692aa18aeb522bc to your computer and use it in GitHub Desktop.
[medium] Coding a Non-Anemic Domain (I)
This file contains hidden or 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 server = require('restify').createServer(); | |
const cartRepository = require('../repositories'); | |
server.get('/cart/:cart/total', (req, res) => { | |
const cartId = Number(req.parameters.cart); | |
const cart = cartRepository.getCartById(cartId); | |
const total = cart.items.reduce((total, item) => total + item.price, 0); | |
res.send(200, { total }); | |
}); |
This file contains hidden or 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
struct Point { | |
int x; | |
int y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment