book-prj


node+express+mongo+jade


node packages
lodash to extend underscore filter, min, first, sort, ... npm install --save lodash

$ git clone git@github.com:mshahriarinia/bookprj.git
$ cd bookprj
$ npm init

$ express bookprj
$ git init
$ git remote add origin git@github.com:mshahriarinia/bookprj.git
$ git push --set-upstream origin master
$ git pull origin master
$ heroku create --http-git
$ git push heroku master
$ heroku ps:scale web=1
$ heroku open




define schemas
define env configs
connect to db
create routes and functions
add authentication





express used as router for react weblog with twitter oauth. jlongster github
very simple define express routes, isAdmin on routes.
enterance is app.js and code is in api.js file where all the routes end up to, module.exports are defined at the buttom/.
module.exports = {
  connect: connect,
  quit: quit,
  getPost: getPost,
  getPosts: getPosts,
  queryPosts: queryPosts,
  queryDrafts: queryDrafts,
  createPost: createPost,
  renamePost: renamePost,
  updatePost: updatePost,
  deletePost: deletePost,
  db: db,
  dbkey: dbkey,
  getClient: function() {
    return client;
  }
};
the main react component is here. i oculdnt track how it's connected to or called

React provides a great infrastructure for server-rendering, but you need a lot more. You need to be able to run the same routes server-side and figure out which data your components need. This is where react-router comes in. This is the critical piece for complex React apps.

It's a great router for the client-side, but it also provides the pieces for server-rendering. For my blog, I specify the routes in routes.js, and the router is run in the bootstrap file. The server and client call this run function. The router tells me the components that are required for the specific URL.

For data handling, I copied an approach from the react-router async data example. 


here is a simple webpack with react for static client all-in-one-place thing. 

express.js 4 https://scotch.io/bar-talk/expressjs-4-0-new-features-and-upgrading-from-3-0





client side routes can be different from server side routes. e.g. a form can be in multiple steps or client can offer various ways to sort data and stuff like that. but server only offers basic functionality of REST or also provide those or not. 

So first we define the rest routes of server then define any routes in client we mght want; So we are essnetially defining routes both for our express and our client



$  express hp_rest_server

$ cd hp_rest_server && npm install    #   install dependencies:
$ DEBUG=hp_rest_server:* ./bin/www       # run the app
















Comments