From aec887be68435ee46cca5f401d2e546015c2fece Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Luiz?=
<32312434+joaoluizn@users.noreply.github.com>
Date: Thu, 27 Jun 2019 14:42:25 -0300
Subject: [PATCH] Update URL-Shortener-Microservice Hint Markdown (#36299)
Creating a Hinting for this project with useful tips
---
.../url-shortener-microservice/index.md | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/guide/english/certifications/apis-and-microservices/apis-and-microservices-projects/url-shortener-microservice/index.md b/guide/english/certifications/apis-and-microservices/apis-and-microservices-projects/url-shortener-microservice/index.md
index 1f616929f5..ad2f7921e5 100644
--- a/guide/english/certifications/apis-and-microservices/apis-and-microservices-projects/url-shortener-microservice/index.md
+++ b/guide/english/certifications/apis-and-microservices/apis-and-microservices-projects/url-shortener-microservice/index.md
@@ -3,8 +3,24 @@ title: URL Shortener Microservice
---
## URL Shortener Microservice
-This is a stub. Help our community expand it.
+The core features to complete this exercise are the creation and retrieval of URLs from the Database.
-This quick style guide will help ensure your pull request gets accepted.
+## Creating Short URL
+- Connect to your database instance.
+ > **Note**: It's important to check your Mongoose connection status before dive into the problem, just to check if everything is okay with your database configuration. This should help: `mongoose.connection.readyState`
+- Receive a POST request containing an URL to be saved on Database.
+- Check if it is a valid URL using `dns.lookup(url, callback)`
+ - Remember you need to import the dns module with required.
+- Generate some kind of identifier to save your original URL in database.
+ - A SHA-1 hash could be used, or even the object ID when saving the element.
+ - There is a bunch of samples over the internet how to generate some kind of identifier, try to explore it or create your own.
+ - An example of how this should look like: `{'url': www.freecodecamp.org, 'hash': 'ef49fa8b4'}`
+
+## Retrieving Short URL
+- Receive a GET request containing an identifier used to find a stored URL.
+- Try to find one URL saved for this identifier
+- Redirect user to URL.
+ > **Note**: The `res.redirect(url)` function need that the given url, has a defined protocol (http://, https://), or it will just concatenate it as an extension of your current domain. eg: Good URL: `https://www.freecodecamp.org`, Bad URL: `www.freecodecamp.org`. Try it out.
+- Remember to handle error situations with proper response like, `res.json({"error":"invalid URL"});