primo commit
This commit is contained in:
commit
2eb778c4a8
9 changed files with 2340 additions and 0 deletions
46
.github/workflows/deploy.yml
vendored
Normal file
46
.github/workflows/deploy.yml
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
name: Deploy to VPS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: https://github.com/actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --prefer-offline
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
|
||||
- name: Deploy via SSH
|
||||
uses: https://github.com/appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.VPS_HOST }}
|
||||
username: ${{ secrets.VPS_USER }}
|
||||
key: ${{ secrets.VPS_SSH_KEY }}
|
||||
script: |
|
||||
echo "START DEPLOY"
|
||||
cd /root/esameits24-26backend
|
||||
git pull --ff-only
|
||||
docker compose up -d --build
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
node_modules/
|
||||
dist/
|
||||
.env
|
||||
56
docker-compose.yml
Normal file
56
docker-compose.yml
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: dockerfile/Dockerfile
|
||||
container_name: esameits24-26backend
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DB_HOST: mysql
|
||||
DB_PORT: 3309
|
||||
PORT: 3007
|
||||
FRONTEND_URL: https://esameits24-26frontend.andreavillari.it
|
||||
AUTH_URL: https://esameits24-26backend.andreavillari.it
|
||||
AUTH_TRUST_HOST: "true"
|
||||
ports:
|
||||
- "127.0.0.1:3007:3007"
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: mysql_esamiits24-26
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
||||
MYSQL_USER: ${MYSQL_USER}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||
volumes:
|
||||
- dbdata:/var/lib/mysql
|
||||
- ./initdb:/docker-entrypoint-initdb.d # opzionale: script SQL iniziali
|
||||
ports:
|
||||
- "127.0.0.1:3310:3306"
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
phpmyadmin:
|
||||
image: phpmyadmin:latest
|
||||
container_name: phpmyadmin_esameits24-26
|
||||
restart: always
|
||||
ports:
|
||||
- "127.0.0.1:8086:80"
|
||||
environment:
|
||||
PMA_HOST: mysql
|
||||
depends_on:
|
||||
- mysql
|
||||
|
||||
volumes:
|
||||
dbdata:
|
||||
29
initdb/00_database.sql
Normal file
29
initdb/00_database.sql
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
-- ============================================================
|
||||
-- Database: esameits24-26
|
||||
-- Creazione database e utente applicativo
|
||||
-- MySQL 8.0+
|
||||
-- ============================================================
|
||||
-- Con Docker Compose il database e l'utente vengono creati
|
||||
-- automaticamente dalle variabili MYSQL_* nel file .env.
|
||||
-- Questo script è utile per installazione manuale su MySQL locale.
|
||||
-- ============================================================
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS esameits24-26
|
||||
CHARACTER SET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE USER IF NOT EXISTS 'esameits24-26_user'@'%'
|
||||
IDENTIFIED BY 'altra_password_sicura';
|
||||
|
||||
CREATE USER IF NOT EXISTS 'esameits24-26_user'@'localhost'
|
||||
IDENTIFIED BY 'altra_password_sicura';
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE
|
||||
ON esameits24-26.*
|
||||
TO 'esameits24-26_user'@'%';
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE
|
||||
ON esameits24-26.*
|
||||
TO 'esameits24-26'@'localhost';
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
27
initdb/01_schema.sql
Normal file
27
initdb/01_schema.sql
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-- ============================================================
|
||||
-- Schema tabelle – esameits24-26
|
||||
-- Allineato alle API: /utenti,
|
||||
-- ============================================================
|
||||
|
||||
USE prenotazioni;
|
||||
|
||||
-- ------------------------------------------------------------
|
||||
-- Tabella utenti (API: GET/POST/PUT/DELETE /utenti)
|
||||
-- ------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS utenti (
|
||||
UtenteID INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
Nome VARCHAR(100) NOT NULL,
|
||||
Cognome VARCHAR(100) NOT NULL,
|
||||
Email VARCHAR(255) NOT NULL,
|
||||
PasswordHash VARCHAR(255) NOT NULL COMMENT 'Password salvata come hash (es. bcrypt)',
|
||||
Admin BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY (UtenteID),
|
||||
UNIQUE KEY uk_utente_email (Email)
|
||||
) ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
|
||||
18
initdb/02_seed.sql
Normal file
18
initdb/02_seed.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-- ============================================================
|
||||
-- Dati iniziali di test – esameits24-26
|
||||
-- Password per tutti gli utenti: Password123!
|
||||
--
|
||||
-- Operatori:
|
||||
-- 1 Andrea Villari – admin@centro.it (Admin)
|
||||
-- 2 Maria Bianchi – maria.bianchi@centro.it (operatore)
|
||||
--
|
||||
-- ============================================================
|
||||
|
||||
USE prenotazioni;
|
||||
|
||||
-- ------------------------------------------------------------
|
||||
-- Operatori
|
||||
-- ------------------------------------------------------------
|
||||
INSERT INTO operatore (Nome, Cognome, Email, PasswordHash, Admin) VALUES
|
||||
('Andrea', 'Villari', 'admin@centro.it', '$2b$10$7Z80qZcDydZCdLrOcaH/VOa9knKWjQVyyg8MtEgBAvgfNMsiLEZze', TRUE),
|
||||
('Maria', 'Bianchi', 'maria.bianchi@centro.it', '$2b$10$7Z80qZcDydZCdLrOcaH/VOa9knKWjQVyyg8MtEgBAvgfNMsiLEZze', FALSE);
|
||||
2121
package-lock.json
generated
Normal file
2121
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
24
package.json
Normal file
24
package.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@auth/express": "^0.12.2",
|
||||
"bcryptjs": "^3.0.3",
|
||||
"cors": "^2.8.6",
|
||||
"dotenv": "^17.4.2",
|
||||
"express": "^5.2.1",
|
||||
"mysql2": "^3.22.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
"@types/cors": "^2.8.19",
|
||||
"@types/express": "^5.0.6",
|
||||
"@types/node": "^26.1.1",
|
||||
"tsx": "^4.23.0",
|
||||
"typescript": "^7.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
16
tsconfig.json
Normal file
16
tsconfig.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue