Boilerplate for React application with webpack using alt's Flux running on a node express server.
| React + Redux / alt + Immutable + Express + mongoose + MongoDB |
https://react-webpack-node.herokuapp.com/
Isomorphic Flux using:
On master branch: - redux - react-router - redux-simple-router
On flux/alt branch: - alt as my Flux implementation - iso to help with bootstrapping data for isomorphic Flux - react-router
Note: If you have previously used an alt implementation of this repository, please refer to this branch. I will not be updating it as frequently as master, but definitely welcome suggestions!
I'm really a fan of this implementation. The main principles of having:
make it very fun and easy to write predictable code! Redux also has a really good ecosystem and strong support from the community.
Having isomorphic React was one of my key criteria when choosing a Flux library, which helped narrow down the scope of libraries.
I found alt's implementation to be clean and simple, and like the option of allowing us to create alt instances or using singletons (and flushing the stores). I also like the direction in which alt is heading.
The aim of this repo is to incorporate the best practices to building a non-trivial apps with Reactjs and Node. I am working to document this repo extensively so it would be easy for both beginners and experts to begin dev-ing on it without pulling your hair out.
mongodRun the commands below for a production build, i.e. what is deployed to Heroku. If you are deploying to Heroku or similar, we assume that you serving the pages over HTTPS.
npm run build to clean the /public folder, and then run webpack through configurations specified in webpack.config.prod.jsnpm start to start servernpm run dev starts the server with webpack-hot-middleware and react-transform-hmrnpm run build && npm run dev (because the server relies on the compiled file to exist in order to serve those files).We use ExtractTextPlugin to extract compiled css in our webpack config file
babel-loader. Seriously, try it!
Install MongoDB:
brew updatebrew install mongodbmongod (Make sure you have the permissions to the directory /data/db)If you're interested in a boilerplate example with postgresql, check reap out!
heroku createheroku app:rename newname if you need togit push heroku masterNote: If you are working from a different machine and get heroku does not appear to be a remote repository message, be sure to run git remote add heroku git@heroku.com:appname.git.
heroku open to open the linkheroku addons:add mongohq or heroku addons:add mongolab. Note: For Google Auth, read Setting up Google Authentication below
npm installsudo npm install pm2 -gpm2 start server/index.jspm2 startup ubuntusudo env PATH=$PATH:/usr/local/bin pm2 startup ubuntu -u sammyRead more on DO config here
For Google Auth to work locally, you need to do the following in your terminal before starting the server:
export GOOGLE_CLIENTID=YOUR_CLIENTID
export GOOGLE_SECRET=YOUR_SECRET
Fret not! Heroku's covered this pretty well.
heroku config:set GOOGLE_CLIENTID=YOUR_CLIENTID
heroku config:set GOOGLE_SECRET=YOUR_SECRET
heroku config:set GOOGLE_CALLBACK=YOUR_CALLBACK
Don't you worry child. Read this.
You can learn more about ES6 (or ES2015) here.
Error: Failed to serialize user into session when trying to login with email/password locally?It's because there are no users created in your local DB so it's throwing an error on the server's end. We haven't set up the handling of errors for this yet. I intend to fix this. If you check this, you'll see that there is a /signup endpoint for creating a user. In the meantime, a quick and easy way to do this is to paste this in your console log while your server is running:
var http = new XMLHttpRequest();
var url = "http://localhost:3000/signup";
var params = "email=example@ninja.com&password=ninja";
http.open("POST", url, true);http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send(params);
This should create a user in your local database and all will be well!!
Best way to keep up to date is check the issues.
My priorities are: 1. Improving the server side rendering 2. Better dev experience 3. Auth routing 4. Unit tests
Credits to webpack-server-side-example, example-app, flux-examples, node-express-mongo-demo, hackathon-starter, web-starter-kit, awesome material-ui, alt and iso, react-starter, reap.
MIT
$ claude mcp add reactGo \
-- python -m otcore.mcp_server <graph>