Boilerplate code for quick setup for CRUD applications using express/knex/postgres/jest/supertest
##Setup - Detailed Instructions Below
- Git clone the repo
git clone [url]
and remove origingit remote remove origin
- npm install
- setup postgres backend
- Modify .env file to suit your backend and migrate/seed db
- migrate tables
npx knex migrate:latest
- run seeds
npx knex seed:run
- npm run server
- npm run test
- modify code to suit your needs
If you dont have postgres follow this link (Follow directions until you're able to get into psql utility): https://www.codementor.io/engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb
In terminal run the following commands:
psql
-- To get into postgreSQL utilityCREATE DATABASE db-name;
-- Creates development serverCREATE DATABASE db-name-test;
-- Creates testing server\q
- CD into your repo
If you dont have postgres follow this link: https://www.2ndquadrant.com/en/blog/pginstaller-install-postgresql/
Set up Postgres and create databases for both the development server (db-name) and testing server (db-name-test)
- Open pgAdmin, sign in with your master password created during the set up of postgres.
- Create a server if needed, if already created, turn server on by right clicking and pressing "Connect Server"
- Once connected, look for the drop down for databases and right click to Create a database
- Create a database called 'db-name' for the development connection & (db-name-test) for the testing connection
Create a ".env" file at the root of your project and add the following for both DEV and TEST databases
POSTGRES_DEV_HOST=localhost
POSTGRES_DEV_PORT=5432
POSTGRES_DEV_USER=postgres
POSTGRES_DEV_PASSWORD= \_Insert your postgres password here*
POSTGRES_DEV_DATABASE=db-name
POSTGRES_TEST_HOST=localhost
POSTGRES_TEST_PORT=5432
POSTGRES_TEST_USER=postgres
POSTGRES_TEST_PASSWORD= \_Insert your postgres password here*
POSTGRES_TEST_DATABASE=db-name-test