I am using nodejs server. I have a file with a class in which the functionality is written. The functionality of this class is the same for the backend and for the frontend. I do not want to create two files with the same functionality.
A file with a class has dependencies - other classes in other files.
How to connect files on the backend and frontend? What should the classes look like for this?
nodejs back-end app.js:
let player = new Player();
player.goTo(10,20);
front-end index.js:
let player = new Player();
player.goTo(10,20);
It's files need include to frontend and backend:
Player.js:
Class Player
{
goTo(x,y){
Path.pathFinding()
}
}
Path.js:
Class Path
{
pathFinding(){
//doing something
}
}