• backend,  Programming,  reusability

    Creating reusable components using function wrappers (with Javascript)

    Creating reusable code is hard. I know, you have crappy deadlines coming up and you just need that feature today. But, before you go ahead and just dial in that feature, consider the future implications of it. Your code doesn’t die tomorrow, it doesn’t die next week, your code lives as long as the product does. Keeping that code base small and understandable is what ensures that working on the project remains as maintainable as possible. That’s the real reason why reusability is so important. However, that’s a discussion for another day. Today I’m covering one part of the puzzle, which is integrating wrapper functions. If you want to look…

  • backend,  Programming

    Organizing your next NodeJS+MongoDB App – Part 1

    When dealing with a project of any real substance, one needs to plan (what a thought!). Often this takes place at the diagram level and perhaps even at a technology selection level. In this multi-part post, I wanted to share my method of organizing my app’s backend. In this portion, I’ll be discussing the general layout of our app and explain what each subfolder will hold. Once we’ve established that, in the next post I’ll be going into the nitty-gritty of how some of these bits fit together Why Read This Post? You Want Easier To Maintain Files You don’t want your projects to become 2,000 line monster files. A…

  • backend,  Programming

    Adding custom validators in MongoDB+Mongoose

    Today we’re going to add custom validators to some of our documents in Mongoose. Things you’ll have to be familiar with for this article MongoDB Mongoose Nodejs Why make custom validators? When dealing with data sent over the web we often find that the inputs we are given tend to be suboptimal. We need some way of relaying to our end users that they’re not meeting our input needs. This is where validators come in. We can define a function that will arbitrate what is and isn’t an acceptable input for a given field. To get started properly let’s define a model and give it a few fields. Now that…