package.json
with
$ npm install
$ npm install -g webpack knex
$BLOG_DB_NAME
environment variable)
psql -c CREATE DATABASE [insert_dev_db_name_here];
createdb [insert_dev_db_name_here]
~/.bash_profile
, or wherever you store them. This is required for the knexfile.js
$NODE_ENV
environment variable to dev
, so that the knexfile
knows which configuration to useFor reference, my local environment variables look like this in my ~/.bash_profile
file:
# Node environment
export NODE_ENV='dev'
# DB credentials
export BLOG_DB_PORT=5432
export BLOG_DB_HOST='localhost'
export BLOG_DB_NAME='blog' # this should match the db you created above
export BLOG_DB_USER=''
export BLOG_DB_PW=''
Migrate the database, build the client, and run the server:
$ npm start
which is the same as:
$ npm run db:migrate # Ensures the db is up to date with latest migrations
$ npm run build # Builds the React client
$ node server/javascript/index.js # Runs the Node/Express server
Go to localhost:8000
(or whatever $PORT
you set) to check that the app is running.
The current focus of this project is in the server/javascript
directory for the API, and the client/react
directory for the client.
To simply start the server, run:
$ npm run dev
This will serve the contents of the client/react/build
directory, which are built with Webpack.
To run Webpack in --watch
mode, run:
$ npm run watch
And that should be it! Happy hacking 🤓