I have 2 routes (example1 and example2), I want to have a global general variable that can be accessible by these 2 routes.
One example:
//api/variable.ts
let test = 0
//api/example1.ts
setTest =() => {
test=2
}
//api/example2.ts
getTest =() => {
return test
}
Now I want to call some routes and the value of the variable should be updated
// mainFile.ts
setTest()
getTest() // It should return 2, but it returns 0
How could I create a global variable like that? I tried to use a singleton class just for this variable, but it didn't work.