This project encompasses the 5-week coach's challenge for What To Say Now, an initiative by WithAll.
This version uses React, Redux, Express, Passport, and PostgreSQL (a full list of dependencies can be found in package.json
).
Before you get started, make sure you have the following software installed on your computer:
Create a new database called what_to_say_now
and follow the instructions in database.sql
.
- Run
npm install
- Create a
.env
file at the root of the project and paste this line into the file:While you're in your newSERVER_SESSION_SECRET=superDuperSecret
.env
file, take the time to replacesuperDuperSecret
with some long random string like25POUbVtx6RKVNWszd9ERB9Bb6
to keep your application secure. Here's a site that can help you: https://passwordsgenerator.net/. If you don't do this step, create a secret with less than eight characters, or leave it assuperDuperSecret
, you will get a warning. - Start postgres if not running already by using
brew services start postgresql
- Run
npm run server
- Run
npm run client
- Navigate to
localhost:3000
To use Postman with this repo, you will need to set up requests in Postman to register a user and login a user at a minimum.
Keep in mind that once you using the login route, Postman will manage your session cookie for you just like a browser, ensuring it is sent with each subsequent request. If you delete the localhost
cookie in Postman, it will effectively log you out.
- Start the server -
npm run server
- Import the sample routes JSON file by clicking
Import
in Passport. Select the file. - Click
Collections
andSend
the following three calls in order:POST /api/user/register
registers a new user, see body to change username/passwordPOST /api/user/login
will login a user, see body to change username/passwordGET /api/user
will get user information, by default it's not very much
After running the login route above, you can try any other route you've created that requires a logged in user!
We used Heroku to deploy this project.
- Create a new Heroku project
- Link the Heroku project to the project GitHub Repo
- Create an Heroku Postgres database
- Connect to the Heroku Postgres database from Postico
- Create the necessary tables
- Add an environment variable for
SERVER_SESSION_SECRET
with a nice random string for security - In the deploy section, select manual deploy
- React
- Redux
- Redux Saga
- node-cron
- react-chartjs-2
- Twilio
- NodeMailer
src/
contains the React application, reducers, and Redux Sagaspublic/
contains static assets for the client-sidebuild/
after you build the project, contains the transpiled code fromsrc/
andpublic/
that will be viewed on the production siteserver/
contains the Express App
This code is also heavily commented. We recommend reading through the comments, getting a lay of the land, and becoming comfortable with how the code works before you start making too many changes.