Giter Club home page Giter Club logo

express-knex-postgres-boilerplate's Introduction

express-knex-postgres-boilerplate

Boilerplate code for quick setup for CRUD applications using express/knex/postgres/jest/supertest

##Setup - Detailed Instructions Below

  1. Git clone the repo git clone [url] and remove origin git remote remove origin
  2. npm install
  3. setup postgres backend
  4. Modify .env file to suit your backend and migrate/seed db
  5. migrate tables npx knex migrate:latest
  6. run seeds npx knex seed:run
  7. npm run server
  8. npm run test
  9. 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.tecmint.com/install-postgresql-with-pgadmin4-on-linux-mint/

Create dev and test database (Mac)

In terminal run the following commands:

  1. psql -- To get into postgreSQL utility
  2. CREATE DATABASE db-name; -- Creates development server
  3. CREATE DATABASE db-name-test; -- Creates testing server
  4. \q
  5. 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)

  1. Open pgAdmin, sign in with your master password created during the set up of postgres.
  2. Create a server if needed, if already created, turn server on by right clicking and pressing "Connect Server"
  3. Once connected, look for the drop down for databases and right click to Create a database
  4. 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=localhost
    POSTGRES_DEV_PORT=5432
    POSTGRES_DEV_USER=postgres
    POSTGRES_DEV_PASSWORD= \_Insert your postgres password here*
    POSTGRES_DEV_DATABASE=db-name

Todo

  • Add Docker and/or docker-compose
    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

express-knex-postgres-boilerplate's People

Contributors

raberin avatar luisabellan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.