Skip to content

Instantly share code, notes, and snippets.

@bruno-brant
Last active August 22, 2019 13:30
Show Gist options
  • Save bruno-brant/386303e4a3ff565ab692aa18aeb522bc to your computer and use it in GitHub Desktop.
Save bruno-brant/386303e4a3ff565ab692aa18aeb522bc to your computer and use it in GitHub Desktop.
[medium] Coding a Non-Anemic Domain (I)
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 });
});
struct Point {
int x;
int y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment