Skip to content

Commit 6d52f2e

Browse files
committed
api endpoint to return all analyzed files
1 parent eab7601 commit 6d52f2e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

spicecloud/pages/api/files.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// pages/api/files.ts
2+
import { promises as fs } from 'fs';
3+
import path from 'path';
4+
5+
export default async function handler(req: any, res: { status: (arg0: number) => { (): any; new(): any; json: { (arg0: { error: string; }): void; new(): any; }; }; }) {
6+
try {
7+
const filePath = path.join(process.cwd(), 'data', 'metrics.json');
8+
const fileContent = await fs.readFile(filePath, 'utf-8');
9+
const jsonData = JSON.parse(fileContent);
10+
res.status(200).json(jsonData);
11+
} catch (err) {
12+
console.error('Erro ao ler metrics.json', err);
13+
res.status(500).json({ error: 'Failed to load metrics.json' });
14+
}
15+
}

0 commit comments

Comments
 (0)