Add full project structure: backend API + frontend
- Move repo to project root to include both public/ and api/ - Add .gitignore excluding node_modules and .env - Include API routes (erase, gmail_oauth), services (mailer), and config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
36b918b95d
commit
614d5af397
20 changed files with 2419 additions and 0 deletions
48
api/app.js
Normal file
48
api/app.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
'use strict';
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
const express = require('express');
|
||||
const helmet = require('helmet');
|
||||
const rateLimit = require('express-rate-limit');
|
||||
|
||||
const eraseRoute = require('./routes/erase');
|
||||
const gmailOAuth = require('./routes/gmail_oauth');
|
||||
|
||||
const app = express();
|
||||
|
||||
app.disable('x-powered-by');
|
||||
app.use(helmet());
|
||||
app.use(express.json({ limit: '10kb' }));
|
||||
|
||||
// Rate limiting general
|
||||
app.use(rateLimit({
|
||||
windowMs: 15 * 60 * 1000,
|
||||
max: 100,
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
}));
|
||||
|
||||
// Rate limiting específico para envío de emails (más estricto)
|
||||
const emailLimit = rateLimit({
|
||||
windowMs: 60 * 60 * 1000, // 1 hora
|
||||
max: 10,
|
||||
message: { error: 'Demasiadas solicitudes de envío. Espera antes de reintentar.' }
|
||||
});
|
||||
|
||||
// ── Rutas ────────────────────────────────────────────────────────
|
||||
app.post('/api/erase', emailLimit, eraseRoute);
|
||||
app.get('/api/gmail/auth', emailLimit, gmailOAuth.authInit);
|
||||
app.get('/api/gmail/callback', gmailOAuth.authCallback);
|
||||
|
||||
// Health check
|
||||
app.get('/api/health', (req, res) => res.json({ status: 'ok' }));
|
||||
|
||||
// ── Arranque ─────────────────────────────────────────────────────
|
||||
const PORT = process.env.PORT || 8787;
|
||||
app.listen(PORT, '127.0.0.1', () => {
|
||||
console.log(`RESETEA backend corriendo en 127.0.0.1:${PORT}`);
|
||||
if (!process.env.GOOGLE_CLIENT_ID) {
|
||||
console.warn('⚠ GOOGLE_CLIENT_ID no configurado — OAuth Gmail deshabilitado');
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue