Tag: node

Read More
Mongoose Featured Image

Mongoose: Get started with MongoDB object mapping

Mongoose is a Node.js library that provides MongoDB object mapping features. To put it simple, it creates extensible JavaScript Object representations of the documents stored in a MongoDB instance.

It sounds a tidy bit more complicated that what it actually is, let’s get started with a few examples straight away. If you are familiar with the MongoDB in Node.js, you probably know that managing documents can become a bit cumbersome.

Read More
Create a Request Header Parser Microservice with Node.js

Create a Request Header Parser Microservice in Node.js

This time, we are going to be creating a request header parser microservice in Node.js. Keep in mind that I’ll be using a set-up similar to  that used by the previous two tutorials; for those who have not read them, that means that we’ll be using Express, and code our app using ECMAScript 6 thanks to Babel.

Feel free to go though the creation of a simple Express app post, as well as the set-up for using ECMAScript 6 within your node app.

Read More
ECMAScript 6 in Node.js with Babel

Use ECMAScript 6 in Node.js with Babel

ECMAScript 6 is a great step for JavaScript. It provides some invaluable tools that make developing new code a bliss. If you want to learn about the features that ECMAScript 6 (also known as ECMAScript 2015, ES6 or ES2015), take a look at this two part series:

Unfortunately, Node.js will not let you use ES6 features out of the box. It does provide a way of using some of the ECMAScript 6 features, but not the whole thing. That’s what we are here to fix.

Read More
Create a Timestamp Microservice with Node.js

Create a Timestamp microservice with Node.js

This time around, we are going to be coding our own timestamp microservice using Node.js, and then, deploy it to Heroku. It’s going to be a very simple service that will return the unix time and natural date for the received input. Our API should be able to receive and properly handle the following two formats:

  • A unix timestamp is a metric used to track time by displaying the miliseconds (sometimes seconds) that have passed since January 1st, 1970 at 00:00:00 UTC. For a quick test, you can get the unix timestamp for right now, by going into the Chrome DevTools console and typing the following: Date.now();
  • The natural language date means that the date is passed in the following format: October 1, 2016.

Our timestamp microservice will accept any one of these two formats, and then, return a JSON object containing both formats. In other words:

  • If the API receives this: 1477388794872, it will output the following JSON object:
    {
      "unix": 1477388794872,
      "natural": "October 25, 2016"
    }
  • Receiving “October 25, 2016” will output the same exact JSON object.

If no unix timestamp nor natural date is present, we’ll return null for both fields:

{
  "unix": null,
  "natural": null
}
Read More
Bower, your new best friend

Bower, your new best friend… Or bird.

Applications grow in size and complexity by the day, and as new needs arise, new tools do too. Bower is one of them, let me tell you about it.

One day, you’re just bringing in jQuery into your nice little project, and then, suddenly, in a weeks time, you need to keep track of a framework, plugins, JS and CSS libraries and whatnot for this other side thing you’re doing. You may just keep a long txt file with a list of CDNs or an overloaded library folder with all of your favorite resources, and that is okay. You’re just missing out on the greatness of Bower, your new best friend.

Today, I’m going to show you the power of NPM and Bower working in tandem. I’ll expand on this in future posts by bringing in a few more tools (Gulp/Grunt, RequireJS, Webpack/Browserify) that you’ll surely find useful, I promise!

Bower is a very handy tool that fetches and brings in anything that you need for your project. That means libraries, frameworks, assets and, according to the official site, rainbows too. Anything that you may ever need is a few keystrokes away.

Before we get into the matter though, we need to get a couple dependencies set up; namely: NPM (Node Package Manager) and Git. Let’s get started.