{"id":63919,"date":"2019-04-23T04:22:27","date_gmt":"2019-04-23T11:22:27","guid":{"rendered":"http:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/"},"modified":"2019-04-23T04:22:27","modified_gmt":"2019-04-23T11:22:27","slug":"building-a-node-js-express-api-to-convert-markdown-to-html","status":"publish","type":"post","link":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/","title":{"rendered":"Building A Node.js Express API To Convert Markdown To HTML"},"content":{"rendered":"<link rel=\"canonical\" href=\"https:\/\/www.smashingmagazine.com\/2019\/04\/nodejs-express-api-markdown-html\/\"><title>Building A Node.js Express API To Convert Markdown To HTML<\/title><\/p>\n<article>\n<header>\n<h1>Building A Node.js Express API To Convert Markdown To HTML<\/h1>\n<address>Sameer Borate<\/address>\n<p>                  <time datetime=\"2019-04-23T12:30:16+02:00\">2019-04-23T12:30:16+02:00<\/time><time datetime=\"2019-04-23T11:06:50+00:00\">2019-04-23T11:06:50+00:00<\/time><\/header>\n<p>Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an easy-to-read and easy-to-write plain text format and to optionally convert it to structurally valid XHTML (or HTML). Currently, with WordPress supporting Markdown, the format has become even more widely used.<\/p>\n<p>The purpose of writing the article is to show you how to use Node.js and the Express framework to create an API endpoint. The context in which we will be learning this is by building an application that converts Markdown syntax to HTML We will also be adding an authentication mechanism to the API so as to prevent misuse of our application.<\/p>\n<h3>A Markdown NodeJS Application<\/h3>\n<p>Our teeny-tiny application, which we will call \u2018Markdown Convertor\u2019, will enable us to post Markdown-styled text and retrieve an HTML version. The application will be created using the Node.js Express framework, and support authentication for conversion requests.<\/p>\n<p>We will build the application in small stages \u2014 initially creating a scaffold using Express and then adding various features like authentication as we go along. So let us start with the initial stage of building the application by creating a scaffold.<\/p>\n<div data-component=\"FeaturePanel\" data-audience=\"non-subscriber\" data-remove=\"true\"><\/div>\n<h3>Stage 1: Installing Express<\/h3>\n<p>Assuming you\u2019ve already installed Node.js on your system, create a directory to hold your application (let\u2019s call it \u201c<code>markdown-api<\/code>\u201d), and switch to that directory:<\/p>\n<pre><code>$ mkdir markdown-api\n$ cd markdown-api\n<\/code><\/pre>\n<p>Use the npm init command to create a <em>package.json<\/em> file for your application. This command prompts you for a number of things like the name and version of your application.<\/p>\n<p>For now, simply hit <kbd>Enter<\/kbd> to accept the defaults for most of them. I\u2019ve used the default entry point file as <em>index.js<\/em>, but you could try <em>app.js<\/em> or some other depending on your preferences.<\/p>\n<p>Now install Express in the <code>markdown-api<\/code> directory and save it in the dependencies list:<\/p>\n<pre><code>$ npm install express --save\n<\/code><\/pre>\n<p>Create an <em>index.js<\/em> file in the current directory (<code>markdown-api<\/code>) and add the following code to test if the Express framework is properly installed:<\/p>\n<pre><code>Const express = require('express');\nvar app = express();\n \napp.get('\/', function(req, res){\n    res.send('Hello World!');\n});\n \napp.listen(3000);\n<\/code><\/pre>\n<p>Now browse to the URL <code>http:\/\/localhost:3000<\/code> to check whether the test file is working properly. If everything is in order, we will see a Hello World!\u2019 greeting in the browser and we can proceed to build a base API to convert Markdown to HTML.<\/p>\n<h3>Stage 2: Building A Base API<\/h3>\n<p>The primary purpose of our API will be to convert text in a Markdown syntax to HTML. The API will have two endpoints:<\/p>\n<ul>\n<li><code>\/login<\/code><\/li>\n<li><code>\/convert<\/code><\/li>\n<\/ul>\n<p>The <code>login<\/code> endpoint will allow the application to authenticate valid requests while the <code>convert<\/code> endpoint will convert (obviously) Markdown to HTML.<\/p>\n<p>Below is the base API code to call the two endpoints. The <code>login<\/code> call just returns an \u201cAuthenticated\u201d string, while the <code>convert<\/code> call returns whatever Markdown content you submitted to the application. The home method just returns a \u2018Hello World!\u2019 string.<\/p>\n<div>\n<pre><code>const express = require(\"express\");\nconst bodyParser = require('body-parser');\n    \nvar app = express();\napp.use(bodyParser.urlencoded({ extended: true }));\napp.use(bodyParser.json());\n \napp.get('\/', function(req, res){\n    res.send('Hello World!');\n});\n \napp.post('\/login', function(req, res) {\n    res.send(\"Authenticated\");\n  },\n);\n \napp.post(\"\/convert\", function(req, res, next) {\n    console.log(req.body);\n    if(typeof req.body.content == 'undefined' || req.body.content == null) {\n        res.json([\"error\", \"No data found\"]);\n    } else {\n        res.json([\"markdown\", req.body.content]);\n    }\n});\n \napp.listen(3000, function() {\n console.log(\"Server running on port 3000\");\n});\n<\/code><\/pre>\n<\/div>\n<p>We use the <code>body-parser<\/code> middleware to make it easy to parse incoming requests to the applications. The middleware will make all the incoming requests available to you under the <code>req.body<\/code> property. You can do without the additional middleware but adding it makes it far easier to parse various incoming request parameters.<\/p>\n<p>You can install <code>body-parser<\/code> by simply using npm:<\/p>\n<pre><code>$ npm install body-parser\n<\/code><\/pre>\n<p>Now that we have our dummy stub functions in place, we will use Postman to test the same. Let\u2019s first begin with a brief overview of Postman.<\/p>\n<div><\/div>\n<h4>Postman Overview<\/h4>\n<p>Postman is an API development tool that makes it easy to build, modify and test API endpoints from within a browser or by downloading a desktop application (browser version is now deprecated). It has the ability to make various types of HTTP requests, i.e. GET, POST, PUT, PATCH. It is available for Windows, macOS, and Linux.<\/p>\n<p>Here\u2019s a taste of Postman\u2019s interface:<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/462c5b77-18e5-498d-a06e-f59276859c4f\/nodejs-express-api-markdown-html-postman-intro.png?ssl=1\"><\/p>\n<p>    <img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-postman-intro.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/462c5b77-18e5-498d-a06e-f59276859c4f\/nodejs-express-api-markdown-html-postman-intro.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/462c5b77-18e5-498d-a06e-f59276859c4f\/nodejs-express-api-markdown-html-postman-intro.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/462c5b77-18e5-498d-a06e-f59276859c4f\/nodejs-express-api-markdown-html-postman-intro.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/462c5b77-18e5-498d-a06e-f59276859c4f\/nodejs-express-api-markdown-html-postman-intro.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-postman-intro.png?w=900\" sizes=\"100vw\" alt=\"Postman interface\"><\/a><figcaption>\n      (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/462c5b77-18e5-498d-a06e-f59276859c4f\/nodejs-express-api-markdown-html-postman-intro.png\">Large preview<\/a>)<br \/>\n    <\/figcaption><\/figure>\n<p>To query an API endpoint, you\u2019ll need to do the following steps:<\/p>\n<ol>\n<li>Enter the URL that you want to query in the URL bar in the top section;<\/li>\n<li>Select the HTTP method on the left of the URL bar to send the request;<\/li>\n<li>Click on the \u2018Send\u2019 button.<\/li>\n<\/ol>\n<p>Postman will then send the request to the application, retrieve any responses and display it in the lower window. This is the basic mechanism on how to use the Postman tool. In our application, we will also have to add other parameters to the request, which will be described in the following sections.<\/p>\n<h3>Using Postman<\/h3>\n<p>Now that we have seen an overview of Postman, let\u2019s move forward on using it for our application.<\/p>\n<p>Start your <code>markdown-api<\/code> application from the command-line:<\/p>\n<pre><code>$ node index.js<\/code><\/pre>\n<p>To test the base API code, we make API calls to the application from Postman. Note that we use the POST method to pass the text to convert to the application.<\/p>\n<p>The application at present accepts the Markdown content to convert via the <code>content<\/code> POST parameter. This we pass as a URL encoded format. The application, currently, returns the string verbatim in a JSON format \u2014 with the first field always returning the string <code>markdown<\/code> and the second field returning the converted text. Later, when we add the Markdown processing code, it will return the converted text.<\/p>\n<h3>Stage 3: Adding Markdown Convertor<\/h3>\n<p>With the application scaffold now built, we can look into the <code>Showdown<\/code> JavaScript library which we will use to convert Markdown to HTML. Showdown is a bidirectional Markdown to HTML converter written in Javascript which allows you to convert Markdown to HTML and back.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7634b6ea-e153-48cc-8001-67c21e08e3ac\/nodejs-express-api-markdown-html-base-postman-test.png?ssl=1\"><\/p>\n<p>    <img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-base-postman-test.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7634b6ea-e153-48cc-8001-67c21e08e3ac\/nodejs-express-api-markdown-html-base-postman-test.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7634b6ea-e153-48cc-8001-67c21e08e3ac\/nodejs-express-api-markdown-html-base-postman-test.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7634b6ea-e153-48cc-8001-67c21e08e3ac\/nodejs-express-api-markdown-html-base-postman-test.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7634b6ea-e153-48cc-8001-67c21e08e3ac\/nodejs-express-api-markdown-html-base-postman-test.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-base-postman-test.png?w=900\" sizes=\"100vw\" alt=\"Testing with Postman\"><\/a><figcaption>\n      (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7634b6ea-e153-48cc-8001-67c21e08e3ac\/nodejs-express-api-markdown-html-base-postman-test.png\">Large preview<\/a>)<br \/>\n    <\/figcaption><\/figure>\n<p>Install the package using npm:<\/p>\n<pre><code>$ npm install showdown\n<\/code><\/pre>\n<p>After adding the required showdown code to the scaffold, we get the following result:<\/p>\n<div>\n<pre><code>const express        = require(\"express\");\nconst bodyParser = require('body-parser');\nconst showdown   = require('showdown');\n    \nvar app = express();\napp.use(bodyParser.urlencoded({ extended: true }));\napp.use(bodyParser.json());\n \nconverter = new showdown.Converter();\n\napp.get('\/', function(req, res){\n    res.send('Hello World!');\n});\n \napp.post('\/login', function(req, res) {\n    res.send(\"Authenticated\");\n  },\n);\n \napp.post(\"\/convert\", function(req, res, next) {\n    if(typeof req.body.content == 'undefined' || req.body.content == null) {\n        res.json([\"error\", \"No data found\"]);\n    } else {\n        text = req.body.content;\n        html = converter.makeHtml(text);\n        res.json([\"markdown\", html]);\n    }\n});\n \napp.listen(3000, function() {\n console.log(\"Server running on port 3000\");\n});\n\n<\/code><\/pre>\n<\/div>\n<p>The main converter code is in the <code>\/convert<\/code> endpoint as extracted and shown below. This will convert whatever Markdown text you post to an HTML version and return it as a JSON document.<\/p>\n<pre><code>...\n} else {\n        text = req.body.content;\n        html = converter.makeHtml(text);\n        res.json([\"markdown\", html]);\n    }\n<\/code><\/pre>\n<p>The method that does the conversion is <code>converter.makeHtml(text)<\/code>. We can set various options for the Markdown conversion using the <code>setOption<\/code> method with the following format:<\/p>\n<pre><code>converter.setOption('optionKey', 'value');\n<\/code><\/pre>\n<p>So, for example, we can set an option to automatically insert and link a specified URL without any markup.<\/p>\n<pre><code>converter.setOption('simplifiedAutoLink', 'true');\n<\/code><\/pre>\n<p>As in the Postman example, if we pass a simple string (such as <code>Google home http:\/\/www.google.com\/<\/code>) to the application, it will return the following string if <code>simplifiedAutoLink<\/code> is enabled:<\/p>\n<div>\n<pre><code><p>Google home <a href=\"http:\/\/www.google.com\/\">http:\/\/www.google.com\/<\/a><\/p>\n<\/code><\/pre>\n<\/div>\n<p>Without the option, we will have to add markup information to achieve the same results:<\/p>\n<pre><code>Google home <http:\/\/www.google.com\/>\n<\/code><\/pre>\n<p>There are many options to modify how the Markdown is processed. A complete list can be found on the <a href=\"http:\/\/www.passportjs.org\/\">Passport.js<\/a> website.<\/p>\n<p>So now we have a working Markdown-to-HTML converter with a single endpoint. Let us move further and add authentication to have application.<\/p>\n<div><\/div>\n<h3>Stage 4: Adding API Authentication Using Passport<\/h3>\n<p>Exposing your application API to the outside world without proper authentication will encourage users to query your API endpoint with no restrictions. This will invite unscrupulous elements to misuse your API and also will burden your server with unmoderated requests. To mitigate this, we have to add a proper authentication mechanism.<\/p>\n<p>We will be using the Passport package to add authentication to our application. Just like the <code>body-parser<\/code> middleware we encountered earlier, Passport is an authentication middleware for Node.js. The reason we will be using Passport is that it has a variety of authentication mechanisms to work with (username and password, Facebook, Twitter,  and so on) which gives the user the flexibility on choosing a particular mechanism. A Passport middleware can be easily dropped into any Express application without changing much code.<\/p>\n<p>Install the package using npm.<\/p>\n<pre><code>$ npm install passport\n<\/code><\/pre>\n<p>We will also be using the <code>local<\/code> strategy, which will be explained later, for authentication. So install it, too.<\/p>\n<pre><code>$ npm install passport-local\n<\/code><\/pre>\n<p>You will also need to add the JWT(JSON Web Token) encode and decode module for Node.js which is used by Passport:<\/p>\n<pre><code>$ npm install jwt-simple\n<\/code><\/pre>\n<h4>Strategies In Passport<\/h4>\n<p>Passport uses the concept of strategies to authenticate requests. Strategies are various methods that let you authenticate requests and can range from the simple case as verifying username and password credentials, authentication using OAuth (Facebook or Twitter), or using OpenID. Before authenticating requests, the strategy used by an application must be configured.<\/p>\n<p>In our application, we will use a simple username and password authentication scheme, as it is simple to understand and code. Currently, Passport supports more than 300 strategies which can be found here.<\/p>\n<p>Although the design of Passport may seem complicated, the implementation in code is very simple. Here is an example that shows how our <code>\/convert<\/code> endpoint is decorated for authentication. As you will see, adding authentication to a method is simple enough.<\/p>\n<div>\n<pre><code>app.post(\"\/convert\", \n         passport.authenticate('local',{ session: false, failWithError: true }), \n         function(req, res, next) {\n        \/\/ If this function gets called, authentication was successful.\n        \/\/ Also check if no content is sent\n        if(typeof req.body.content == 'undefined' || req.body.content == null) {\n            res.json([\"error\", \"No data found\"]);\n        } else {\n            text = req.body.content;\n            html = converter.makeHtml(text);\n            res.json([\"markdown\", html]);\n        }}, \n        \/\/ Return a 'Unauthorized' message back if authentication failed.\n        function(err, req, res, next) {\n            return res.status(401).send({ success: false, message: err })\n        });\n<\/code><\/pre>\n<\/div>\n<p>Now, along with the Markdown string to be converted, we also have to send a username and password. This will be checked with our application username and password and verified. As we are using a local strategy for authentication, the credentials are stored in the code itself.<\/p>\n<p>Although this may sound like a security nightmare, for demo applications this is good enough. This also makes it easier to understand the authentication process in our example. Incidentally, a common security method used is to store credentials in environment variables. Still, many people may not agree with this method, but I find this relatively secure.<\/p>\n<p>The complete example with authentication is shown below.<\/p>\n<div>\n<pre><code>const express = require(\"express\");\nconst showdown  = require('showdown');\nconst bodyParser = require('body-parser');\nconst passport = require('passport');\nconst jwt = require('jwt-simple');\nconst LocalStrategy = require('passport-local').Strategy;\n \n    \nvar app = express();\napp.use(bodyParser.urlencoded({ extended: true }));\napp.use(bodyParser.json());\n \nconverter = new showdown.Converter();\n \nconst ADMIN = 'admin';\nconst ADMIN_PASSWORD = 'smagazine';\nconst SECRET = 'secret#4456';\n \npassport.use(new LocalStrategy(function(username, password, done) {\n  if (username === ADMIN && password === ADMIN_PASSWORD) {\n    done(null, jwt.encode({ username }, SECRET));\n    return;\n  }\n  done(null, false);\n}));\n \napp.get('\/', function(req, res){\n    res.send('Hello World!');\n});\n \n \napp.post('\/login', passport.authenticate('local',{ session: false }),\n                function(req, res) {\n                \/\/ If this function gets called, authentication was successful.\n                \/\/ Send a 'Authenticated' string back.\n                res.send(\"Authenticated\");\n  });\n  \n \napp.post(\"\/convert\", \n         passport.authenticate('local',{ session: false, failWithError: true }), \n         function(req, res, next) {\n        \/\/ If this function gets called, authentication was successful.\n        \/\/ Also check if no content is sent\n        if(typeof req.body.content == 'undefined' || req.body.content == null) {\n            res.json([\"error\", \"No data found\"]);\n        } else {\n            text = req.body.content;\n            html = converter.makeHtml(text);\n            res.json([\"markdown\", html]);\n        }}, \n        \/\/ Return a 'Unauthorized' message back if authentication failed.\n        function(err, req, res, next) {\n            return res.status(401).send({ success: false, message: err })\n        });\n \n \napp.listen(3000, function() {\n console.log(\"Server running on port 3000\");\n});\n<\/code><\/pre>\n<\/div>\n<p>A Postman session that shows conversion with authentication added is shown below.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/ae32fa60-d46d-4065-8966-b5e9ce0b32b9\/nodejs-express-api-markdown-html-base-postman-auth.png?ssl=1\"><\/p>\n<p>    <img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-base-postman-auth.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/ae32fa60-d46d-4065-8966-b5e9ce0b32b9\/nodejs-express-api-markdown-html-base-postman-auth.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/ae32fa60-d46d-4065-8966-b5e9ce0b32b9\/nodejs-express-api-markdown-html-base-postman-auth.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/ae32fa60-d46d-4065-8966-b5e9ce0b32b9\/nodejs-express-api-markdown-html-base-postman-auth.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/ae32fa60-d46d-4065-8966-b5e9ce0b32b9\/nodejs-express-api-markdown-html-base-postman-auth.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-base-postman-auth.png?w=900\" sizes=\"100vw\" alt=\"Final application testing with Postman\"><\/a><figcaption>\n      Final application testing with Postman (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/ae32fa60-d46d-4065-8966-b5e9ce0b32b9\/nodejs-express-api-markdown-html-base-postman-auth.png\">Large preview<\/a>)<br \/>\n    <\/figcaption><\/figure>\n<p>Here we can see that we have got a proper HTML converted string from a Markdown syntax. Although we have only requested to convert a single line of Markdown, the API can convert a larger amount of text.<\/p>\n<p>This concludes our brief foray into building an API endpoint using Node.js and Express. API building is a complex topic and there are finer nuances that you should be aware of while building one, which sadly we have no time for here but will perhaps cover in future articles.<\/p>\n<h3>Accessing Our API From Another Application<\/h3>\n<p>Now that we have built an API, we can create a small Node.js script that will show you how the API can be accessed. For our example, we will need to install the <code>request<\/code> npm package that provides a simple way to make HTTP requests. (You will Most probably already have this installed.)<\/p>\n<pre><code>$ npm install request --save\n<\/code><\/pre>\n<p>The example code to send a request to our API and get the response is given below. As you can see, the <code>request<\/code> package simplifies the matter considerably. The markdown to be converted is in the <code>textToConvert<\/code> variable.<\/p>\n<p>Before running the following script, make sure that the API application we created earlier is already running. Run the following script in another command window.<\/p>\n<p><strong>Note<\/strong>: <em>We are using the<\/em> <code>(back-tick)<\/code> <em>sign to span multiple JavaScript lines for the<\/em> <code>textToConvert<\/code> <em>variable. This is not a single-quote.<\/em><\/p>\n<pre><code>var Request = require(\"request\");\n \n\/\/ Start of markdown\nvar textToConvert = `Heading\n=======\n## Sub-heading\n \nParagraphs are separated\nby a blank line.\n \nTwo spaces at the end of a line  \nproduces a line break.\n \nText attributes _italic_, \n**bold**, 'monospace'.\nA [link](http:\/\/example.com).\nHorizontal rule:`;\n \n\/\/ End of markdown\n                    \nRequest.post({\n    \"headers\": { \"content-type\": \"application\/json\" },\n    \"url\": \"http:\/\/localhost:3000\/convert\",\n    \"body\": JSON.stringify({\n        \"content\": textToConvert,\n        \"username\": \"admin\",\n        \"password\": \"smagazine\"\n    })\n}, function(error, response, body){\n    \/\/ If we got any connection error, bail out.\n    if(error) {\n        return console.log(error);\n    }\n    \/\/ Else display the converted text\n    console.dir(JSON.parse(body));\n});\n<\/code><\/pre>\n<p>When we make a POST request to our API, we provide the Markdown text to be converted along with the credentials. If we provide the wrong credentials, we will be greeted with an error message.<\/p>\n<pre><code>{\n  success: false,\n  message: {\n    name: 'AuthenticationError',\n    message: 'Unauthorized',\n    status: 401\n  }\n}\n<\/code><\/pre>\n<p>For a correctly authorized request, the above sample Markdown will be converted to the following:<\/p>\n<pre><code>[ 'markdown',\n  `<h1 id=\"heading\">Heading<\/h1>\n  <h2 id=\"subheading\">Sub-heading<\/h2>\n  <p>Paragraphs are separated by a blank line.<\/p>\n  <p>Two spaces at the end of a line<br \/>\n  produces a line break.<\/p>\n  <p>Text attributes <em>italic<\/em>, \n  <strong>bold<\/strong>, 'monospace'.\n  A <a href=\"http:\/\/example.com\">link<\/a>.\n  Horizontal rule:<\/p>` ]\n<\/code><\/pre>\n<p>Although we have hardcoded the Markdown here, the text can come from various other sources \u2014 file, web forms, and so on. The request process remains the same.<\/p>\n<p>Note that as we are sending the request as an <code>application\/json<\/code> content type; we need to encode the body using json, hence the <code>JSON.stringify<\/code> function call. As you can see, it takes a very small example to test or API application.<\/p>\n<h3>Conclusion<\/h3>\n<p>In this article, we embarked on a tutorial with the goal of learning on how to use Node,js and the Express framework to build an API endpoint. Rather than building some dummy application with no purpose, we decided to create an API that converts Markdown syntax to HTML, which anchors or learning in a useful context. Along the way, we added authentication to our API endpoint, and we also saw ways to test our application endpoint using Postman.<\/p>\n<div>\n  <img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/logo-red-17.png?w=900\" alt=\"Smashing Editorial\"><span>(rb, ra, il)<\/span>\n<\/div>\n<\/article>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Building A Node.js Express API To Convert Markdown To HTML Building A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00 Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an&#8230;<a class=\"moretag\" href=\"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/\"> Read the full article&#8230;<\/a><\/p>\n","protected":false},"author":4,"featured_media":63920,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[371],"tags":[],"class_list":["post-63919","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-user-experience"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Building A Node.js Express API To Convert Markdown To HTMLBuilding A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an easy-to-read and\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Guest Contribution\"\/>\n\t<meta name=\"keywords\" content=\"user experience\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Design for Immersive Technologies | User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies\" \/>\n\t\t<meta property=\"og:description\" content=\"Building A Node.js Express API To Convert Markdown To HTMLBuilding A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an easy-to-read and\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-04-23T11:22:27+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-04-23T11:22:27+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Building A Node.js Express API To Convert Markdown To HTMLBuilding A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an easy-to-read and\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#article\",\"name\":\"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies\",\"headline\":\"Building A Node.js Express API To Convert Markdown To HTML\",\"author\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.taterboy.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/04\\\/nodejs-express-api-markdown-html-postman-intro.png?fit=400%2C265&ssl=1\",\"width\":400,\"height\":265},\"datePublished\":\"2019-04-23T04:22:27-07:00\",\"dateModified\":\"2019-04-23T04:22:27-07:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#webpage\"},\"articleSection\":\"User Experience\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.taterboy.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"name\":\"User Experience\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"position\":2,\"name\":\"User Experience\",\"item\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#listItem\",\"name\":\"Building A Node.js Express API To Convert Markdown To HTML\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#listItem\",\"position\":3,\"name\":\"Building A Node.js Express API To Convert Markdown To HTML\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"name\":\"User Experience\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\",\"name\":\"Design for Immersive Technologies\",\"description\":\"User Experience for Games, Virtual Reality (VR) and Augmented\\\/Mixed Reality (AR\\\/MR)\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/\",\"name\":\"Guest Contribution\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d2aad73eb0f48c67b141e9fc978a0e498969791ed623346e361d02d19775b0bb?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Guest Contribution\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#webpage\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/\",\"name\":\"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies\",\"description\":\"Building A Node.js Express API To Convert Markdown To HTMLBuilding A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \\u201cto write using an easy-to-read and\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.taterboy.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/04\\\/nodejs-express-api-markdown-html-postman-intro.png?fit=400%2C265&ssl=1\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#mainImage\",\"width\":400,\"height\":265},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/building-a-node-js-express-api-to-convert-markdown-to-html\\\/#mainImage\"},\"datePublished\":\"2019-04-23T04:22:27-07:00\",\"dateModified\":\"2019-04-23T04:22:27-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/\",\"name\":\"Design for Immersive Technologies\",\"description\":\"User Experience for Games, Virtual Reality (VR) and Augmented\\\/Mixed Reality (AR\\\/MR)\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies","description":"Building A Node.js Express API To Convert Markdown To HTMLBuilding A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an easy-to-read and","canonical_url":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/","robots":"max-image-preview:large","keywords":"user experience","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#article","name":"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies","headline":"Building A Node.js Express API To Convert Markdown To HTML","author":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"publisher":{"@id":"https:\/\/www.taterboy.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-postman-intro.png?fit=400%2C265&ssl=1","width":400,"height":265},"datePublished":"2019-04-23T04:22:27-07:00","dateModified":"2019-04-23T04:22:27-07:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#webpage"},"isPartOf":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#webpage"},"articleSection":"User Experience"},{"@type":"BreadcrumbList","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.taterboy.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","name":"User Experience"}},{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","position":2,"name":"User Experience","item":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#listItem","name":"Building A Node.js Express API To Convert Markdown To HTML"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#listItem","position":3,"name":"Building A Node.js Express API To Convert Markdown To HTML","previousItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","name":"User Experience"}}]},{"@type":"Organization","@id":"https:\/\/www.taterboy.com\/blog\/#organization","name":"Design for Immersive Technologies","description":"User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","url":"https:\/\/www.taterboy.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author","url":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/","name":"Guest Contribution","image":{"@type":"ImageObject","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d2aad73eb0f48c67b141e9fc978a0e498969791ed623346e361d02d19775b0bb?s=96&d=mm&r=g","width":96,"height":96,"caption":"Guest Contribution"}},{"@type":"WebPage","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#webpage","url":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/","name":"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies","description":"Building A Node.js Express API To Convert Markdown To HTMLBuilding A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an easy-to-read and","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.taterboy.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#breadcrumblist"},"author":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"creator":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-postman-intro.png?fit=400%2C265&ssl=1","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#mainImage","width":400,"height":265},"primaryImageOfPage":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/#mainImage"},"datePublished":"2019-04-23T04:22:27-07:00","dateModified":"2019-04-23T04:22:27-07:00"},{"@type":"WebSite","@id":"https:\/\/www.taterboy.com\/blog\/#website","url":"https:\/\/www.taterboy.com\/blog\/","name":"Design for Immersive Technologies","description":"User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.taterboy.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Design for Immersive Technologies | User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","og:type":"article","og:title":"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies","og:description":"Building A Node.js Express API To Convert Markdown To HTMLBuilding A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an easy-to-read and","og:url":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/","article:published_time":"2019-04-23T11:22:27+00:00","article:modified_time":"2019-04-23T11:22:27+00:00","twitter:card":"summary","twitter:title":"Building A Node.js Express API To Convert Markdown To HTML | Design for Immersive Technologies","twitter:description":"Building A Node.js Express API To Convert Markdown To HTMLBuilding A Node.js Express API To Convert Markdown To HTML Sameer Borate 2019-04-23T12:30:16+02:002019-04-23T11:06:50+00:00Markdown is a lightweight text markup language that allows the marked text to be converted to various formats. The original goal of creating Markdown was of enabling people \u201cto write using an easy-to-read and"},"aioseo_meta_data":{"post_id":"63919","title":null,"description":null,"keywords":null,"keyphrases":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_custom_image_width":null,"og_custom_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"created":"2021-02-07 20:49:49","updated":"2026-09-01 09:07:21","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"twitter_image_url":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.taterboy.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/\" title=\"User Experience\">User Experience<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tBuilding A Node.js Express API To Convert Markdown To HTML\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.taterboy.com\/blog"},{"label":"User Experience","link":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/"},{"label":"Building A Node.js Express API To Convert Markdown To HTML","link":"https:\/\/www.taterboy.com\/blog\/2019\/04\/building-a-node-js-express-api-to-convert-markdown-to-html\/"}],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8wzr5-gCX","jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/nodejs-express-api-markdown-html-postman-intro.png?fit=400%2C265&ssl=1","_links":{"self":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts\/63919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/comments?post=63919"}],"version-history":[{"count":0,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts\/63919\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/media\/63920"}],"wp:attachment":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/media?parent=63919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/categories?post=63919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/tags?post=63919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}