This is a small web application built for beginners that highlights essential web programming topics such as:
- The HTTP request response life cycle
- Node's Express web application framework
- Fundamental patterns in computer programming (loops, branching, variables)
- Data persistence using a SQL database
- HTML templating using Handlebars
- Deploying an application using Heroku
Note: This project requires you to install PostgreSQL. See Installing PostgreSQL for instructions.
- Fork this repository
- Clone your fork
- Run
npm install
inside the project directory - Get started on the Iterations
npm run db:create
will create local databases for development and testing.
You can install PostgreSQL on a Mac with brew
:
brew install postgresql
Once installed, start the database server with
brew services start postgresql
You can install PostgreSQL on Windows using Chocolatey's choco
command:
choco install postgresql
See the Chocolatey PostgreSQL package page for more details.
Once installed, you have to add PostgreSQL's bin
directory to your PATH environment variable. Search for Edit system environment variable to open System Properties. From there, click the Environment Variables button.
Under User variables, click the row labeled Path and then click the Edit... button. Click New and add the following directory to the PATH environment variable:
C:\Program Files\PostgreSQL\12\bin
We are using two libraries two interact with the database:
- Knex.js, which is used to generate SQL queries and interact with PostgreSQL
- Objection.js, which allows us to interact with the database using JavaScript objects (rather than writing SQL queries). Under the hood, it uses Knex to talk to the database.
To create the local development database, run the following command inside the project directory:
npm run db:create
If this fails it means your PostgreSQL installation is broken. Find an instructor and get help! If PostgreSQL isn't set up correctly, nothing will work.
Next, run the following command to create the initial tables:
npx knex migrate:latest
Finally, run the following to start the server:
npm start
Visit http://localhost:3000 to see the app!
See Deploying To Heroku below for instructions on how to make the application available to the public. You can skip this step for now, if you want.
- ✔️ A guest may create a message
- ✔️ A guest may see a list of all messages
- A guest may 'like' a message
- A guest may see the number of likes on a message
- A guest may assign a 'mood' to a message, i.e., 'happy', 'sad', 'fun'
- A guest may see the mood assigned to a message
- Use some html and css to make this site look a little better
- Think of 1-2 UX improvements and make them
- Users can log in
- A message becomes associated ('owned') when it is created by a logged in User
- An author may destroy a message they own
- An author may update a message they own
- Every author has a page displaying their messages
Heroku is a service that allows us to host our application and make it available to the whole world. Every time we have a new version of our application, we push it to Heroku (a process called deploying).
One nice feature of Heroku is that we use git
to publish new versions of your application.
Before anything else, do the following:
-
Create an account on Heroku
-
Once the
heroku
command is available, log into your Heroku account with the following command:heroku login
-
Inside the project directory, run the following command to create a new Heroku application (replace
some-example-app
with a unique name for your application):heroku create some-example-app
-
Add PostgreSQL to your Heroku instance with the following command:
heroku addons:create heroku-postgresql:hobby-dev
You're now ready to deploy to Heroku using git
:
git push heroku master
Once git push
has finished, run the following command to ensure the database is up to date:
heroku run npx knex migrate:latest
Finally, run
heroku domains
to see the domain for your application. Open it up in your browser of choice!