Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
TZ=UTC
PORT=3000
NODE_ENV=development

STORAGE_PATH=./uploads

MYSQL_DATABASE=herbario_dev
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USERNAME=root
MYSQL_PASSWORD=masterkey

MYSQL_MIGRATION_USERNAME=root
MYSQL_MIGRATION_PASSWORD=masterkey

RECAPTCHA_SECRET_KEY=6LcYYYYYYYYYYYYYY

JWT_SECRET=your-jwt-secret-here
TZ=UTC
PORT=3000
NODE_ENV=development

STORAGE_PATH=./uploads

MYSQL_DATABASE=herbario_dev
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USERNAME=root
MYSQL_PASSWORD=masterkey

MYSQL_MIGRATION_USERNAME=root
MYSQL_MIGRATION_PASSWORD=masterkey

RECAPTCHA_SECRET_KEY=6LcYYYYYYYYYYYYYY

JWT_SECRET=your-jwt-secret-here

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER="seu-email@gmail.com"
SMTP_PASS="sua-senha-de-app-de-16-digitos"
SMTP_FROM="Sistema HCF <no-reply@hcf.com>"

URL_PAINEL=http://localhost:5173/
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run lint
npm run lint
187 changes: 94 additions & 93 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,94 +1,95 @@
{
"name": "hcf-api",
"version": "0.1.1",
"description": "Projeto para construção da API para o sistema do Herbário da UTFPR",
"main": "dist/app/index.js",
"author": "Elaine Sangali <e.nani@gmail.com>",
"license": "MIT",
"private": true,
"engines": {
"node": "^22"
},
"scripts": {
"migration:create": "tsx --env-file=.env src/database/cli.ts migration:create",
"migration:apply": "tsx --env-file=.env src/database/cli.ts migration:apply",
"lint:typescript": "tsc --noEmit",
"lint:eslint": "eslint --cache --fix --ext '.js,.ts,.tsx' .",
"lint": "run-p lint:typescript lint:eslint",
"clean": "rimraf dist",
"build:app": "babel -d ./dist -x '.js,.ts,.tsx' --copy-files --no-copy-ignored ./src",
"start": "nodemon --ext 'js,ts,tsx' --exec babel-node --extensions '.js,.ts,.tsx' ./src/index.js",
"build": "run-s clean build:app",
"test": "jest",
"prepare": "husky",
"audit": "npm audit --audit-level=moderate",
"audit:fix": "npm audit fix"
},
"devDependencies": {
"@babel/cli": "7.27.0",
"@babel/core": "7.26.10",
"@babel/node": "7.26.0",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/preset-env": "7.22.10",
"@babel/preset-react": "7.26.3",
"@babel/preset-typescript": "7.22.15",
"@types/express": "5.0.1",
"@types/jest": "30.0.0",
"@types/react": "19.1.0",
"@types/react-dom": "19.1.1",
"@typescript-eslint/eslint-plugin": "6.7.0",
"@typescript-eslint/parser": "6.7.0",
"babel-plugin-module-resolver": "5.0.0",
"chai": "4.1.2",
"chai-http": "^4.0.0",
"eslint": "8.49.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.1.0",
"eslint-import-resolver-typescript": "3.6.0",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-import-helpers": "1.3.1",
"husky": "9.1.7",
"jest": "29.7.0",
"nodemon": "3.1.9",
"npm-run-all": "4.1.5",
"typescript": "5.8.3"
},
"dependencies": {
"axios": "^1.10.0",
"bcrypt": "5.1.1",
"bluebird": "3.7.2",
"body-parser": "2.2.0",
"commander": "13.1.0",
"cors": "2.8.5",
"date-fns": "4.1.0",
"dotenv": "16.3.1",
"ejs": "^2.6.1",
"express": "5.1.0",
"express-validator": "7.2.1",
"fast-csv": "^5.0.5",
"handlebars": "^4.7.8",
"helmet": "^8.0.0",
"jsonwebtoken": "9.0.2",
"express-rate-limit": "^7.4.1",
"knex": "2.5.1",
"moment": "^2.24.0",
"moment-timezone": "^0.5.21",
"morgan": "1.10.0",
"multer": "1.4.5-lts.2",
"mysql2": "3.14.0",
"node-wkhtmltopdf": "^2.0.0",
"puppeteer": "24.6.0",
"q": "^1.5.1",
"react": "19.1.0",
"react-dom": "19.1.0",
"request": "^2.88.0",
"sequelize": "^4.38.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"throttled-queue": "^1.0.5",
"tsx": "4.19.3",
"uuid": "11.1.0",
"wkhtmltopdf": "^0.4.0"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
{
"name": "hcf-api",
"version": "0.1.1",
"description": "Projeto para construção da API para o sistema do Herbário da UTFPR",
"main": "dist/app/index.js",
"author": "Elaine Sangali <e.nani@gmail.com>",
"license": "MIT",
"private": true,
"engines": {
"node": "^22"
},
"scripts": {
"migration:create": "tsx --env-file=.env src/database/cli.ts migration:create",
"migration:apply": "tsx --env-file=.env src/database/cli.ts migration:apply",
"lint:typescript": "tsc --noEmit",
"lint:eslint": "eslint --cache --fix --ext '.js,.ts,.tsx' .",
"lint": "run-p lint:typescript lint:eslint",
"clean": "rimraf dist",
"build:app": "babel -d ./dist -x '.js,.ts,.tsx' --copy-files --no-copy-ignored ./src",
"start": "nodemon --ext 'js,ts,tsx' --exec babel-node --extensions '.js,.ts,.tsx' ./src/index.js",
"build": "run-s clean build:app",
"test": "jest",
"prepare": "husky",
"audit": "npm audit --audit-level=moderate",
"audit:fix": "npm audit fix"
},
"devDependencies": {
"@babel/cli": "7.27.0",
"@babel/core": "7.26.10",
"@babel/node": "7.26.0",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/preset-env": "7.22.10",
"@babel/preset-react": "7.26.3",
"@babel/preset-typescript": "7.22.15",
"@types/express": "5.0.1",
"@types/jest": "30.0.0",
"@types/react": "19.1.0",
"@types/react-dom": "19.1.1",
"@typescript-eslint/eslint-plugin": "6.7.0",
"@typescript-eslint/parser": "6.7.0",
"babel-plugin-module-resolver": "5.0.0",
"chai": "4.1.2",
"chai-http": "^4.0.0",
"eslint": "8.49.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.1.0",
"eslint-import-resolver-typescript": "3.6.0",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-import-helpers": "1.3.1",
"husky": "9.1.7",
"jest": "29.7.0",
"nodemon": "3.1.9",
"npm-run-all": "4.1.5",
"typescript": "5.8.3"
},
"dependencies": {
"axios": "^1.10.0",
"bcrypt": "5.1.1",
"bluebird": "3.7.2",
"body-parser": "2.2.0",
"commander": "13.1.0",
"cors": "2.8.5",
"date-fns": "4.1.0",
"dotenv": "16.3.1",
"ejs": "^2.6.1",
"express": "5.1.0",
"express-validator": "7.2.1",
"fast-csv": "^5.0.5",
"handlebars": "^4.7.8",
"helmet": "^8.0.0",
"jsonwebtoken": "9.0.2",
"express-rate-limit": "^7.4.1",
"knex": "2.5.1",
"moment": "^2.24.0",
"moment-timezone": "^0.5.21",
"morgan": "1.10.0",
"multer": "1.4.5-lts.2",
"mysql2": "3.14.0",
"node-wkhtmltopdf": "^2.0.0",
"nodemailer": "^7.0.9",
"puppeteer": "24.6.0",
"q": "^1.5.1",
"react": "19.1.0",
"react-dom": "19.1.0",
"request": "^2.88.0",
"sequelize": "^4.38.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"throttled-queue": "^1.0.5",
"tsx": "4.19.3",
"uuid": "11.1.0",
"wkhtmltopdf": "^0.4.0"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
72 changes: 36 additions & 36 deletions script/database-sync/database-sync.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
#!/bin/bash

set -e
set -o pipefail

EXCLUDE_PARAMS=""
if [ -n "$SYNC_EXCLUDE_TABLES" ]; then
IFS=',' read -ra TABLES <<< "$SYNC_EXCLUDE_TABLES"
for table in "${TABLES[@]}"; do
table=$(echo "$table" | xargs) # trim whitespace
if [ -n "$table" ]; then
EXCLUDE_PARAMS="$EXCLUDE_PARAMS --ignore-table=${SYNC_SOURCE_DATABASE}.${table}"
fi
done
echo "Excluding tables: $SYNC_EXCLUDE_TABLES"
fi

echo "Starting synchronization process..."

mysqldump \
-h "$SYNC_SOURCE_HOST" \
-P "$SYNC_SOURCE_PORT" \
-u "$SYNC_SOURCE_USER" \
${SYNC_SOURCE_PASSWORD:+-p"$SYNC_SOURCE_PASSWORD"} \
$EXCLUDE_PARAMS \
--single-transaction \
"$SYNC_SOURCE_DATABASE" | \
mysql \
-h "$SYNC_DEST_HOST" \
-P "$SYNC_DEST_PORT" \
-u "$SYNC_DEST_USER" \
${SYNC_DEST_PASSWORD:+-p"$SYNC_DEST_PASSWORD"} \
"$SYNC_DEST_DATABASE"


echo "Synchronization completed successfully: ${SYNC_SOURCE_DATABASE} -> ${SYNC_DEST_DATABASE}"
#!/bin/bash

set -e
set -o pipefail

EXCLUDE_PARAMS=""
if [ -n "$SYNC_EXCLUDE_TABLES" ]; then
IFS=',' read -ra TABLES <<< "$SYNC_EXCLUDE_TABLES"
for table in "${TABLES[@]}"; do
table=$(echo "$table" | xargs) # trim whitespace
if [ -n "$table" ]; then
EXCLUDE_PARAMS="$EXCLUDE_PARAMS --ignore-table=${SYNC_SOURCE_DATABASE}.${table}"
fi
done
echo "Excluding tables: $SYNC_EXCLUDE_TABLES"
fi

echo "Starting synchronization process..."

mysqldump \
-h "$SYNC_SOURCE_HOST" \
-P "$SYNC_SOURCE_PORT" \
-u "$SYNC_SOURCE_USER" \
${SYNC_SOURCE_PASSWORD:+-p"$SYNC_SOURCE_PASSWORD"} \
$EXCLUDE_PARAMS \
--single-transaction \
"$SYNC_SOURCE_DATABASE" | \
mysql \
-h "$SYNC_DEST_HOST" \
-P "$SYNC_DEST_PORT" \
-u "$SYNC_DEST_USER" \
${SYNC_DEST_PASSWORD:+-p"$SYNC_DEST_PASSWORD"} \
"$SYNC_DEST_DATABASE"


echo "Synchronization completed successfully: ${SYNC_SOURCE_DATABASE} -> ${SYNC_DEST_DATABASE}"
34 changes: 17 additions & 17 deletions script/database-sync/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/sh

echo "Configuring cron job with schedule: $CRON_SCHEDULE (timezone: $TZ)"

# ensure environment variables are passed to the cron job
printenv | grep -E "^SYNC_" >> /etc/environment

echo "$CRON_SCHEDULE /database-sync.sh 1> /proc/1/fd/1 2> /proc/1/fd/2" | crontab -

if ! crontab -l >/dev/null 2>&1; then
echo "Failed to configure cron job"
exit 1
fi

crontab -l

exec $@
#!/bin/sh
echo "Configuring cron job with schedule: $CRON_SCHEDULE (timezone: $TZ)"
# ensure environment variables are passed to the cron job
printenv | grep -E "^SYNC_" >> /etc/environment
echo "$CRON_SCHEDULE /database-sync.sh 1> /proc/1/fd/1 2> /proc/1/fd/2" | crontab -
if ! crontab -l >/dev/null 2>&1; then
echo "Failed to configure cron job"
exit 1
fi
crontab -l
exec $@
Loading