We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eab7601 commit 6d52f2eCopy full SHA for 6d52f2e
spicecloud/pages/api/files.ts
@@ -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