Advertisement
krle997

Untitled

Nov 26th, 2024
172
0
13 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const apiCallLogger2 = (request: any, response: any, next: (err?: any) => any): any => {
  2.   console.log("pocetak");
  3.  
  4.   const now = new Date();
  5.   const hours = now.getHours();
  6.   const minutes = now.getMinutes();
  7.  
  8.   if (
  9.     hours >= 8 && hours <= 13 &&
  10.     (hours < 13 || (hours === 13 && minutes <= 30))
  11.   ) {
  12.     console.log({hours, minutes});
  13.  
  14.     const logFilePath = path.join(__dirname, 'chatlog.txt');
  15.     let logCount = 0;
  16.  
  17.     try {
  18.       logCount = parseInt(fs.readFileSync(logFilePath, 'utf8') || '0');
  19.     } catch (err) {
  20.       console.error(err);
  21.     }
  22.  
  23.     logCount++;
  24.  
  25.     fs.writeFileSync(logFilePath, logCount.toString(), 'utf8');
  26.   }
  27.  
  28.   next();
  29. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement