Ulf Gebhardt 73f51b8bc4
feat(other): backend - mail api for it4c (#231)
* backend - mail api for it4c

Implements an fastify backend service with an email service.
This allows to send us emails received via contact form on the website.

* optional telephone

* missing text delimiter

* start command and correct build method to classicjs

* deploy for backend & adjust README.md

* debug deploy [1]

* debug deploy [2]

* debug deploy [3]

* debug deploy [4]

* debug deploy [5]

* finish deploy script

* watch when running npm run dev

* fix format validation

* debug sendmail[1]

* debug sendmail[2]

* debug sendmail[3]

* debug sendmail[4]

* debug sendmail[5]

* env for MAIL_HOST

* referece name in email subject

* fix format string

* eslint

* backend build & lint workflows

* order comments

* unit tests

* unit test workflow

* prettier

* alias paths

* fix esm support

* 100% tests

* corrected nodejs version

* use beforeEach to clearAllMocks

This simplifies the code and reduces redundancy

* fix wrong import
2025-03-07 10:32:56 +01:00

46 lines
1010 B
Bash
Executable File

#!/bin/sh
# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/../..
# by default this will create folders in the project root
DEPLOY_DIR=${1:-test}
BUILD_DIR=$PROJECT_ROOT/docs/.vuepress/dist
# assuming you are already on the right branch
git pull -ff
# Frontend
GIT_REF=$(git rev-parse --short HEAD)
DEPLOY_DIR_REF=$DEPLOY_DIR-$GIT_REF
## Parameter is a proper directory?
if [ -d "$DEPLOY_DIR_REF" ]; then
return "Directory '$DEPLOY_DIR_REF' does already exist" 2>/dev/null || exit 1
fi
## Build the project
cd $PROJECT_ROOT
rm -R $BUILD_DIR
npm install
npm run build
## Copy files and Sym link
mkdir "$DEPLOY_DIR_REF/"
cp -r $BUILD_DIR/* "$DEPLOY_DIR_REF/"
ln -sfn "$DEPLOY_DIR_REF" $DEPLOY_DIR
# backend
BACKEND_ROOT=$PROJECT_ROOT/backend
BACKEND_SERVICE=it4c-backend
cd $BACKEND_ROOT
pm2 stop $BACKEND_SERVICE
pm2 delete $BACKEND_SERVICE
npm install
npm run build
pm2 start 'npm run start' --name $BACKEND_SERVICE