config
database
models
notes
routes
tests
.gitignore
.prettierrc
index.js
knexfile.js
LICENSE
README.md
server.js
Packager files
package.json
Config files
.replit
express-knex-postgres-boilerplate
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
Setup PostgreSQL
Homebrew (for macOS users)
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
Create dev and test database (Mac)
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
Windows
If you dont have postgres follow this link: https://www.2ndquadrant.com/en/blog/pginstaller-install-postgresql/
Create dev and test databases (Windows)
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
Environmental Variables at Runtime
Create a ".env" file at the root of your project and add the following for both DEV and TEST databases
POSTGRES_DEV_HOST=localhostPOSTGRES_DEV_PORT=5432POSTGRES_DEV_USER=postgresPOSTGRES_DEV_PASSWORD= \_Insert your postgres password here*POSTGRES_DEV_DATABASE=db-name
POSTGRES_TEST_HOST=localhostPOSTGRES_TEST_PORT=5432POSTGRES_TEST_USER=postgresPOSTGRES_TEST_PASSWORD= \_Insert your postgres password here*POSTGRES_TEST_DATABASE=db-name-test