request > uppercaser > POST tags
server.post('/tags', uppercaser, (req, res) => {});
inside the uppercaser middleware // grab data from request body // uppercase the tag information // save it to the database
client side routing vs server side routing
// checkout webpack
http://cs11rocks.com/api/ << serving the api portion of the app
http://cs11rocks.com/ << serving the client application http://cs11rocks.com/ << serving the client application
http://cs11rocks.com/users << not handled by server routing, client routing takes over http://cs11rocks.com/clients << not handled by server routing, client routing takes over
Later inside the client app axios.get('/api/clients').then().catch(); > http://cs11rocks.com/api/clients
// middleware
// routes server.api('/api', apiRouter); // server router
server.use('*', express.static('client/public'))
if (process.env.NODE_ENV === 'production') { // serve up production assets app.use(express.static('client/build'))
const path = require('path') app.get('*', (req, res) => { res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html')) }) }
application build/deployment strategies
// single application that has both client and server // single page application + single api server // microservices === breaks up the api into kinda components
npm init -y added the start script to use nodemon yarn add nodemon --dev yarn add express
req > m1 > m2 > m3 > m4 > em
folder structure (BE CONSISTENT)
- by type: reducers, components, actions
- by feature: users, clients, orders
- hybrid: type > feature || feature > type