Tag: mongoosejs

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
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.