• 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…