moved routes

This commit is contained in:
2026-03-04 16:00:40 -06:00
parent 0fbb298e89
commit 15d33a116c
2 changed files with 45 additions and 35 deletions

View File

@@ -1,6 +1,7 @@
/**
* QBO Routes
* Handles QBO OAuth, sync, and data operations
* Handles QBO sync and data operations
* NOTE: OAuth auth/callback routes are in index.js (root-level paths)
*/
const express = require('express');
const router = express.Router();
@@ -22,35 +23,6 @@ router.get('/status', (req, res) => {
}
});
// GET auth URL - redirects to Intuit
router.get('/auth', (req, res) => {
const client = getOAuthClient();
const authUri = client.authorizeUri({
scope: [require('../config/qbo').OAuthClient.scopes.Accounting],
state: 'intuit-qbo-auth'
});
console.log('🔗 Redirecting to QBO Authorization:', authUri);
res.redirect(authUri);
});
// OAuth callback
router.get('/auth/callback', async (req, res) => {
const client = getOAuthClient();
try {
const authResponse = await client.createToken(req.url);
console.log('✅ QBO Authorization erfolgreich!');
saveTokens();
res.redirect('/#settings');
} catch (e) {
console.error('❌ QBO Authorization fehlgeschlagen:', e);
res.status(500).send(`
<h2>QBO Authorization Failed</h2>
<p>${e.message || e}</p>
<a href="/">Zurück zur App</a>
`);
}
});
// GET bank accounts from QBO
router.get('/accounts', async (req, res) => {
try {
@@ -597,4 +569,4 @@ router.post('/sync-payments', async (req, res) => {
}
});
module.exports = router;
module.exports = router;