Welcome to HEII's topic board! Here you can post a topic (with a name and description), and vote on the topic (yes or no), but only if you are registered and log in with our site.
- As a user you can view the current posted topics (the username, name and description) and the number of votes for yes and the number of votes for no.
- You can register with our site, if your username has not already been taken and if the password meets the requirements (at least one number, upper case letter and lower case letter.
- You can then log in to the site.
- You can view any error message if anything has gone wrong in any of the processes.
- As a logged in user, you can post a new topic and vote (only once) on a topic that has been posted.
git clone https://github.com/fac-13/HEII-topics.git
- Run
npm i
to install the required modules. - Set up the local database by:
- Connect to postgres, either by
psql
(pgcli
) in the terminal on MAC, andsudo -u postgres psql
on ubuntu. - Create the database by typing
CREATE DATABASE [the name of the database];
. It's best not to use a hyphen (-
) or uppercase letters in your database name. - Create a superuser with a password - type in
CREATE USER [the new username] WITH SUPERUSER PASSWORD '[the password of the database]';
- Change ownership of the database to the new user by typing
ALTER DATABASE [name of the database] OWNER TO [the new username];
- Connect to postgres, either by
- Add a .env file (with no name) in the root folder and add the database's url in this format:
DB_URL = [the heroku database]
TEST_DB_URL = postgres://[username]:[password]@localhost:5432/[databasename]
SECRET = TAKA
- Exit postgres and the run
npm run build
to build the database. (or Build the database by connecting to postgres and typing\i
+ correct path +/ToVaHayGi/src/database/db_build.sql
) - You should now be able to run tests (using
npm test
) and also runnpm start
(ornpm run dev
) and access the site at localhost:4000.
- NB: There is currently no logout option - delete the jwt within the Cookie section of your local browser to log out).
- Simple web app with a node server and a database
- DB includes schema documentation
- DB is hosted on Heroku.
- DB built with PostgreSQL
- DB Security concerns appropriately considered (ie. script injections)
- Content dynamic, but DOM manipulation kept to a minimum
- Mobile-first design
- Clear user journey
- Clear software architecture planned out.
- Login form with 2 fields - username and password
- Client-side and server-side validation on login form, including error handling that provides feedback to users
- Users only have to log in once (i.e. implement a cookie-based session on login)
- Username is visible on each page of the site after logging in
- Any user-submitted content should be labelled with the authors username
- Website content should be stored in a database
- CSS
- Log Out and Account Deletion option
- Have an "admin" level user (role) who can edit and delete all content (permissions)
- Add comment functionality to content
- Add like functionality to content
-
We used issues to track what still needed to done: Check out our Project board
- Obtaining all of the data we wanted from our database (so we did not need to query the database multiple times).
- We did manage to solve this issues. This is the
SELECT
SQL command that obtains the necessary information from the database (including the topic id, the topic title, the topic description, the username of the user who posted the topic, the associatedd topic number of votes for yes, the associated topic number of votes for no, and the number of comments.SELECT t.id, t.topic_title AS title, t.description, u.username AS author, COUNT(CASE WHEN v.value = 'yes' THEN 1 ELSE null END) AS yes_votes, COUNT(CASE WHEN v.value = 'no' THEN 1 ELSE null END) AS no_votes, COUNT(c.*) AS comments FROM topics t LEFT JOIN users u ON t.user_id = u.id LEFT JOIN voting v ON t.id = v.topic_id LEFT JOIN comments c ON t.id = c.topic_id GROUP BY t.id, u.username ORDER BY t.id;
- We did manage to solve this issues. This is the