Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

technologiestiftung/flusshygiene-postgres-api

Repository files navigation

Flusshygiene Postgres API

Build Status Greenkeeper badge Maintainability Test Coverage Known Vulnerabilities

needs a running Postgres db for testing and for development.

Run:

docker run -p 5432:5432 mdillon/postgis:10

Needs also a a lot of .env variables:

# NODE_ENV=development
# set to 0 if you are running on your machine
# 1 means in a container
NODE_DOCKER_ENV=1
# postgres
PG_USER_DEV=postgres
PG_USER_PROD=XXXXXXXXXXX

PG_HOST_DEV=127.0.0.1
PG_HOST_PROD=somthing.xxxxxxxxxxx.region.rds.amazonaws.com
# Docker specific values host needs NODE_DOCKER_ENV=1
PG_HOST_DEV_DOCKER=postgres

# database name
PG_DATABASE_DEV=postgres
PG_DATABASE_PROD=xxxxxxxxxxxxxx
# database password
PG_PASSWORD_DEV=postgres_password
PG_PASSWORD_PROD=xxxxxxxxxxxxxxxxxxxx

# database port
PG_PORT_DEV=5432
PG_PORT_PROD=5432

# port for the express server postgres-api
POSTGRES_EXPRESS_PORT_DEV=5004
POSTGRES_EXPRESS_PORT_PROD=5004


# auth0 realted values
# you will need to create an API and an application that can access it on auth0
JWKS_URI=https://you.eu.auth0.com/.well-known/jwks.json
AUTH0_AUDIENCE=your-audience
AUTH0_ISSUER=https://you.eu.auth0.com/

build with docker:

docker build username/containername:tag

run with docker:

docker run --name shortname --env-file ./path/to/.env -p=5004:5004 username/containername:tag

Github Actions

Currently only one action is available:

Release to docker Hub

When a new release is created this action will build the image and push it to docker hub.

Creating tags+release from the command line and trigger action (use hub brew install hub)

git tag -a "v0.1.4" -m "from commandline"
git push --tags
hub release create -m "from command line" v0.1.4

more infos coming soon(-ish).

DB

Migrations

See the typeorm migration guide for further explanation. In short:

# this is fish shell. Remove the `env` for bash

# generate latest state
npm run build
env NODE_DOCKER_ENV=0 env NODE_ENV=production npm run typeorm migration:generate -- --name NewMigrationFile
# generate js from ts
npm run build
env NODE_DOCKER_ENV=0 env NODE_ENV=production npm run typeorm migration:run
env NODE_DOCKER_ENV=0 env NODE_ENV=production npm run typeorm migration:revert