FinkeFlo / pr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting started for development

Preparation

Install and run

# Install dependencies
$ yarn install --frozen-lockfile

# Set `DATABASE_URL` environment variable or `api/.env`
$ DATABASE_URL="postgresql://user:password@host:5432/database"

# Run DB migrations (development mode, using shadow database)
$ yarn api prisma migrate dev

# Run DB migrations (production mode, without shadow database)
$ yarn api prisma migrate deploy

# Start backend in watch mode
$ yarn api dev

# Start frontend in watch mode
$ yarn web dev

The backend provides a SwaggerUI for the REST API on /doc.

Executing tests

# lint
$ yarn lint

# unit tests
$ yarn api test

# e2e tests
$ yarn api test:e2e

Build for single deployment

Backend and frontend are served from the same domain. / shows frontend, /api leads to backend.

# Build backend
$ yarn api build

# Build frontend
$ yarn web build

# Run backend and serve frontend
$ SERVE_STATIC_PATH=../web/dist/ yarn api start

Build for separate deployment

Backend and frontend are served from different domains.

# Build backend
$ yarn api build

# Build frontend
$ VUE_APP_API_URL=http://localhost:3000/ yarn web build

# Run backend - without serving frontend code
$ yarn api start

# Serve frontend
$ yarn web serve

Production

# Build docker image (backend)
$ docker build . -f api/Dockerfile

# Build docker image (backend + frontend)
$ docker build . -f Dockerfile

Configuration parameters

All configuration parameters can be set via environment variables or using the respective .env files.

Backend Configuration is not relevant during build phase, only when actually running the code. In contrast, the frontend configuration is relevant during build phase and compiled into the build (i.e. cannot be changed afterwards).

Backend (api)

# api/.env

# PostgreSQL database
DATABASE_URL="postgresql://user:password@host:5432/database"

# E-mail address used as recipient in contact endpoint
CONTACT_RECIPIENT_EMAIL="me@example.com"

# Transport configuration for sending emails, https://nodemailer.com/smtp/
# Default: use local sendmail (if available)
MAILER_TRANSPORT="smtps://username:password@smtp.example.com/"

# Maximum score of results to be shown from fuzzy search
SECURITIES_SEARCH_MAX_SCORE=0.001

# Minimum number of results to be shown (independent from score)
SECURITIES_SEARCH_MIN_RESULTS=10

# Serve static files from this path under / and move api endpoints to /api
SERVE_STATIC_PATH="../web/dist"

# Allowed period of inactivity for sessions in seconds
SESSION_TIMEOUT=86400

# Token to download GeoIP database from www.ip2location.com (optional)
IP2LOCATION_TOKEN="..."

Frontend (web)

# web/.env

# URL to API
VUE_APP_API_URL=http://localhost:3000/

Recommended VSCode settings

To be placed in .vscode/settings.json.

{
  "editor.codeActionsOnSave": {
    // Fix eslint issues on save
    "source.fixAll.eslint": true
  },

  // Disable vue template validation by vetur, validated by eslint.
  // Vetur uses eslint-plugin-vue but doesn't pick up .eslintrc.js.
  "vetur.validation.template": false
}

About


Languages

Language:TypeScript 85.7%Language:Vue 13.2%Language:JavaScript 0.6%Language:Dockerfile 0.4%Language:HTML 0.2%