- Clear feature ownership
- Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
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
app.put('/user/:userId', (req, res) => { | |
User.findByIdAndUpdate(req.params.userId, $set: req.body.data, (updateFailedError, user) => { | |
if (updateFailedError) { | |
res | |
.status(500) | |
.json({ | |
errors: [updateFailedError] | |
}); | |
} | |
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
app.put('/user/:userId', (req, res) => { | |
User.update({ _id: req.params.userId }, $set: req.body.data, (updateFailedError) => { | |
if (updateFailedError) { | |
res | |
.status(500) | |
.json({ | |
errors: [updateFailedError] | |
}); | |
} | |
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
app.put('/user/:userId', (req, res) => { | |
User.findById(req.params.userId, (queryFailedError, user) => { | |
if (queryFailedError) { | |
res | |
.status(500) | |
.json({ | |
errors: [queryFailedError] | |
}); | |
} |
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
// beware of dragons | |
// don't put your brackets on a new line | |
function actionCreator(data) { | |
return | |
{ | |
type: 'EATEN_BY_A_DRAGON', | |
data | |
} | |
} |
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
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, |
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
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, |
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
/** | |
* When writing event handlers it’s common to adopt the handle{eventName} naming convention. | |
*/ | |
handleClick(e) { /* do something */ } | |
// For components that handle several event types, these function names can be repetitive. The names themselves might not provide much value, as they simply proxy to other actions/functions. | |
handleClick() { require("./actions/doStuff")(/* action stuff */) } | |
handleMouseEnter() { this.setState({ hovered: true }) } | |
handleMouseLeave() { this.setState({ hovered: false }) } |
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
function fantasticMiddleware(req, res, next) { | |
console.log("I am fantastic!") | |
} | |
router.use("/listOrders", fantasticMiddleware); | |
router.use("/getTotal", fantasticMiddleware); |
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
function fantasticMiddleware(req, res, next) { | |
console.log("I am fantastic!") | |
} | |
router.use(/^\/(listOrders|getTotal)\/?$/, fantasticMiddleware) |