DEV Community

Discussion on: JavaScript CRUD Rest API using Nodejs, Express, Sequelize, Postgres, Docker and Docker Compose

Collapse
 
antonfridlund profile image
Anton Fridlund

Hello!
I think this read was quite interesting, good guide.

There were however a few things i noticed that I don't often see in modern JavaScript programming.

Usually you would avoid chaining calls with ".then" since it is bad practice, use "await" instead. Is there a reason why you chain your calls like this even when it's bad practice?

Exporting arrow functions in the controller leads to poor readability and is also not a common way to handle controllers. You would probably want to create a class that represents the controller and export that class. Do you have a reason for exporting arrow functions?

Something that I was wondering throughout the guide was why you use "require" instead of "import", basically why commonjs instead of esm? Commonjs is since long dying and i would not recommend using it.

The JavaScript code in the guide seems to be quite old and I would be careful if I were to use it.

Collapse
 
francescoxx profile image
Francesco Ciulla

nice breakdown Anton! this is not optimized and it's meant to get things fast. the focus here was more on creating the endpoints and the docker image and the connection with the db.

about the async await, I just used the suggested code, but in other guides I used the await, honestly I prefer that one

this is not meant to be a production ready code, but it's a way to undesrtand the basics!

Thanks for your feedback, I will probably level up the code in the next guide!

Collapse
 
antonfridlund profile image
Anton Fridlund

Thank you for the explanation!
I was happy to see such a thorough guide as a whole.

It was interesting to see how you containerize the application and I also liked the testing of the end product using Postman and TablePlus, great tools.

Thank you for the guide!

Thread Thread
 
francescoxx profile image
Francesco Ciulla

my idea was to start with this and maybe focus more on the upcoming Typescript example. this article is a breakthrough of something I coded live on youtube.

Thank yuo for your feedback, highly appreciated instead of the usual "asweome" comment! 💙

Thread Thread
 
karlkras profile image
Karl Krasnowsky

A typescript version would be great! Thanks for your effort.
Awesome! 😄

Thread Thread
 
francescoxx profile image
Francesco Ciulla

it's on the todo list. thanks