How to access a common object or variable in different files in ts (next.js)?

I use Next.js. I have one file with code:

export let counter = 0;

In the first file of api route /api/test1 I add number to counter:

counter += 5;

In the seconds file of api /api/test2 I want to get updated a value of counter:

console.log('counter', counter); // 5

But I get 0;

How can I get the current counter value in seconds file?

p.s. I simplified the task, using the example of a counter.