/nodejs-with-postgres-api-example

k8s course example - node.js app with Postgres, Hapi.js and Swagger

Primary LanguageJavaScript

Node.js with Postgres Example

Swagger Page of that application

Requirements

  • Node.js v8+ or Docker and Docker Compose
  • Postgres running on local instance or Docker

Running on localMachine

  • Install dependencies - npm i
  • Run project - npm start

OR: Docker

  • docker-compose up

OR: Alternatives on pulling from Docker hub

docker run -d -p 5432:5432 --name postgres \
    --env POSTGRES_PASSWORD=mysecretpassword \
    --env POSTGRES_DB=heroes\
    postgres
docker run -p 3000:3000 \
    --link postgres:postgres \
    -e POSTGRES_HOST=postgres:mysecretpassword@postgres:5432 \
    -e POSTGRES_DB=heroes \
    -e POSTGRES_SSL=false \
    erickwendel/nodejs-with-postgres-api-example:latest

Viewing

  • Go to swagger page - localhost:3000/documentation