Snippets of Code is a website for saving, editing finding and sharing useful snippets of code.
Try the project live at https://snippetsofcode.herokuapp.com/
The JSON API that maintains the collection of snippets is based on the Team CRaKT's Week 7 project with a few small fixes and enhancements.
The new SPA / client code is all in the public folder.
Project build as a part of Founders and Coders FAC19.
- JavaScript
- Node
- Express
- PostgreSQL
- Hand rolled SPA router in vanilla JS.
- As a user, I want to: see all the resources
- As a user, I want to: sign up for an account
- As a user, I want to: log in to my account
- As a user, I want to: add my own resources
- As a user, I want to: update my own resources
- As a user, I want to: delete my own resources
- Clone the repo
git clone https://github.com/fac19/Week8-BFOP.git
- CD into that folder
cd Week8-BFOP
- Run
npm i
to install dependencies - Setup databases
- Make sure you have a database user with superuser privileges. If you want to use and existing user you can ensure they have superuser privileges like so...
ALTER USER your_user WITH SUPERUSER;
- Create a local production database and assign it to that user.
CREATE DATABASE local_production_database_name WITH OWNER your_user;
- Create a local test database called localtest with the same owner/user
CREATE DATABASE localtest WITH OWNER your_user;
-
Create an .env file in the project's root folder
- PGDATABASE=local_production_database_name
- PGUSER=your_user
- PGPASSWORD=your_password
- SECRET=SECRETCODE You can choose a secret of your choice but if you do you won't be able to log in with the exampl accounts we have provided.
-
Run
npm run setupdb
to initialize your local production database. -
If you'd like more and proper full code examples you can import the file /db/examples.sql into your production database with your preffered db admin tool.
Run npm run dev
to run for development purposes
OR node server.js
to run server in production mode
Test can be run with npm run test
. You must have a database called localtest set up for the tests to run. No mocks here - we need to actually test our models!
There are five default users, their email addresses are.
Their passwords are all, unsurprisingly, 'password'.
The admin account is special. It can delete anyone's posts, other users can only delete their own.
Have fun and please PM us if you have an install problems!
P.S. They will almost certainly be database problems, so maybe double-check step 4.