DEV Community

Discussion on: Designing a better architecture for a Node.js API

Collapse
 
junaidlodhi7 profile image
Muhammad Junaid Lodhi • Edited

@thiago Pacheco: I like the implementation of the architecture,
I am having problem runnning the project can you help me out.

in Base Controller, I get this error when I run the project.
this.get = this.get.bind(this);

can not read property bind of undefined.

NOTE:I have not changed anything and trying to run the code

Can you please me in running code so I can continue working on it?

Collapse
 
pacheco profile image
Thiago Pacheco

Hi Muhammad,

Thank you for sharing that.
Actually, this is an extra line that was not supposed to be in this file.
I was trying to reduce the size of the project to make it simpler, but I forgot to remove this call.
You can just remove the following line from the Controller constructor:
this.get = this.get.bind(this);

I already fixed it in the post, sorry for the error.

Let me know if that worked for you.

Collapse
 
junaidlodhi7 profile image
Muhammad Junaid Lodhi

It worked for me, Thanks a lot .

I also removed

server.get(/api/post/:params, PostController.get);
from routes.js

Thanks a lot.

Thread Thread
 
pacheco profile image
Thiago Pacheco

Perfect Muhammad, thank you very much!