feat: db
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import express from 'express';
|
||||
import { Transaction } from "@shared/interfaces/transaction"
|
||||
import Transaction from '../model/transaction';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// Mock data
|
||||
const mockTransactions: Transaction[] = [
|
||||
{ id: '1', partner: 'Alice Smith', amount: 50.00, date: new Date('2026-03-01'), type: 'Received' },
|
||||
{ id: '2', partner: 'Bob Johnson', amount: -25.50, date: new Date('2026-02-28'), type: 'Sent' },
|
||||
];
|
||||
|
||||
// GET /api/transactions
|
||||
router.get('/', (req, res) => {
|
||||
res.json(mockTransactions);
|
||||
router.get('/', async (req, res) => {
|
||||
try {
|
||||
const transactions = await Transaction.findAll({ limit: 10 });
|
||||
res.json(transactions);
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch transactions:', err);
|
||||
res.status(500).json({ error: 'Failed to fetch transactions' });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user