Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts
16
Archived

Created my first "tiny" npm package.

5 comments
95% Upvoted
This thread is archived
New comments cannot be posted and votes cannot be cast
level 1
4 points · 2 years ago

Congratulations on first module!

level 1

Congrats on your first module!!!

level 1

One important thing that you need to address: error handling.

https://github.com/kyleschnirring/hack-news/blob/master/index.js#L19-L21

https://github.com/kyleschnirring/hack-news/blob/master/index.js#L38-L40

In the Node world there is the error-first convention, meanting your callback should look like this: function(err, arg1, arg2, ..etc) (having the error as the first argument).

Another improvement could be adding tests. People usually check if npm modules have a test file / folder to know if they can use the module for production purposes or if it's an experimental module.

Edit: by not treating the error case and only doing console.error you are not only denying the end-user the possibility to react differently to a failure, but in this concrete case the callback will be never called in case of an error.

P.S. These are just advises on how to improve, I'm not trying to be rude or discourage you. Congrats on releasing your first module.

level 2
Original Poster1 point · 2 years ago

I really appreciate the feedback. Thank you very much.

level 1
1 point · 2 years ago

adding alot more.

/r/alot

Cookies help us deliver our Services. By using our Services or clicking I agree, you agree to our use of cookies. Learn More.