Tag: Array Methods

Read More
Image search abstraction layer

Create an Image Search Abstraction Layer with Node.js

Today, we are going to be building an image search abstraction layer that is built on top of the Bing search API. For this purpose, we’ll make use of Node.js + Express and Mongoose as an object manager for MongoDB. Additionally, we’ll harness the power of ECMAScript 6 using Babel.

If you are not familiar with Mongoose, take a look at this recent post. If you want to know more about ECMAScript 6 usage in Node.js with Babel, give this other article a read first.

Read More

Create a URL Shortener with Node.js and MongoDB

URL shorteners are very useful. Remembering long and tedious URL addresses, or sharing 100 character URLs with your peers is not what we would call, convenient. That’s why we have services such as the Google URL Shortener, Bitly or TinyURL.

We are going to replicate the functionality that these pages offer to some extent. We’ll start off by creating an API using Node.js and the Express framework, and will integrate with a MongoDB instance to store information making use of Mongoose.

The functionality is quite straightforward, we must implement two endpoints in our application:

  • /new/URL_TO_SHORTEN: Creates a new short URL for the provided long URL.
  • /SHORT_URL: Will redirect to the long version of the provided short URL.

Instead of babbling around, let’s set up the project and install all of our dependencies.

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