let lastChangeTime = 0;
const debounceInterval = 100; // миллисекунды
app.post('/submit', (req, res, next) => {
fs.watch('/node.js project/data1.json', (eventType, filename) => {
if (eventType === 'change') {
const now = Date.now();
if (now - lastChangeTime > debounceInterval) {
console.log('Нашёл файл.');
lastChangeTime = now;
next();
}
}
});
});