2022-12-10 02:02:03 +00:00
|
|
|
import fsPromises from 'fs/promises'
|
|
|
|
import path from 'path'
|
2022-12-17 00:20:58 +00:00
|
|
|
import { Service, Status } from '../../interfaces/CardTypes';
|
2022-12-10 02:02:03 +00:00
|
|
|
|
|
|
|
export default async function ServicesAPI(req: any, res: any) {
|
|
|
|
try {
|
|
|
|
const filePath = path.join(process.cwd(), '/public/pages.json')
|
|
|
|
const data = await fsPromises.readFile(filePath)
|
|
|
|
.then((file) => JSON.parse(file.toString()));
|
|
|
|
data.services.forEach((service: Service) => {
|
2022-12-17 00:20:58 +00:00
|
|
|
service.status = Status.loading;
|
2022-12-10 02:02:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
res.status(200).json(data.services);
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
res.status(500).json({ error: 'Error reading data' });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|