Skip to content

Commit 2bbca72

Browse files
committed
Complete reports system integration - connect reportRoutes to main app
1 parent cccbf68 commit 2bbca72

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ npm run test:verbose
108108
- `GET /api/files` - Retrieve file list
109109

110110
### Reports
111-
- `GET /api/reports` - Retrieve all reports
112-
- `POST /api/reports` - Create new report
113-
- `GET /api/reports/:id` - Retrieve specific report
111+
- `GET /reports/generate` - Generate a report from current data
112+
- `GET /reports/summary` - Get summary statistics of data
114113

115114
## Technologies
116115

@@ -163,15 +162,13 @@ const response = await fetch('/api/files/upload', {
163162

164163
### Generate Report
165164
```javascript
166-
const response = await fetch('/api/reports', {
167-
method: 'POST',
168-
headers: { 'Content-Type': 'application/json' },
169-
body: JSON.stringify({
170-
title: 'Monthly Revenue Report',
171-
period: '2025-01',
172-
type: 'revenue'
173-
})
174-
});
165+
// Get summary statistics
166+
const summaryResponse = await fetch('/reports/summary');
167+
const summary = await summaryResponse.json();
168+
169+
// Generate full report
170+
const reportResponse = await fetch('/reports/generate');
171+
const report = await reportResponse.json();
175172
```
176173

177174
## Environment Variables

src/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import mongoose from 'mongoose';
33
import { connectDatabase } from './config/database';
44
import { setFileRoutes } from './routes/fileRoutes';
55
import { setDataRoutes } from './routes/dataRoutes';
6+
import { setReportRoutes } from './routes/reportRoutes';
67

78
const app = express();
89
const PORT = process.env.PORT || 3000;
@@ -17,6 +18,7 @@ connectDatabase();
1718
// Set up routes
1819
setFileRoutes(app);
1920
setDataRoutes(app);
21+
setReportRoutes(app);
2022

2123
// Start the server
2224
app.listen(PORT, () => {

src/routes/reportRoutes.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Router } from 'express';
2+
import { ReportController } from '../controllers/reportController';
3+
4+
const router = Router();
5+
const reportController = new ReportController();
6+
7+
export function setReportRoutes(app: Router) {
8+
app.get('/reports/generate', reportController.generateReport.bind(reportController));
9+
app.get('/reports/summary', reportController.getSummary.bind(reportController));
10+
}

tests/app.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import request from 'supertest';
2-
import express from 'express';
2+
import express, { Request, Response } from 'express';
33

44
// Mock dependencies
55
jest.mock('../src/config/database');
@@ -24,10 +24,10 @@ describe('App', () => {
2424
// Mock implementations
2525
mockConnectDatabase.mockImplementation(() => {});
2626
mockSetFileRoutes.mockImplementation((app) => {
27-
app.get('/test-file', (req, res) => res.json({ message: 'file route' }));
27+
app.get('/test-file', (req: Request, res: Response) => res.json({ message: 'file route' }));
2828
});
2929
mockSetDataRoutes.mockImplementation((app) => {
30-
app.get('/test-data', (req, res) => res.json({ message: 'data route' }));
30+
app.get('/test-data', (req: Request, res: Response) => res.json({ message: 'data route' }));
3131
});
3232

3333
// Set up routes
@@ -56,7 +56,7 @@ describe('App', () => {
5656
});
5757

5858
it('should handle JSON middleware', async () => {
59-
app.post('/test-json', (req, res) => {
59+
app.post('/test-json', (req: Request, res: Response) => {
6060
res.json({ received: req.body });
6161
});
6262

@@ -69,7 +69,7 @@ describe('App', () => {
6969
});
7070

7171
it('should handle URL encoded middleware', async () => {
72-
app.post('/test-form', (req, res) => {
72+
app.post('/test-form', (req: Request, res: Response) => {
7373
res.json({ received: req.body });
7474
});
7575

0 commit comments

Comments
 (0)