I was trying to create an endpoint in node.js, more specifically in express
but I am not sure why I can't access userService variable when requesting from a client.
I've gotten Cannot read property 'userService' of undefined, but when i move ServicesFactory.getInstance().getUserService() inside the signUp function it works?!
I am guessing that node.js garbage collects it due to it's not being used until the user make a request.
export class UserApi implements WebEndpoint {
    router: Router
    userService = ServicesFactory.getInstance().getUserService()
    constructor() {
        this.router = Router()
        this.router.post('/signup', this.signUp)
    }
    signUp(req: Request, res: Response): void {
        const user: User = req.body
        this.userService.signUp(user)
        res.send("Successfully registered")
    }
}
