2022-12-10 02:02:03 +00:00
|
|
|
import fsPromises from 'fs/promises'
|
|
|
|
import path from 'path'
|
2022-12-11 17:38:43 +00:00
|
|
|
import { Service, ServiceStatus } from '../../interfaces/Services';
|
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) => {
|
|
|
|
service.status = ServiceStatus.loading;
|
|
|
|
});
|
|
|
|
|
|
|
|
res.status(200).json(data.services);
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
res.status(500).json({ error: 'Error reading data' });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|