Skip to content

Commit

Permalink
counter
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Dec 29, 2023
1 parent 533ba24 commit dfd9ba8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions install.ztnet/src/routes/getBashInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { Request, Response } from 'express';
import fs from 'fs';
import { removeTrailingSlash } from '../utils/helpers';

// Initialize a counter variable at the top level
let downloadCounter = 0;

//fetch bash script
export const getBashInstaller = async function (req: Request, res: Response) {
const url = removeTrailingSlash(req.url);
Expand All @@ -26,6 +29,11 @@ export const getBashInstaller = async function (req: Request, res: Response) {
return;
}

// File exists, increment the download counter and log it with the current date
downloadCounter++;
const currentDate = new Date().toISOString();
console.log(`[${currentDate}] Bash file has been downloaded ${downloadCounter} times.`);

//file exists
res.download(fileURL, 'install.sh', options);
});
Expand Down

0 comments on commit dfd9ba8

Please sign in to comment.