100% LOCALE - NESSUN SERVIZIO ESTERNO!
Un server privato completo con database locale, nessun MongoDB, nessun servizio cloud.
- ✅ Database SQLite LOCALE (file .db)
- ✅ Nessun servizio esterno
- ✅ Tutto sul tuo computer
- ✅ Password criptate con bcrypt
- ✅ JWT authentication
- ✅ API REST complete
- ✅ Dashboard React admin
- ✅ Upload file
- ✅ Sicurezza integrata
npm installnpm run seedQuesto crea:
- Utenti di test
- Messaggi di esempio
- Il database locale
data/database.db
npm startIl server sarà su: http://localhost:5000
cd dashboard
npm install
npm run devApri: http://localhost:3000
Dopo npm run seed:
Email: admin@example.com
Password: admin123
POST http://localhost:5000/api/auth/register
Body: { "name": "Mario", "email": "mario@example.com", "password": "password123" }POST http://localhost:5000/api/auth/login
Body: { "email": "mario@example.com", "password": "password123" }POST http://localhost:5000/api/messages
Headers: { "Authorization": "Bearer YOUR_TOKEN" }
Body: { "receiverId": 2, "content": "Ciao!" }GET http://localhost:5000/api/messages
Headers: { "Authorization": "Bearer YOUR_TOKEN" }GET http://localhost:5000/api/users
Headers: { "Authorization": "Bearer YOUR_TOKEN" }// 1. Registra un utente
const register = await fetch('http://localhost:5000/api/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Mario Rossi',
email: 'mario@example.com',
password: 'password123'
})
});
const { data } = await register.json();
const token = data.token;
// 2. Invia un messaggio
await fetch('http://localhost:5000/api/messages', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
receiverId: 2,
content: 'Ciao! Questo è il mio messaggio.'
})
});
// 3. Ottieni tutti i messaggi
const messages = await fetch('http://localhost:5000/api/messages', {
headers: { 'Authorization': `Bearer ${token}` }
});
const { data: allMessages } = await messages.json();
console.log(allMessages);adilprivateserver/
├── data/ # Database locale SQLite
│ └── database.db # File database
├── routes/ # API routes
│ ├── auth.js
│ ├── users.js
│ ├── messages.js
│ └── files.js
├── dashboard/ # React dashboard
├── uploads/ # File caricati
├── database.js # Database manager
└── server.js # Entry point
- ✅ Password hash con bcrypt
- ✅ JWT tokens
- ✅ Helmet security headers
- ✅ CORS configurato
- ✅ Rate limiting
- ✅ Validazione input
const API_URL = 'http://TUO_IP:5000/api';
// Trova il tuo IP
ipconfig // Windows
ifconfig // Mac/Linux
// Esempio con fetch
fetch(`${API_URL}/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'mario@example.com',
password: 'password123'
})
});Il database è un file SQLite locale:
- Cartella:
data/database.db - Nessun server esterno
- Solo sul tuo computer
- Backup: copia il file
database.db
Per fare backup: copia la cartella data/
Errore: Cannot find module 'better-sqlite3'
npm installPorta già in uso?
Cambia la porta nel file .env:
PORT=5001-
npm installeseguito -
npm run seedeseguito - Server avviato con
npm start - Dashboard avviata con
cd dashboard && npm run dev - Accedi a http://localhost:3000
- Login con admin@example.com / admin123
🚀 Tutto privato, tutto locale, tutto tuo!