Reddit-like web app built with React and Redux.
Clone this repository in your computer:
$ git clone https://github.com/calaca/reactnd-readable.git
Or download it as a ZIP file.
You'll need to install Node and NPM (they come together when you install Node): NodeJS - Downloads
Open a terminal at the project root:
cd api-server
npm install
cd ../frontend
npm install
npm start
: runs the app in development modenpm run build
: builds the app for production to thebuild
foldernpm run test
: runs the test watcher in an interactive modenpm run eject
: ejects the app so you have full control over configuration files and the transitive dependencies
To run these, make sure you are at the frontend
folder.
- Open a terminal and go to
./api-server
- Run the server with
node server
(keep this terminal open) - Open another terminal and go to the client app source folder
./frontend
- Run the React app with
npm start
- Start coding!
Click here for the live version of this app.
npm start
: starts the server for deploymentnpm run postinstall
: builds the app for production/deployment to thebuild
folder
To run these, make sure you are at the root folder.
Tests will be coming soon.
This is how to deploy using Heroku:
- Install Heroku CLI
- Make changes to the project
- Add the changes with
git add .
- Add a commit with
git commit -m 'deploy time!'
- Login to Heroku with
heroku login
- Create a Heroku app with
heroku create
- Push to Heroku with
git push heroku master
- Run
heroku open
to view your project in your default browser
These are all executed at root folder.
Here are the changes I had to make to api-server/server.js
to make it serve React static files and handle API routes properly:
- Configure a
package.json
at root folder specifying node and npm versions, plus scripts for start and post install - Change api routes to start with
/api
- Change authorization middleware to only watch routes that start with
/api
- Create a route to serve static files from React build folder only in production mode
- React - A JavaScript library for building user interfaces
- React Router - Declarative routing for React
- Redux - Redux is a predictable state container for JavaScript apps
- react-redux - Official React bindings for Redux
- Heroku - Platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud
Please read CONTRIBUTING for details on the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details