<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Node.js &#8211; Best DevOps</title>
	<atom:link href="https://www.bestdevops.com/tag/node-js/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.bestdevops.com</link>
	<description>Lets Learn, Do it &#38; Share! Thats a Best DevOps!!!</description>
	<lastBuildDate>Wed, 14 Oct 2026 08:41:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>Fundamental Tutorials of Node.js</title>
		<link>https://www.bestdevops.com/fundamental-tutorials-of-node-js/</link>
					<comments>https://www.bestdevops.com/fundamental-tutorials-of-node-js/#respond</comments>
		
		<dc:creator><![CDATA[vijaykr123]]></dc:creator>
		<pubDate>Sat, 05 Aug 2023 12:56:06 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Applications]]></category>
		<category><![CDATA[Fundamental]]></category>
		<category><![CDATA[Microservices]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.bestdevops.com/?p=28786</guid>

					<description><![CDATA[What is Node.js? Node.js is an open-source, cross-platform runtime environment that runs on the V8 JavaScript engine. It is designed [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">What is Node.js?</h2>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="512" data-id="28787" src="https://www.bestdevops.com/wp-content/uploads/2023/08/what-is-2-1024x512.png" alt="" class="wp-image-28787" srcset="https://www.bestdevops.com/wp-content/uploads/2023/08/what-is-2-1024x512.png 1024w, https://www.bestdevops.com/wp-content/uploads/2023/08/what-is-2-300x150.png 300w, https://www.bestdevops.com/wp-content/uploads/2023/08/what-is-2-768x384.png 768w, https://www.bestdevops.com/wp-content/uploads/2023/08/what-is-2-1536x768.png 1536w, https://www.bestdevops.com/wp-content/uploads/2023/08/what-is-2.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</figure>



<p class="wp-block-paragraph">Node.js is an open-source, cross-platform runtime environment that runs on the V8 JavaScript engine. It is designed to build scalable network applications. Node.js is event-driven and non-blocking, which makes it efficient at handling concurrent requests. Node.js is a popular choice for building real-time web applications, such as chat applications and streaming applications. It is also used for building server-side applications, such as web APIs and microservices.</p>



<p class="wp-block-paragraph"><strong>Here are some of the key features of Node.js:</strong></p>



<ul class="wp-block-list">
<li>Event-driven: Node.js is event-driven, which means that it only executes code when an event occurs. This makes it efficient at handling concurrent requests.</li>



<li>Non-blocking: Node.js is non-blocking, which means that it does not block the main thread when it is waiting for an event to occur. This makes it efficient at handling concurrent requests.</li>



<li>Cross-platform: Node.js is cross-platform, which means that it can run on Windows, macOS, and Linux.</li>



<li>Asynchronous: Node.js is asynchronous, which means that it can handle multiple requests at the same time.</li>



<li>Scalable: Node.js is scalable, which means that it can be easily scaled to handle more requests.</li>
</ul>



<h2 class="wp-block-heading">What are the top use cases of Node.js?</h2>



<p class="wp-block-paragraph">Node.js is a popular runtime environment that is used for a wide variety of applications. </p>



<p class="wp-block-paragraph"><strong>Here are some of the top use cases of Node.js:</strong></p>



<ul class="wp-block-list">
<li>Real-time web applications: Node.js is a popular choice for building real-time web applications, such as chat applications and streaming applications. This is because Node.js is event-driven and non-blocking, which makes it efficient at handling concurrent requests.</li>



<li>Server-side applications: Node.js is also used for building server-side applications, such as web APIs and microservices. This is because Node.js is asynchronous, which means that it can handle multiple requests at the same time.</li>



<li>IoT applications: Node.js is used for building IoT applications, as it can be used to handle the high volume of data that is generated by IoT devices.</li>



<li>Content management systems: Node.js is used for building content management systems (CMSs), such as WordPress and Drupal. This is because Node.js is scalable and can handle a large number of users.</li>



<li>E-commerce: Node.js is used for building e-commerce websites, as it can handle the high volume of traffic that is generated by e-commerce websites.</li>



<li>Logistics: Node.js is used for building logistics applications, such as tracking shipments and managing inventory levels. This is because Node.js is scalable and can handle a large number of transactions.</li>



<li>Financial: Node.js is used for building financial applications, such as trading platforms and risk management systems. This is because Node.js is scalable and can handle a large number of transactions.</li>



<li>Healthcare: Node.js is used for building healthcare applications, such as electronic medical records (EMRs) and patient portals. This is because Node.js is scalable and can handle a large number of users.</li>
</ul>



<h2 class="wp-block-heading">What are the features of Node.js?</h2>



<p class="wp-block-paragraph">Node.js is a popular runtime environment that is used for a wide variety of applications. </p>



<p class="wp-block-paragraph"><strong>Here are some of the key features of Node.js:</strong></p>



<ul class="wp-block-list">
<li>Event-driven: Node.js is event-driven, which means that it only executes code when an event occurs. This makes it efficient at handling concurrent requests.</li>



<li>Non-blocking: Node.js is non-blocking, which means that it does not block the main thread when it is waiting for an event to occur. This makes it efficient at handling concurrent requests.</li>



<li>Cross-platform: Node.js is cross-platform, which means that it can run on Windows, macOS, and Linux.</li>



<li>Asynchronous: Node.js is asynchronous, which means that it can handle multiple requests at the same time.</li>



<li>Scalable: Node.js is scalable, which means that it can be easily scaled to handle more requests.</li>



<li>JavaScript: Node.js is based on JavaScript, which is a popular programming language that is easy to learn and use.</li>



<li>Ecosystem: Node.js has a large and active ecosystem, which means that there are a wide variety of modules and libraries available for Node.js.</li>
</ul>



<h2 class="wp-block-heading">What is the workflow of Node.js?</h2>



<p class="wp-block-paragraph"><strong>Here are some additional details about each step:</strong></p>



<ul class="wp-block-list">
<li>Creating a project: The first step is to create a project. This can be done by creating a new directory and initializing it with the npm init command. The npm init command will prompt you to enter a few basic details about your project, such as the name of the project and the version number.</li>



<li>Installing dependencies: The next step is to install the dependencies for your project. This can be done by running the npm install command. The npm install command will install the dependencies that are listed in the package.json file.</li>



<li>Writing code: The next step is to write the code for your project. This code will be executed by the Node.js runtime environment. The Node.js runtime environment is a JavaScript engine that is designed to execute JavaScript code on the server.</li>



<li>Running the code: The code can be run by executing the node command. The node command will execute the JavaScript code that is contained in the file.</li>



<li>Testing the code: The code can be tested by using a variety of testing frameworks, such as Mocha and Chai. Testing frameworks are used to automate the testing of code.</li>



<li>Deploying the code: The code can be deployed to a production environment by using a variety of deployment methods, such as Heroku and Amazon Web Services (AWS). Deployment is the process of making the code available to users.</li>
</ul>



<h2 class="wp-block-heading">How Node.js Works &amp; Architecture?</h2>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img decoding="async" data-id="28788" src="https://www.bestdevops.com/wp-content/uploads/2023/08/Node.js-Architecture-1024x575-1.jpg" alt="" class="wp-image-28788" /></figure>
</figure>



<p class="wp-block-paragraph">Node.js is an open-source, cross-platform runtime environment that runs on the V8 JavaScript engine. It is designed to build scalable network applications. Node.js is event-driven and non-blocking, which makes it efficient at handling concurrent requests. Node.js works by using a single-threaded event loop to handle all of the requests that are made to the server. The event loop is responsible for calling the appropriate callbacks when events occur. Events can be triggered by a variety of things, such as HTTP requests, file system changes, and timer events.</p>



<p class="wp-block-paragraph">The Node.js architecture is divided into two main parts: the event loop and the modules. The event loop is responsible for handling all of the requests that are made to the server. The modules are responsible for providing functionality to the Node.js runtime environment. The event loop is a critical part of the Node.js architecture. It is responsible for making sure that all of the requests that are made to the server are handled in a timely manner. The event loop is also responsible for making sure that the Node.js runtime environment is not blocked by anyone&#8217;s request.</p>



<p class="wp-block-paragraph">The modules are a key part of the Node.js architecture. They provide functionality to the Node.js runtime environment, such as HTTP request handling, file system access, and database access. The modules are written in JavaScript and can be installed using the npm package manager.</p>



<p class="wp-block-paragraph">Node.js is a powerful and versatile platform that is used for a wide variety of applications. It is a good choice for applications that require scalability, efficiency, and versatility.</p>



<p class="wp-block-paragraph"><strong>Here are some of the key features of the Node.js architecture:</strong></p>



<ul class="wp-block-list">
<li>Single-threaded event loop: The Node.js event loop is a single-threaded event loop. This means that only one request can be processed at a time. However, the event loop is non-blocking, which means that it can handle multiple requests in parallel.</li>



<li>Modules: Node.js modules are a key part of the architecture. They provide functionality to the Node.js runtime environment, such as HTTP request handling, file system access, and database access.</li>



<li>JavaScript: Node.js is based on JavaScript. This makes it easy to learn and use, and there is a large and active community of JavaScript developers.</li>
</ul>



<h2 class="wp-block-heading">How to Install and Configure Node.js?</h2>



<p class="wp-block-paragraph"><strong>Here are the steps on how to install and configure Node.js:</strong></p>



<ul class="wp-block-list">
<li>Download the Node.js installer. You can download the Node.js installer from the official Node.js website.</li>



<li>Install the Node.js installer. The installation process will vary depending on your operating system.</li>



<li>Configure the Node.js environment variables. You will need to configure the Node.js environment variables so that you can run Node.js applications from the command line.</li>



<li>Verify the installation. You can verify the installation by running the node -v command.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/fundamental-tutorials-of-node-js/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>5 reasons why Node.js is a perfect Enterprise App Development platform</title>
		<link>https://www.bestdevops.com/nodejs-enterprise-app-development-platform/</link>
					<comments>https://www.bestdevops.com/nodejs-enterprise-app-development-platform/#respond</comments>
		
		<dc:creator><![CDATA[James Grill]]></dc:creator>
		<pubDate>Wed, 27 Jan 2021 11:28:23 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Node.js]]></category>
		<guid isPermaLink="false">http://www.bestdevops.com/?p=15461</guid>

					<description><![CDATA[With the cutthroat competition in today&#8217;s world of business, the bar for the performance of enterprise applications has risen continuously [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span style="font-weight: 400">With the cutthroat competition in today&#8217;s world of business, the bar for the performance of enterprise applications has risen continuously for the past couple of years. Enterprise applications have to maintain various aspects of their operations such as data confidentiality and upholding business performance. </span></p>
<p><span style="font-weight: 400">Node.js provides a robust server environment for companies to develop web apps swiftly and securely. In a world where taking quick decisions and actions is the key to achieving success in business, Node.js proves to be an excellent platform for developing enterprise applications</span></p>
<p><b>Key points of Node.js as a Platform</b></p>
<p><span style="font-weight: 400">Node.js is an open-source platform which can essentially run JavaScript codes outside a web browser. With developers writing command-line tools which then run server-side scripts, Node.js can efficiently produce dynamic web page content even before the page reaches the user’s web browser.</span></p>
<p><span style="font-weight: 400">Using asynchronous programming and implementing push technology over web sockets in the real-time web applications, Node.js has been able to transform the process of web &amp; request-response. Now, the server and clients can freely communicate and exchange data and enjoy an unrestrictive two-way connection. Developers can share the same piece of coding with the client and server side through Node.js’ asynchronous programming.</span></p>
<p><span style="font-weight: 400">According to a survey held back in 2019, Node.js was deemed as the most popular platform among developers in the category of “Frameworks, Libraries, and Tools”. According to a user survey held for Node.js users, more than 40% of Node.js programmers use this platform to develop enterprise apps. A majority of developers of this percentage were surprisingly working for Fortune 500 companies. With numerous companies claiming that Node.js increases developer productivity, the number of downloads of this platform is steadily increasing by a whopping 40% every year.</span></p>
<p><b>Benefits of Node.js</b></p>
<p><span style="font-weight: 400">Before delving into the detailed reasons as to why enterprises should hire a </span><b>Node.Js/ </b><span style="font-weight: 400"><a href="https://www.cumulations.com/services/reactjs-development-company/">React.Js Development Company</a> for their next app project, let us look at some quick benefits of using Node.js as a platform:</span></p>
<ul>
<li style="font-weight: 400"><span style="font-weight: 400">The Node.js platform facilitates quick development of applications.</span></li>
<li style="font-weight: 400"><span style="font-weight: 400">It is fast in executing codes in other languages.</span></li>
<li style="font-weight: 400"><span style="font-weight: 400">It is highly efficient when it comes to bridging the gap between frontend development and backend development. </span></li>
<li style="font-weight: 400"><span style="font-weight: 400">It provides LTS or long-term support. </span></li>
<li style="font-weight: 400"><span style="font-weight: 400">It allows developers to reuse application codes and build cross-platform desktop apps.</span></li>
<li style="font-weight: 400"><span style="font-weight: 400">It is ideal for microservices in companies which are essentially breaking up the application into smaller parts and then scaling and deploying them individually.</span></li>
</ul>
<p><b>5 main reasons why enterprises should consider Node.js as their app development platform</b></p>
<p><span style="font-weight: 400">Node.js provides you with several benefits to prove its case as one of the best platforms for enterprise app development. Here are five top reasons as to why you should consider Node.js for developing speedy and efficient enterprise applications:</span></p>
<ul>
<li><b>Node.js allows cross-platform app development.</b></li>
</ul>
<p><span style="font-size: 0.95em">One of the main reasons why companies time and again comes back to Node.js as their preferred platform of app development is due to its ability to build cross-platform desktop apps. Node.js allows users to use platforms such as Electron and NW.js, and make desktop apps that work with any kind of operating system.</span><br />
<b></b></p>
<p><span style="font-weight: 400">Developers, who might not be skilled in languages such as Objective-C, Swift, Java that are used to build native apps, can still create web and desktop apps with the help of Node.js. These developers can reuse their codes from their web applications and implement it on desktop applications which have compatibility with Windows, Linux, and macOS.</span></p>
<p><span style="font-weight: 400">Node.js dismisses the need for a Mac machine to build macOS applications or Windows machine for building Window apps with its developer tools. Every significant developer tool which is related to Node is cross-platform. Moreover, Node.js allows its users to get exclusive access to Google Chrome Developer Tools which ultimately gives them all the necessary equipment to debug efficiently and provide better desktop versions of the application. </span></p>
<ul>
<li><b>It does not have a steep learning curve.</b></li>
</ul>
<p><span style="font-size: 0.95em">Node.js is very easy to learn and master. Without a steep learning curve, developers can easily understand the workings of this platform. Furthermore, developers who were using a different platform earlier can easily shift to this platform without particularly extensive knowledge about it. The platform allows developers to use JavaScript to build web applications which is convenient and easy to learn.</span><br />
<b></b></p>
<p><span style="font-weight: 400">With Node.js as the base, developers can easily build scalable applications that work on both Windows and Unix. Enterprises usually turn towards Node.js as their app development platform due to the ease and convenience of finding developers, or app development companies that provide high-quality professionals, adept in developing through Node.js.</span></p>
<ul>
<li><b>Node.js provides high-quality performance.</b></li>
</ul>
<p><span style="font-size: 0.95em">The platform is essentially based on V8 runtime of Google Chrome which is written in C++ and which overall, acts as a major advantage for the programmers. They can build applications which are compatible with several operating systems at a time without necessarily re-coding for every new OS. Moreover, both the Node.js platform as well as Google’s V* receive regular updates for utmost optimization of their performances. </span><br />
<b></b></p>
<p><span style="font-weight: 400">Node.js can easily manage multiple server connections simultaneously due to its single-thread architecture. Thus, the platform will not create any additional threads for each new request that it gets. This not only makes the app operate faster but also prevents excessive usage of RAM.</span></p>
<ul>
<li><b>The platform is known to provide LTS or Long-Term Support.</b></li>
</ul>
<p><span style="font-size: 0.95em">The Node.js platform provides its users with a long-term support feature which, according to a survey held in 2018, more than 60% of developers deems to be important. With the IT world’s fickle nature and dynamic changes, it is not a surprise to see technologies falling apart before they could even offer LTS. Node.js is equipped to counter this trend and provides its users with consistency with its support and updates.</span><br />
<b></b></p>
<ul>
<li><b>Node.js provides an NPM or Node Package Manager.</b></li>
</ul>
<p><span style="font-size: 0.95em">For enterprises who are dwelling over the privacy and security concerns over their app development platform, the Node.js platform provides an enterprise version of its Npm. Npm offers a range of benefits to the users. From installing and using small modules to identifying and replacing unsafe code, the enterprise version of npm can improve the developmental process of enterprise apps to great extent. This feature by Node.js was widely acclaimed by developers worldwide and is still growing in terms of its operations and abilities.</span><br />
<b></b></p>
<p><span style="font-weight: 400">While these were only five reasons, Node.js provides several reasons for companies to consider developing their apps on this platform. Node.js facilitates seamless development of apps without adding any kind of complexities. With its fast-paced V8 engines and single code base, Node.js consists of all the prerequisites necessary for developing and deploying comprehensive enterprise apps.</span></p>
<p>&nbsp;</p>
<p><b>Author Bio:</b></p>
<p><span style="font-weight: 400">James Grills </span><span style="font-weight: 400">is a marketing advisor &#8211; currently associated with Cumulations Technologies, a </span><a href="https://www.cumulations.com/services/flutter-app-development/"><span style="font-weight: 400">Flutter App Development company</span></a><span style="font-weight: 400">. He is a technical writer with a passion for writing on emerging technologies in the areas of mobile application development and IoT technology.</span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/nodejs-enterprise-app-development-platform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How Cloud Computing Models Simplify Mobile App Development</title>
		<link>https://www.bestdevops.com/cloud-computing-model-making-mobile-app-development-less-complicated/</link>
					<comments>https://www.bestdevops.com/cloud-computing-model-making-mobile-app-development-less-complicated/#respond</comments>
		
		<dc:creator><![CDATA[anil]]></dc:creator>
		<pubDate>Tue, 21 Apr 2020 05:54:50 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[Cloud computing]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[IT-market]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software technology]]></category>
		<guid isPermaLink="false">http://www.bestdevops.com/?p=11941</guid>

					<description><![CDATA[On-Premise infrastructure gave way to SaaS, which gave way to PaaS. Learn how IaaS, SaaS, and PaaS differ, and why Platform-as-a-Service has become the preferred cloud model for mobile app development teams.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><em>This article is based on a post originally sourced from southfloridareporter.com.</em></p>



<h2 class="wp-block-heading">The Evolution from On-Premise to Cloud</h2>



<p class="wp-block-paragraph">Mobile app development teams have not always had the luxury of elastic, remotely hosted infrastructure. Before cloud platforms matured, the standard approach was On-Premise: every server, storage array, and development tool lived in the same physical building as the engineering team. That model created predictable headaches — limited physical space, large upfront capital expenditure, complex licensing, and slow provisioning cycles that blocked development velocity.</p>



<p class="wp-block-paragraph">The emergence of cloud computing introduced three foundational service models that progressively transferred infrastructure responsibility away from in-house IT teams:</p>



<ul class="wp-block-list">
<li><strong>Infrastructure-as-a-Service (IaaS)</strong> — virtualised compute, networking, and storage delivered on demand.</li>
<li><strong>Software-as-a-Service (SaaS)</strong> — fully managed software applications delivered over the internet.</li>
<li><strong>Platform-as-a-Service (PaaS)</strong> — a managed environment that provides the runtime, middleware, development tools, and services a team needs to build, test, and deploy applications without managing the underlying infrastructure.</li>
</ul>



<p class="wp-block-paragraph">Each model sits at a different level of the stack, and choosing the right one depends on how much control versus convenience a team needs.</p>



<h2 class="wp-block-heading">SaaS vs. PaaS: What Changed and Why</h2>



<p class="wp-block-paragraph">SaaS was the first widely adopted cloud model for many organisations. It replaced on-premise software licences with subscription-based, browser-accessible applications — think email, CRM, or collaboration tools. For end users this was transformative, but for development teams building custom mobile applications, SaaS alone was not enough. Developers needed a managed environment where they could write, test, and ship code, not just consume finished products.</p>



<p class="wp-block-paragraph">PaaS filled that gap. Rather than purchasing and maintaining servers, configuring runtime environments, or negotiating separate tool licences, a development team can provision a PaaS environment and immediately start writing application logic. Key practical advantages PaaS offers over SaaS for mobile development teams include:</p>



<ul class="wp-block-list">
<li><strong>Richer feature set</strong> — databases, messaging queues, authentication services, and CI/CD pipelines are available as managed add-ons.</li>
<li><strong>Reduced operational budget</strong> — infrastructure management overhead shifts to the cloud provider.</li>
<li><strong>Faster time to launch</strong> — pre-configured environments eliminate lengthy setup phases.</li>
<li><strong>Elastic scaling</strong> — storage, compute, and bandwidth can be adjusted as the application grows or shrinks.</li>
<li><strong>Location independence</strong> — resources are delivered from data centres irrespective of where the development team sits.</li>
</ul>



<h2 class="wp-block-heading">Mobile PaaS: Handling the Heavy Lifting</h2>



<p class="wp-block-paragraph">Mobile app development carries unique complexity compared with traditional web development. A single application may need to run correctly across multiple operating systems (iOS, Android, and various vendor-specific environments), screen sizes, hardware capabilities, and network conditions. That cross-platform burden can consume engineering attention that should be focused on product features rather than environment configuration.</p>



<p class="wp-block-paragraph">Mobile PaaS (sometimes abbreviated mPaaS) addresses this by providing a managed backend and toolchain specifically optimised for mobile development workflows. The platform abstracts away infrastructure concerns so developers can focus on application logic and user experience.</p>



<h3 class="wp-block-heading">Multi-Language and Framework Support</h3>



<p class="wp-block-paragraph">A well-configured PaaS environment supports a range of programming languages and frameworks out of the box — commonly including Python, Node.js, Java, and C# — along with popular frontend frameworks and UI toolkits. Development teams can select the language stack that matches their skills and project requirements, then provision the required runtime without manually installing or patching dependencies on physical machines.</p>



<h3 class="wp-block-heading">Integrated Development Environment (IDE) Capabilities</h3>



<p class="wp-block-paragraph">Many PaaS offerings include or integrate tightly with cloud-hosted IDEs. This means the full development loop — writing code, debugging, running automated tests, and deploying to a staging or production environment — can happen within a single, consistent toolchain. The alternative — context-switching between local IDEs, separate test environments, and manual deployment scripts — introduces friction and increases the chance of environment-specific bugs surfacing only after release.</p>



<p class="wp-block-paragraph">A cloud IDE also makes it straightforward to spin up sandbox environments for experimenting with new features or architectural approaches without disrupting the main development branch.</p>



<h2 class="wp-block-heading">Security in a PaaS Model</h2>



<p class="wp-block-paragraph">Security for mobile applications is not limited to the application layer itself. Data in transit between the app and the backend, data at rest on servers, and access control across a distributed team all need to be managed. PaaS platforms typically provide several security capabilities as managed services:</p>



<ul class="wp-block-list">
<li><strong>Centralised authentication</strong> — identity providers and OAuth flows managed by the platform, reducing the risk of custom-built authentication mistakes.</li>
<li><strong>Role-based access control (RBAC)</strong> — fine-grained permission assignment so developers, testers, and automated pipelines only access what they need.</li>
<li><strong>Single sign-on (SSO)</strong> — consistent identity management across services.</li>
<li><strong>Data encryption</strong> — encryption at rest and in transit handled by the platform, with key management often delegated to managed key stores.</li>
<li><strong>Backup and recovery</strong> — automated snapshots and point-in-time recovery reduce data loss risk without requiring a dedicated database administrator.</li>
</ul>



<p class="wp-block-paragraph">These capabilities allow smaller teams to maintain a security posture that would otherwise require dedicated security engineering resources.</p>



<h2 class="wp-block-heading">Pay-As-You-Go (PAYG) Pricing Model</h2>



<p class="wp-block-paragraph">Traditional on-premise infrastructure required organisations to provision for peak load, which meant paying for capacity that sat idle during normal operation. PaaS platforms overwhelmingly use a consumption-based or pay-as-you-go pricing model, which aligns costs with actual usage.</p>



<p class="wp-block-paragraph">For mobile app development specifically, PAYG pricing means:</p>



<ul class="wp-block-list">
<li>Server capacity can be scaled up ahead of a feature release or marketing campaign, then scaled back down afterwards.</li>
<li>Storage can grow incrementally as the user base grows rather than being purchased in large fixed blocks.</li>
<li>Teams are not locked into long-term hardware depreciation cycles.</li>
<li>Licensing costs for middleware, databases, and tools are folded into a single cloud bill rather than managed as separate vendor contracts.</li>
</ul>



<p class="wp-block-paragraph">This model removes a significant administrative burden from development teams and gives finance teams more predictable, usage-correlated expenditure.</p>



<h2 class="wp-block-heading">Choosing the Right Cloud Model for Your Mobile Project</h2>



<p class="wp-block-paragraph">IaaS, SaaS, and PaaS are not mutually exclusive. Many production mobile applications use PaaS for the application runtime and development toolchain, IaaS for specialised compute workloads (such as video transcoding or machine learning inference), and SaaS tools for project management, monitoring, or customer support. The key is understanding what each model manages on your behalf versus what your team retains responsibility for:</p>



<figure class="wp-block-table"><table><thead><tr><th>Responsibility</th><th>On-Premise</th><th>IaaS</th><th>PaaS</th><th>SaaS</th></tr></thead><tbody><tr><td>Physical hardware</td><td>Team</td><td>Provider</td><td>Provider</td><td>Provider</td></tr><tr><td>Virtualisation</td><td>Team</td><td>Provider</td><td>Provider</td><td>Provider</td></tr><tr><td>OS &amp; runtime</td><td>Team</td><td>Team</td><td>Provider</td><td>Provider</td></tr><tr><td>Middleware &amp; frameworks</td><td>Team</td><td>Team</td><td>Provider</td><td>Provider</td></tr><tr><td>Application code</td><td>Team</td><td>Team</td><td>Team</td><td>Provider</td></tr><tr><td>Data</td><td>Team</td><td>Team</td><td>Team</td><td>Shared</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">For most mobile app development teams, PaaS strikes the best balance: it eliminates low-value infrastructure management while preserving full control over application code and data design. Teams that need more control over OS-level configuration may lean toward IaaS; teams that only need pre-built tools without custom development can rely on SaaS.</p>



<h2 class="wp-block-heading">Key Takeaways</h2>



<ul class="wp-block-list">
<li>On-Premise infrastructure created space, cost, and licensing constraints that slowed mobile development teams.</li>
<li>IaaS, SaaS, and PaaS each abstract a different layer of the stack, trading control for managed convenience.</li>
<li>PaaS is particularly well-suited to mobile app development because it provides language runtimes, IDEs, security services, and elastic scaling without requiring teams to manage underlying infrastructure.</li>
<li>Pay-as-you-go pricing aligns cloud spend with actual usage, removing the over-provisioning problem inherent in on-premise models.</li>
<li>Security capabilities — authentication, RBAC, encryption, backup — are available as managed platform services on most PaaS offerings.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/cloud-computing-model-making-mobile-app-development-less-complicated/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Full-text search with Node.js and ElasticSearch on Docker</title>
		<link>https://www.bestdevops.com/full-text-search-with-node-js-and-elasticsearch-on-docker/</link>
					<comments>https://www.bestdevops.com/full-text-search-with-node-js-and-elasticsearch-on-docker/#respond</comments>
		
		<dc:creator><![CDATA[anil]]></dc:creator>
		<pubDate>Mon, 16 Sep 2019 05:48:32 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Eleastic Search]]></category>
		<category><![CDATA[codebase]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Elasticsearch]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[server]]></category>
		<guid isPermaLink="false">http://www.bestdevops.com/?p=7747</guid>

					<description><![CDATA[Source:-blog.logrocket Full-text search can be both scary and exciting. Some popular databases such as&#160;MySql&#160;and&#160;Postgres&#160;are an amazing solution for storing data… [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Source:-blog.logrocket<br></p>



<p class="wp-block-paragraph">Full-text search can be both scary and exciting. Some popular databases such as&nbsp;<strong>MySql</strong>&nbsp;and&nbsp;<strong>Postgres</strong>&nbsp;are an amazing solution for storing data… but when it comes to full-text search performances, there’s no competition with&nbsp;<strong>ElasticSearch</strong>.</p>



<p class="wp-block-paragraph">For those who don’t know, ElasticSearch is a search engine server built on top of <strong>Lucene</strong> with an amazing distributed-architecture support. According to db-engines.com, it is currently the most used search engine out there.</p>



<p class="wp-block-paragraph">In this post, we are going to build a simple REST application called The Quotes Database which will allow us to store and search as many quotes as we want.</p>



<p class="wp-block-paragraph">I’ve prepared a JSON file containing 5000+ quotes with their authors, we’ll be using it as our starting data for populating ElasticSearch.</p>



<h2 class="wp-block-heading">Setting up Docker</h2>



<p class="wp-block-paragraph">First of all, we don’t want to install ElasticSearch on our machine. We’ll be using Docker for orchestrating both the Node.js server and the ES instance on a container, which will allow us to deploy a production-ready application with all the dependencies that it needs.</p>



<p class="wp-block-paragraph">Let’s create a&nbsp;<code>Dockerfile</code>&nbsp;inside our project root folder:</p>



<pre class="wp-block-preformatted">FROM node:10.15.3-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install
RUN npm install -g pm2

COPY . ./

EXPOSE 3000
EXPOSE 9200

CMD npm run start</pre>



<p class="wp-block-paragraph">As you can see, we’re telling Docker that we’ll run a&nbsp;<strong>Node.js 10.15.3-alpine</strong>&nbsp;runtime. We’ll also create a new working directory under&nbsp;<code>/usr/src/app</code>, where we’ll copy both the&nbsp;<code>package.json</code>&nbsp;and the&nbsp;<code>package-lock.json</code>&nbsp;files. That way, Docker will be able to run&nbsp;<code>npm install</code>&nbsp;inside our&nbsp;<code>WORKDIR</code>, installing our needed dependencies.</p>



<p class="wp-block-paragraph">We’ll also install <strong>PM2</strong> by running <code>RUN npm install -g pm2</code>. The Node.js runtime is single-threaded, so if a process crashes, the entire app needs to be restarted… <strong>PM2</strong> checks the Node.js process status and restarts it when the app goes down for any reason.</p>



<p class="wp-block-paragraph">After installing PM2, we’ll copy our codebase inside our&nbsp;<code>WORKDIR</code>&nbsp;(<code>COPY&nbsp;.&nbsp;./</code>), and we tell Docker to expose two ports,&nbsp;<code>3000</code>, which will expose our RESTful service, and&nbsp;<code>9200</code>, which exposes the ElasticSearch service (<code>EXPOSE&nbsp;3000</code>&nbsp;and&nbsp;<code>EXPOSE&nbsp;9200</code>).</p>



<p class="wp-block-paragraph">Last but not least, we tell Docker which command will start the Node.js app with&nbsp;<code>npm run start</code>.</p>



<h2 class="wp-block-heading">Setting up docker-compose</h2>



<p class="wp-block-paragraph">Now you may be saying, ‘<em>Great, I get it! But how do I handle the ElasticSearch instance inside Docker? I can’t find it in my Dockerfile!’</em>… you’re right! That’s where&nbsp;<strong>docker-compose</strong>&nbsp;becomes useful. It allows us to orchestrate multiple Docker containers and to create a connection between them. So, let’s write down the&nbsp;<code>docker-compose.yml</code>&nbsp;file, which will be stored inside our project root directory:</p>



<pre class="wp-block-preformatted">version: '3.6'
services:
  api:
    image: node:10.15.3-alpine
    container_name: tqd-node
    build: .
    ports:
      - 3000:3000
    environment:
     - NODE_ENV=local
     - ES_HOST=elasticsearch
     - NODE_PORT=3000
     - ELASTIC_URL=http://elasticsearch:9200
    volumes:
      - .:/usr/src/app/quotes
    command: npm run start
    links:
        - elasticsearch
    depends_on:
        - elasticsearch
    networks: 
      - esnet
  elasticsearch:
    container_name: tqd-elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1
    volumes:
      - esdata:/usr/share/elasticsearch/data
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.type=single-node
    logging:
      driver: none
    ports:
      - 9300:9300
      - 9200:9200
    networks: 
      - esnet
volumes:
  esdata:
networks:
  esnet:</pre>



<p class="wp-block-paragraph">This is a bit more complex than our Dockerfile, but let’s analyze it:</p>



<ul class="wp-block-list"><li>We declare which version of&nbsp;<code>docker-compose.yml</code>&nbsp;file we’re using (<code>3.6</code>)</li><li>We declare our services:<ul><li><code>api</code>, which is our Node.js app. Just like in our Dockerfile, it requires the&nbsp;<code>node:10.15.3-alpine</code>&nbsp;image. We also assign a name to this container&nbsp;<code>tqd-node</code>, and here we call the previously created Dockerfile using the&nbsp;<code>build&nbsp;.</code>&nbsp;command.</li><li>We need to expose the&nbsp;<code>3000</code>&nbsp;port so we write these statements as follows&nbsp;<code>3000:3000</code>. It means that we’re mapping&nbsp;<strong>from</strong>&nbsp;the port&nbsp;<code>3000</code>&nbsp;(inside our container)&nbsp;<strong>to</strong>&nbsp;the port&nbsp;<code>3000</code>&nbsp;(accessible from our machine). Then we’ll set some environment variables. The value&nbsp;<code>elasticsearch</code>&nbsp;is a variable which refers to the&nbsp;<code>elasticsearch</code>&nbsp;service inside our&nbsp;<code>docker-compose.yml</code>&nbsp;file.</li><li>We also want to mount a volume&nbsp;<code>/usr/src/app/quotes</code>. That way, once we restart our container we’ll maintain our data without losing it.</li><li>Once more, we tell Docker which command we need to execute once the container starts up, then we set a link to the&nbsp;<code>elasticsearch</code>&nbsp;service. We also tell Docker to start the&nbsp;<code>api</code>&nbsp;service after the&nbsp;<code>elasticsearch</code>&nbsp;service has booted (using the&nbsp;<code>depends_on</code>&nbsp;directive).</li><li>Last but not least, we tell Docker to connect the&nbsp;<code>api</code>&nbsp;service under the&nbsp;<code>esnet</code>&nbsp;network. That’s because every container has its own network. That way, we say that&nbsp;<code>api</code>&nbsp;and&nbsp;<code>elasticsearch</code>&nbsp;services shares the same network so they will be able to call each other with the same ports.</li><li><code>elasticsearch</code>, which is (as you may have guessed) our ES service. It’s configuration is pretty similar to the&nbsp;<code>api</code>&nbsp;service. We’ll just cut off its verbose logs setting the&nbsp;<code>logging</code>&nbsp;directive to&nbsp;<code>driver:&nbsp;none</code>&nbsp;.</li></ul></li><li>We also declare our volumes, where we store the ES data.</li><li>And we declare our network,&nbsp;<code>esnet</code>.</li></ul>



<h2 class="wp-block-heading">Bootstrapping the Node.js app</h2>



<p class="wp-block-paragraph">Now we need to create our Node.js application, so let’s get started setting up our&nbsp;<code>package.json</code>&nbsp;file:</p>



<pre class="wp-block-preformatted">npm init -y</pre>



<p class="wp-block-paragraph">Now we need to install some dependencies:</p>



<pre class="wp-block-preformatted">npm i -s @elastic/elasticsearch body-parser cors dotenv express</pre>



<p class="wp-block-paragraph">Great! Our&nbsp;<code>package.json</code>&nbsp;file should look like this:</p>



<pre class="wp-block-preformatted">{
  "name": "nodejselastic",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@elastic/elasticsearch": "^7.3.0",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv": "^8.0.0",
    "express": "^4.17.1"
  }
}</pre>



<p class="wp-block-paragraph">Let’s implement our ElasticSearch connector in Node.js. First, we need to create a new&nbsp;<code>/src/elastic.js</code>&nbsp;file:</p>



<pre class="wp-block-preformatted">const { Client } = require("@elastic/elasticsearch");
                   require("dotenv").config();

const elasticUrl = process.env.ELASTIC_URL || "http://localhost:9200";
const esclient   = new Client({ node: elasticUrl });
const index      = "quotes";
const type       = "quotes";</pre>



<p class="wp-block-paragraph">As you can see, here we set some constants that will be incredibly useful. First of all, we create a new connection to ElasticSearch using its official Node.js SDK, then we define an index (<code>"quotes"</code>) and an index type(<code>"quotes"</code> again, we’ll see later what they mean).</p>



<p class="wp-block-paragraph">Now we need to create an index on ElasticSearch. You can think of “indexes” as a SQL “database” equivalent. ElasticSearch is a NoSQL database, which means that it has no tables — it just stores JSON documents. An index is a logical namespace which maps to one or more primary shards and can have zero or more replica shards. You can read more about ElasticSearch indexes here.</p>



<p class="wp-block-paragraph">Let’s now define a function that will create our index:</p>



<pre class="wp-block-preformatted">async function createIndex(index) { 
  try {
    await esclient.indices.create({ index });
    console.log(`Created index ${index}`);
  } catch (err) {
    console.error(`An error occurred while creating the index ${index}:`);
    console.error(err);
  }
}</pre>



<p class="wp-block-paragraph">Now we need another function that creates the mapping for our quotes. The mapping defines the schema and types of our document:</p>



<pre class="wp-block-preformatted">async function setQuotesMapping () {
  try {
    const schema = {
      quote: {
        type: "text" 
      },
      author: {
        type: "text"
      }
    };

    await esclient.indices.putMapping({ 
      index, 
      type,
      include_type_name: true,
      body: { 
        properties: schema 
      } 
    })

    console.log("Quotes mapping created successfully");
  } catch (err) {
    console.error("An error occurred while setting the quotes mapping:");
    console.error(err);
  }
}</pre>



<p class="wp-block-paragraph">As you can see, we’re defining the schema for our documents, and we’re inserting it inside our&nbsp;<code>index</code>.</p>



<p class="wp-block-paragraph">Now let’s consider that ElasticSearch is a huge system and can take some seconds to boot up. We can’t connect to ES until it is ready, so we need a function that checks when the ES server is ready:</p>



<pre class="wp-block-preformatted">function checkConnection() {
  return new Promise(async (resolve) =&gt; {
    console.log("Checking connection to ElasticSearch...");
    let isConnected = false;
    while (!isConnected) {
      try {
        await esclient.cluster.health({});
        console.log("Successfully connected to ElasticSearch");
        isConnected = true;
      // eslint-disable-next-line no-empty
      } catch (_) {
      }
    }
    resolve(true);
  });
}</pre>



<p class="wp-block-paragraph">As you can see, we’re returning a promise. That’s because by using&nbsp;<code>async/await</code>&nbsp;we’re able to stop the entire Node.js process until this promise resolves, and it won’t do it until it connects to ES. That way, we force our Node.js to wait for ES before booting up.</p>



<p class="wp-block-paragraph">We’re done with ElasticSearch! Now let’s export our functions:</p>



<pre class="wp-block-preformatted">module.exports = {
  esclient,
  setQuotesMapping,
  checkConnection,
  createIndex,
  index,
  type
};</pre>



<p class="wp-block-paragraph">Great! Let’s see the entire&nbsp;<code>elastic.js</code>&nbsp;file:</p>



<pre class="wp-block-preformatted">const { Client } = require("@elastic/elasticsearch");
                   require("dotenv").config();
const elasticUrl = process.env.ELASTIC_URL || "http://localhost:9200";
const esclient   = new Client({ node: elasticUrl });
const index      = "quotes";
const type       = "quotes";
/**
 * @function createIndex
 * @returns {void}
 * @description Creates an index in ElasticSearch.
 */
async function createIndex(index) {
  try {
    await esclient.indices.create({ index });
    console.log(`Created index ${index}`);
  } catch (err) {
    console.error(`An error occurred while creating the index ${index}:`);
    console.error(err);
  }
}
/**
 * @function setQuotesMapping,
 * @returns {void}
 * @description Sets the quotes mapping to the database.
 */
async function setQuotesMapping () {
  try {
    const schema = {
      quote: {
        type: "text" 
      },
      author: {
        type: "text"
      }
    };
  
    await esclient.indices.putMapping({ 
      index, 
      type,
      include_type_name: true,
      body: { 
        properties: schema 
      } 
    })
    
    console.log("Quotes mapping created successfully");
  
  } catch (err) {
    console.error("An error occurred while setting the quotes mapping:");
    console.error(err);
  }
}
/**
 * @function checkConnection
 * @returns {Promise&lt;Boolean&gt;}
 * @description Checks if the client is connected to ElasticSearch
 */
function checkConnection() {
  return new Promise(async (resolve) =&gt; {
    console.log("Checking connection to ElasticSearch...");
    let isConnected = false;
    while (!isConnected) {
      try {
        await esclient.cluster.health({});
        console.log("Successfully connected to ElasticSearch");
        isConnected = true;
      // eslint-disable-next-line no-empty
      } catch (_) {
      }
    }
    resolve(true);
  });
}
module.exports = {
  esclient,
  setQuotesMapping,
  checkConnection,
  createIndex,
  index,
  type
};</pre>



<h2 class="wp-block-heading">Populating ElasticSearch with quotes</h2>



<p class="wp-block-paragraph">Now we need to populate our ES instance with our quotes. This may sound easy, but believe me, it can be tricky.</p>



<p class="wp-block-paragraph">Let’s create a new file in&nbsp;<code>/src/data/index.js</code>:</p>



<pre class="wp-block-preformatted">const elastic = require("../elastic");
const quotes  = require("./quotes.json");

const esAction = {
  index: {
    _index: elastic.index,
    _type: elastic.type
  }
};</pre>



<p class="wp-block-paragraph">As you can see, we’re importing the&nbsp;<code>elastic</code>&nbsp;module we just created and our quotes from a JSON file stored in&nbsp;<code>/src/data/quotes.json</code>. We’re also creating an object called&nbsp;<code>esAction</code>, which will tell ES how to index a document once we insert it.</p>



<p class="wp-block-paragraph">Now we need a script to populate our database. We also need to create an array of Object with the following structure:</p>



<pre class="wp-block-preformatted">[
  {
    index: {
      _index: elastic.index,
      _type:  elastic.type
    }
  },
  {
    author: "quote author",
    quote:  "quote"
  },
  ...
]</pre>



<p class="wp-block-paragraph">As you can see, for each quote we’re gonna insert, we need to set its mapping to ElasticSearch. So that’s what we’ll do:</p>



<pre class="wp-block-preformatted">async function populateDatabase() {
  const docs = [];
  for (const quote of quotes) {
    docs.push(esAction);
    docs.push(quote);
  }
  return elastic.esclient.bulk({ body: docs });
}</pre>



<p class="wp-block-paragraph">Great! Now let’s create our main file in&nbsp;<code>/src/main.js</code>&nbsp;and see how we’ll structure everything we’ve written so far:</p>



<pre class="wp-block-preformatted">const elastic = require("./elastic");
const data    = require("./data");
                require("dotenv").config();

(async function main() {

  const isElasticReady = await elastic.checkConnection();
  if (isElasticReady) {
    const elasticIndex = await elastic.esclient.indices.exists({index: elastic.index});

    if (!elasticIndex.body) {
      await elastic.createIndex(elastic.index);
      await elastic.setQuotesMapping();
      await data.populateDatabase()
    }
  }

})();</pre>



<p class="wp-block-paragraph">Let’s analyze the code above. We create a self-executing main function which will check for the ES connection. The code execution won’t proceed until ES is connected. When ES is ready, we’ll check if the&nbsp;<code>quotes</code>&nbsp;index exists. If it doesn’t, we’ll create it, we’ll set its mapping and will populate the database. Obviously, we’ll do so only the first time we start up our server!</p>



<h2 class="wp-block-heading">Creating a RESTful API</h2>



<p class="wp-block-paragraph">Now we need to create our RESTful server. We’ll be using Express.js, which is the most popular Node.js framework out there for building servers.</p>



<p class="wp-block-paragraph">We’ll start with the&nbsp;<code>/src/server/index.js</code>&nbsp;file:</p>



<pre class="wp-block-preformatted">const express      = require("express");
const cors         = require("cors");
const bodyParser   = require("body-parser");
const routes       = require("./routes");
                     require("dotenv").config();

const app  = express();
const port = process.env.NODE_PORT || 3000;

function start() {
  return  app.use(cors())
             .use(bodyParser.urlencoded({ extended: false }))
             .use(bodyParser.json())
             .use("/quotes",routes)
             .use((_req, res) =&gt; res.status(404).json({ success: false,error: "Route not found" }))
             .listen(port, () =&gt; console.log(`Server ready on port ${port}`));
}

module.exports = {
  start
};</pre>



<p class="wp-block-paragraph">As you can see, it is just a standard Express.js server, we won’t spend much time on that.</p>



<p class="wp-block-paragraph">Let’s see our&nbsp;<code>/src/server/routes/index.js</code>&nbsp;file:</p>



<pre class="wp-block-preformatted">const express    = require("express");
const controller = require("../controllers");
const routes     = express.Router();

routes.route("/").get(controller.getQuotes);
routes.route("/new").post(controller.addQuote);

module.exports = routes;</pre>



<p class="wp-block-paragraph">We just create two endpoints:</p>



<ol class="wp-block-list"><li><code>GET&nbsp;/</code>, will return a list of quotes matching our query string parameters.</li><li><code>POST&nbsp;/new/</code>, will allow us to post a new quote storing it inside ElasticSearch.</li></ol>



<p class="wp-block-paragraph">So now let’s see our&nbsp;<code>/src/server/controllers/index.js</code>&nbsp;file:</p>



<pre class="wp-block-preformatted">const model = require("../models");

async function getQuotes(req, res) {
  const query  = req.query;
  if (!query.text) {
    res.status(422).json({
      error: true,
      data: "Missing required parameter: text"
    });
    return;
  }
  try {
    const result = await model.getQuotes(req.query);
    res.json({ success: true, data: result });
  } catch (err) {
    res.status(500).json({ success: false, error: "Unknown error."});
  }
}

async function addQuote(req, res) {
  const body = req.body;
  if (!body.quote || !body.author) {
    res.status(422).json({
      error: true,
      data: "Missing required parameter(s): 'body' or 'author'"
    });
    return;
  }
  try {
    const result = await model.insertNewQuote(body.quote, body.author);
    res.json({ 
      success: true, 
      data: {
        id:     result.body._id,
        author: body.author,
        quote:  body.quote
      } 
    });
  } catch (err) {
    res.status(500).json({ success: false, error: "Unknown error."});
  }
}
module.exports = {
  getQuotes,
  addQuote
};</pre>



<p class="wp-block-paragraph">Here we’re basically defining two functions:</p>



<ol class="wp-block-list"><li><code>getQuotes</code>, which requires at least one querystring parameter –&nbsp;<code>text</code></li><li><code>addQuote</code>, which require two parameters –&nbsp;<code>author</code>&nbsp;and&nbsp;<code>quote</code></li></ol>



<p class="wp-block-paragraph">The ElasticSearch interface is delegated to our&nbsp;<code>/src/server/models/index.js</code>. This structure helps us maintain a MVC-ish architecture.</p>



<p class="wp-block-paragraph">Let’s see our model:</p>



<pre class="wp-block-preformatted">const { esclient, index, type } = require("../../elastic");

async function getQuotes(req) {
  const query = {
    query: {
      match: {
        quote: {
          query: req.text,
          operator: "and",
          fuzziness: "auto"
        }
      }
    }
  }

  const { body: { hits } } = await esclient.search({
    from:  req.page  || 0,
    size:  req.limit || 100,
    index: index, 
    type:  type,
    body:  query
  });

  const results = hits.total.value;
  const values  = hits.hits.map((hit) =&gt; {
    return {
      id:     hit._id,
      quote:  hit._source.quote,
      author: hit._source.author,
      score:  hit._score
    }
  });

  return {
    results,
    values
  }
}</pre>



<p class="wp-block-paragraph">As you can see, we’re composing our ElasticSearch query by selecting every quote that includes a given word or phrase.</p>



<p class="wp-block-paragraph">Then, we spawn the query, setting both&nbsp;<code>page</code>&nbsp;and&nbsp;<code>limit</code>&nbsp;values we can pass them in a query string, for instance&nbsp;<code>http://localhost:3000/quotes?text=love&amp;page=1&amp;limit=100</code>. If these values are not passed via querystring, we’ll fall back to their default values.</p>



<p class="wp-block-paragraph">ElasticSearch returns an incredibly big amount of data, but we just need four things:</p>



<ol class="wp-block-list"><li>Quote ID</li><li>The quote itself</li><li>Quote author</li><li>Score</li></ol>



<p class="wp-block-paragraph">The score represents how close the quote is to our search term. Once we have these values, we return them with the total results number, which may be useful when paginating the results on the front end.</p>



<p class="wp-block-paragraph">Now we need to create the last function for our model&nbsp;<code>insertNewQuote</code>:</p>



<pre class="wp-block-preformatted">async function insertNewQuote(quote, author) {
  return esclient.index({
    index,
    type,
    body: {
      quote,
      author
    }
  })
}</pre>



<p class="wp-block-paragraph">This function is really simple, we just post the quote and the author to our index and return the query result back to the controller.</p>



<p class="wp-block-paragraph">Now the complete&nbsp;<code>/src/server/models/index.js</code>&nbsp;file should look like this:</p>



<pre class="wp-block-preformatted">const { esclient, index, type } = require("../../elastic");

async function getQuotes(req) {
  const query = {
    query: {
      match: {
        quote: {
          query: req.text,
          operator: "and",
          fuzziness: "auto"
        }
      }
    }
  }

  const { body: { hits } } = await esclient.search({
    from:  req.page  || 0,
    size:  req.limit || 100,
    index: index, 
    type:  type,
    body:  query
  });

  const results = hits.total.value;

  const values  = hits.hits.map((hit) =&gt; {
    return {
      id:     hit._id,
      quote:  hit._source.quote,
      author: hit._source.author,
      score:  hit._score
    }
  });

  return {
    results,
    values
  }
}

async function insertNewQuote(quote, author) {
  return esclient.index({
    index,
    type,
    body: {
      quote,
      author
    }
  })
}

module.exports = {
  getQuotes,
  insertNewQuote
}</pre>



<p class="wp-block-paragraph">And we’re done! We just need to setup our start script inside out&nbsp;<code>package.json</code>&nbsp;file and we’re ready to go:</p>



<pre class="wp-block-preformatted">"scripts": {
  "start": "pm2-runtime start ./src/main.js --name node_app",
  "stop": "pm2-runtime stop node_app "
}</pre>



<p class="wp-block-paragraph">We also need to update our&nbsp;<code>/src/main.js</code>&nbsp;script in order to start up our Express.js server once ElasticSearch has been connected:</p>



<pre class="wp-block-preformatted">const elastic = require("./elastic");
const server  = require("./server");
const data    = require("./data");
                require("dotenv").config();

(async function main() {
  const isElasticReady = await elastic.checkConnection();

  if (isElasticReady) {
    const elasticIndex = await elastic.esclient.indices.exists({index: elastic.index});

    if (!elasticIndex.body) {
      await elastic.createIndex(elastic.index);
      await elastic.setQuotesMapping();
      await data.populateDatabase()
    }

    server.start();
  }
})();</pre>



<h2 class="wp-block-heading">Launching the application</h2>



<p class="wp-block-paragraph">We’re now ready to start our application using&nbsp;<strong>docker-compose</strong>!</p>



<p class="wp-block-paragraph">Just run the following command:</p>



<pre class="wp-block-preformatted">docker-compose up</pre>



<p class="wp-block-paragraph">You’ll need to wait until Docker downloads both the ElasticSearch and Node.js images, then it will boot up your server and you’ll be ready to query against your REST endpoints!</p>



<p class="wp-block-paragraph">Let’s test with a couple of cURL calls:</p>



<pre class="wp-block-preformatted">curl localhost:3000/quotes?text=love&amp;limit=3

{
  "success": true,
  "data": {
    "results": 716,
    "values": [
      {
        "id": "JDE3kGwBuLHMiUvv1itT",
        "quote": "There is only one happiness in life, to love and be loved.",
        "author": "George Sand",
        "score": 6.7102118
      },
      {
        "id": "JjE3kGwBuLHMiUvv1itT",
        "quote": "Live through feeling and you will live through love. For feeling is the language of the soul, and feeling is truth.",
        "author": "Matt Zotti",
        "score": 6.2868223
      },
      {
        "id": "NTE3kGwBuLHMiUvv1iFO",
        "quote": "Genuine love should first be directed at oneself if we do not love ourselves, how can we love others?",
        "author": "Dalai Lama",
        "score": 5.236455
      }
    ]
  }
}</pre>



<p class="wp-block-paragraph">So as you can see, we decided to limit our results to&nbsp;<code>3</code>, but there are over 713 quotes!</p>



<p class="wp-block-paragraph">We can easily get the next three quotes by calling:</p>



<pre class="wp-block-preformatted">curl localhost:3000/quotes?text=love&amp;limit=3&amp;page=2

{
  "success": true,
  "data": {
    "results": 716,
    "values": [
      {
        "id": "SsyHkGwBrOFNsaVmePwE",
        "quote": "Forgiveness is choosing to love. It is the first skill of self-giving love.",
        "author": "Mohandas Gandhi",
        "score": 4.93597
      },
      {
        "id": "rDE3kGwBuLHMiUvv1idS",
        "quote": "Neither a lofty degree of intelligence nor imagination nor both together go to the making of genius. Love, love, love, that is the soul of genius.",
        "author": "Wolfgang Amadeus Mozart",
        "score": 4.7821507
      },
      {
        "id": "TjE3kGwBuLHMiUvv1h9K",
        "quote": "Speak low, if you speak love.",
        "author": "William Shakespeare",
        "score": 4.6697206
      }
    ]
  }
}</pre>



<p class="wp-block-paragraph">And what if you need to insert a new quote? Just call the&nbsp;<code>/quotes/new</code>&nbsp;endpoint!</p>



<pre class="wp-block-preformatted">curl --request POST \
     --url http://localhost:3000/quotes/new \
     --header 'content-type: application/json' \
     --data '{
        "author": "Michele Riva",
        "quote": "Using Docker and ElasticSearch is challenging, but totally worth it."
}'</pre>



<p class="wp-block-paragraph">and the response will be:</p>



<pre class="wp-block-preformatted">{
  "success": true,
  "data": {
    "id": "is2QkGwBrOFNsaVmFAi8",
    "author": "Michele Riva",
    "quote": "Using Docker and ElasticSearch is challenging, but totally worth it."
  }
}</pre>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">Docker makes it incredibly easy to manage our dependencies and their deployment. From that point, we could host our application on Heroku, AWS ECS, Google Cloud Container or any other Docker-based service with ease, without struggling to setup our server with their super-complex configurations.</p>



<p class="wp-block-paragraph">Next steps?</p>



<ul class="wp-block-list"><li>Learn how to use Kubernetes in order to scale your container and orchestrate more ElasticSearch Instances!</li><li>Create a new endpoint that will allow you to update an existing quote. Mistakes can happen!</li><li>And what about deleting a quote? How would you implement that endpoint?</li><li>It would be great to save your quotes with tags (for instances, quotes about love, health, art)… try to update your <code>quotes</code> index!</li></ul>



<p class="wp-block-paragraph">Software development is fun. With Docker, Node, and ElasticSearch it’s even better!</p>



<h2 class="wp-block-heading">Plug: LogRocket, a DVR for web apps</h2>



<figure class="wp-block-image"><a href="https://logrocket.com/signup/" target="_blank" rel="noreferrer noopener"><img decoding="async" src="https://i2.wp.com/blog.logrocket.com/wp-content/uploads/2017/03/1d0cd-1s_rmyo6nbrasp-xtvbaxfg.png?resize=1200%2C677&amp;ssl=1" alt="LogRocket Dashboard Free Trial Banner" class="wp-image-46"/></a></figure>



<p class="wp-block-paragraph">LogRocket is a frontend logging tool that lets you replay problems as if they happened in your own browser. Instead of guessing why errors happen, or asking users for screenshots and log dumps, LogRocket lets you replay the session to quickly understand what went wrong. It works perfectly with any app, regardless of framework, and has plugins to log additional context from Redux, Vuex, and @ngrx/store.</p>



<p class="wp-block-paragraph">In addition to logging Redux actions and state, LogRocket records console logs, JavaScript errors, stacktraces, network requests/responses with headers + bodies, browser metadata, and custom logs. It also instruments the DOM to record the HTML and CSS on the page, recreating pixel-perfect videos of even the most complex single-page apps.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/full-text-search-with-node-js-and-elasticsearch-on-docker/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Node.js Is Popular With DevOps Teams, But Security Practice Lags Behind Adoption</title>
		<link>https://www.bestdevops.com/node-js-popular-with-devops-but-security-lags/</link>
					<comments>https://www.bestdevops.com/node-js-popular-with-devops-but-security-lags/#respond</comments>
		
		<dc:creator><![CDATA[anil]]></dc:creator>
		<pubDate>Sat, 04 Nov 2017 07:01:55 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[DevOps News]]></category>
		<category><![CDATA[developer survey]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Security Lags]]></category>
		<category><![CDATA[security tools]]></category>
		<guid isPermaLink="false">http://www.bestdevops.com/?p=2923</guid>

					<description><![CDATA[A survey by NodeSource and Sqreen found that while Node.js is growing rapidly in DevOps environments, most development teams are not consistently using the security tools available to them — leaving applications exposed to known vulnerabilities and real-time attacks.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><em>This article is based on reporting originally published by <strong>enterprisetech.com</strong>, drawing on survey data released by NodeSource and Sqreen.</em></p>



<h2 class="wp-block-heading">Node.js Adoption Outpacing Security Readiness</h2>



<p class="wp-block-paragraph">Node.js has earned a strong foothold in DevOps toolchains, with NodeSource — a commercial Node.js runtime vendor — describing it as &#8220;the runtime of choice for DevOps.&#8221; Yet a joint survey conducted by NodeSource and application security startup Sqreen reveals a troubling gap: developer teams are adopting Node.js rapidly while underinvesting in the security practices needed to protect the applications they build with it.</p>



<h2 class="wp-block-heading">Key Survey Findings</h2>



<p class="wp-block-paragraph">The survey polled Node.js developers and technology executives. Its headline findings paint a picture of widespread security anxiety paired with limited remediation activity:</p>



<ul class="wp-block-list">
  <li><strong>More than one-third</strong> of respondents expect their organization to be hacked, with many resigned to a significant attack within the next six months.</li>
  <li><strong>60 percent</strong> of developers expressed concern about the security of their applications.</li>
  <li>Only <strong>16 percent</strong> were confident that third-party modules used in their projects are free of vulnerabilities.</li>
  <li>Only <strong>30 percent</strong> combine manual and automated code reviews to identify known vulnerabilities.</li>
  <li>Only <strong>30 percent</strong> reported scanning third-party code to detect vulnerable dependencies.</li>
  <li>Just <strong>35 percent</strong> of companies combine code reviews with automated tooling to search for vulnerabilities.</li>
  <li>Only <strong>23 percent</strong> of respondents use any form of real-time threat detection.</li>
  <li>The most common monitoring approach — used by <strong>44 percent</strong> — is log inspection, a largely reactive method.</li>
  <li><strong>35 percent</strong> of developers acknowledged they have no reliable way of knowing when their applications are actively under attack.</li>
</ul>



<h2 class="wp-block-heading">Security Is a Concern, Not a Priority</h2>



<p class="wp-block-paragraph">&#8220;Our survey results clearly demonstrate that security is a concern for developers — but not a priority,&#8221; said Joe McCann, CEO of NodeSource, in a statement accompanying the survey release.</p>



<p class="wp-block-paragraph">The findings reflect a tension familiar across modern software delivery: the pressure to ship code quickly competes directly with the time and discipline required to secure it. Release cycles that once ran monthly now run weekly, and individual code components may be updated multiple times per day. In that environment, security reviews are often deferred or skipped entirely.</p>



<h2 class="wp-block-heading">Open Source Dependencies Amplify the Risk</h2>



<p class="wp-block-paragraph">Node.js development relies heavily on the npm ecosystem, which provides access to hundreds of thousands of open source packages. The convenience of reusing community-maintained modules accelerates development but introduces a significant supply-chain risk: vulnerabilities in upstream packages can propagate into production applications without any action by the application developer.</p>



<p class="wp-block-paragraph">Security experts cited in the original reporting note that the greater availability and use of open source code — which is often maintained inconsistently — has heightened these concerns. The survey data supports this: only 16 percent of respondents expressed confidence in the security posture of their third-party dependencies.</p>



<h2 class="wp-block-heading">Tools Exist, But Adoption Remains Low</h2>



<p class="wp-block-paragraph">&#8220;Developers have a wide array of security tools at their disposal that they are simply not using,&#8221; said Jean-Baptiste Aviat, co-founder and CTO of Sqreen. Aviat and his co-founder previously worked as security specialists at Apple before founding Sqreen, which provides runtime application self-protection (RASP) and security monitoring software.</p>



<p class="wp-block-paragraph">The categories of tooling available to Node.js development teams include:</p>



<ul class="wp-block-list">
  <li><strong>Static analysis (SAST):</strong> Scans source code for known vulnerability patterns before deployment.</li>
  <li><strong>Software composition analysis (SCA):</strong> Audits third-party and open source dependencies for known CVEs. Tools such as <code>npm audit</code>, Snyk, and OWASP Dependency-Check fall into this category.</li>
  <li><strong>Dynamic analysis (DAST):</strong> Tests running applications for exploitable weaknesses.</li>
  <li><strong>Runtime protection (RASP):</strong> Monitors application behavior in real time and can block attacks as they occur — the category Sqreen operates in.</li>
  <li><strong>Security Information and Event Management (SIEM):</strong> Aggregates and correlates security events across systems for centralized visibility.</li>
</ul>



<p class="wp-block-paragraph">The survey found that SIEM adoption among Node.js teams was low, with log inspection being the dominant — and largely reactive — monitoring approach.</p>



<h2 class="wp-block-heading">Real-Time Detection: The Most Critical Gap</h2>



<p class="wp-block-paragraph">Perhaps the most operationally significant finding is that only 23 percent of Node.js developers use any form of real-time threat detection. Relying on log analysis means that by the time a team identifies an attack, damage may already be done — data exfiltrated, services disrupted, or credentials compromised.</p>



<p class="wp-block-paragraph">The 35 percent of developers who reported having no way to detect active attacks represent a particularly high-risk cohort. Without visibility into runtime behavior, these teams cannot distinguish normal traffic from exploitation attempts, nor can they respond to incidents in a timely manner.</p>



<h2 class="wp-block-heading">What DevOps Teams Should Do</h2>



<p class="wp-block-paragraph">The survey data points to several practical areas where DevOps and development teams can close the security gap without overhauling their entire workflow:</p>



<ol class="wp-block-list">
  <li><strong>Integrate dependency scanning into CI/CD pipelines.</strong> Running <code>npm audit</code> or a dedicated SCA tool on every build catches vulnerable packages before they reach production.</li>
  <li><strong>Automate code review checks.</strong> Pairing human code review with static analysis tools reduces the burden on reviewers and catches vulnerability classes that humans commonly miss.</li>
  <li><strong>Add runtime visibility.</strong> Even basic application performance monitoring (APM) with security alerting provides far more insight than log inspection alone.</li>
  <li><strong>Treat security as a pipeline gate, not a post-deployment audit.</strong> Shifting security left — embedding checks early in development — reduces the cost and disruption of remediating vulnerabilities found in production.</li>
  <li><strong>Inventory and continuously monitor third-party modules.</strong> As the npm dependency tree grows, automated tooling is the only scalable way to track which packages are in use and whether they have been flagged for vulnerabilities.</li>
</ol>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">Node.js has become a foundational runtime for many DevOps teams, valued for its performance, extensive package ecosystem, and JavaScript&#8217;s ubiquity. But popularity without security discipline creates a large and growing attack surface. The NodeSource/Sqreen survey suggests that awareness of the problem is high while action to address it remains limited. Closing that gap requires treating security tooling as an integral part of the delivery pipeline rather than an optional add-on applied after the fact.</p>



<p class="wp-block-paragraph"><em>Original reporting: enterprisetech.com. Survey conducted by NodeSource and Sqreen (published 2017).</em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/node-js-popular-with-devops-but-security-lags/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Set Up a Continuous Testing Pipeline with Node.js</title>
		<link>https://www.bestdevops.com/tutorial-set-up-a-continuous-testing-pipeline-with-node-js/</link>
					<comments>https://www.bestdevops.com/tutorial-set-up-a-continuous-testing-pipeline-with-node-js/#respond</comments>
		
		<dc:creator><![CDATA[anil]]></dc:creator>
		<pubDate>Fri, 24 Mar 2017 12:05:58 +0000</pubDate>
				<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[DevOps Best Practices]]></category>
		<category><![CDATA[DevOps Tools]]></category>
		<category><![CDATA[Continuous Deployment]]></category>
		<category><![CDATA[Continuous testing]]></category>
		<category><![CDATA[Continuous testing pipeline]]></category>
		<category><![CDATA[Heroku]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://www.bestdevops.com/?p=1034</guid>

					<description><![CDATA[Learn how to build a complete continuous development pipeline that automatically builds, deploys, and tests a Node.js application using GitHub, CircleCI, Heroku, and Assertible.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Continuous integration is a well-established part of modern development workflows. Most teams are already familiar with CI services that automatically build code whenever new changes are pushed to a repository. But the real power comes from extending that pipeline further — not just building your code, but also <strong>deploying</strong> it and <strong>testing</strong> it automatically within the same workflow. This broader practice is often called <strong>continuous development</strong> (or a full CI/CD/CT pipeline).</p>



<figure class="wp-block-image"><img decoding="async" src="https://s3-us-west-2.amazonaws.com/assertible/blog/continuous-development-diagram-horizontal.png" alt="Continuous development pipeline diagram showing build, deploy, and test stages" /><figcaption>A complete continuous development workflow: integrate, deploy, and test — automatically.</figcaption></figure>



<p class="wp-block-paragraph">This tutorial walks through each stage of that pipeline using a Node.js example application:</p>



<ul class="wp-block-list">
<li><strong>Continuous integration</strong>: Push code to GitHub; CircleCI automatically builds and runs unit tests.</li>
<li><strong>Continuous deployment</strong>: On a successful build, CircleCI deploys the application to Heroku.</li>
<li><strong>Continuous testing</strong>: After deployment, Assertible runs automated post-deployment API tests against the live application.</li>
</ul>



<p class="wp-block-paragraph">By the end, you will have a workflow that automatically builds, deploys, and tests your Node.js app after every push to your repository — with no manual steps required.</p>



<h2 class="wp-block-heading">Continuous Integration with CircleCI</h2>



<p class="wp-block-paragraph">The pipeline starts when code is pushed to a GitHub repository. CircleCI picks up the new changes, installs dependencies, and runs your unit tests. Setting this up requires just two things:</p>



<ol class="wp-block-list">
<li>Add a <code>circle.yml</code> configuration file to the root of your repository.</li>
<li>Connect the repository to CircleCI by adding it as a project in your CircleCI dashboard.</li>
</ol>



<p class="wp-block-paragraph">For a Node.js application, the default CircleCI settings are sufficient. CircleCI automatically detects Node.js projects and runs <code>npm install</code> followed by <code>npm test</code> without requiring any extra configuration in the YAML file.</p>



<p class="wp-block-paragraph">A minimal <code>circle.yml</code> for a Node.js project looks like this:</p>


<pre class="wp-block-code"><span><code class="hljs">machine:
  node:
    version: stable

test:
  post:
    - npm test</code></span></pre>


<p class="wp-block-paragraph">Once configured, every push to GitHub triggers a CircleCI build. If any unit test fails, the pipeline stops and the deployment step is never reached — protecting your production environment from broken builds.</p>



<figure class="wp-block-image"><img decoding="async" src="https://s3-us-west-2.amazonaws.com/assertible/blog/assertible-circleci-build-example.png" alt="CircleCI showing a successful build for a Node.js project" /><figcaption>A successful CircleCI build confirms all unit tests have passed before deployment begins.</figcaption></figure>



<h2 class="wp-block-heading">Continuous Deployment with Heroku</h2>



<p class="wp-block-paragraph">After a successful build, CircleCI executes the <code>deployment</code> block in <code>circle.yml</code>. In this example, the application is deployed to Heroku by pushing directly to the Heroku Git remote using the commit SHA captured in the <code>$CIRCLE_SHA1</code> environment variable.</p>


<pre class="wp-block-code"><span><code class="hljs language-php">deployment:
  production:
    branch: master
    commands:
      <span class="hljs-comment"># Deploy the app to Heroku</span>
      - git push git@heroku.com:your-app-name.git $CIRCLE_SHA1:refs/heads/master</code></span></pre>


<p class="wp-block-paragraph">This configuration tells CircleCI to trigger the production deployment only when changes are merged to the <code>master</code> branch. Feature branches will still be built and tested by CircleCI, but they will not be deployed to production.</p>



<p class="wp-block-paragraph">Key points about this deployment step:</p>



<ul class="wp-block-list">
<li>The Heroku SSH key must be added to CircleCI&#8217;s project settings so the <code>git push</code> is authenticated.</li>
<li>You can extend the <code>commands</code> list to run database migrations, flush caches, or perform any other pre- or post-deploy tasks.</li>
<li>Heroku review apps can be used alongside this pattern to create isolated staging environments for every pull request.</li>
</ul>



<figure class="wp-block-image"><img decoding="async" src="https://s3-us-west-2.amazonaws.com/assertible/blog/assertible-heroku-deploy-example.png" alt="Heroku deployment activity log showing a successful release" /><figcaption>Heroku&#8217;s activity log confirms each deployment was triggered automatically by CircleCI.</figcaption></figure>



<h2 class="wp-block-heading">Continuous Testing with Assertible</h2>



<p class="wp-block-paragraph">Unit tests verify your code in isolation, but they cannot tell you whether the live, deployed application is actually working correctly. That is where post-deployment testing comes in. After Heroku finishes the deployment, the pipeline uses Assertible to run a suite of API tests against the running application.</p>



<p class="wp-block-paragraph">Assertible listens for GitHub Deployment events. When it receives a <code>success</code> deployment status for a repository it is connected to, it automatically runs the API tests you have defined. The <code>github_deploy</code> helper script (provided by Assertible&#8217;s open-source <code>assertible/deployments</code> repository) sends these events from within your CircleCI build.</p>



<p class="wp-block-paragraph">Add the following steps to your <code>circle.yml</code> deployment commands, after the Heroku push:</p>


<pre class="wp-block-code"><span><code class="hljs language-php"><span class="hljs-comment"># Download the github_deploy helper script</span>
- curl https:<span class="hljs-comment">//raw.githubusercontent.com/assertible/deployments/master/github_deploy &gt; github_deploy</span>
- chmod +x github_deploy

<span class="hljs-comment"># Notify GitHub of the deployment, then mark it successful.</span>
<span class="hljs-comment"># Assertible listens for the 'success' event and triggers API tests.</span>
- |
  APPROOT=https:<span class="hljs-comment">//your-app-name.herokuapp.com/</span>
  DEPLOY_ID=$(ENVIRONMENT_NAME=<span class="hljs-string">"production"</span> ./github_deploy $CIRCLE_SHA1 $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME $APPROOT <span class="hljs-string">"pending"</span>)
  ./github_deploy $CIRCLE_SHA1 $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME $APPROOT <span class="hljs-string">"success"</span> $DEPLOY_ID</code></span></pre>


<p class="wp-block-paragraph">The script first creates a deployment record in GitHub with a <code>pending</code> status, capturing the resulting deployment ID. Once the deployment is confirmed live, it updates the status to <code>success</code>. Assertible detects this event and immediately executes the configured API test suite.</p>



<figure class="wp-block-image"><img decoding="async" src="https://s3-us-west-2.amazonaws.com/assertible/blog/assertible-deployment-results-example.png" alt="Assertible post-deployment test results showing API assertions passed" /><figcaption>Assertible runs API assertions against the newly deployed application and links results back to the triggering commit.</figcaption></figure>



<p class="wp-block-paragraph">This automated post-deployment testing catches issues that unit tests cannot — such as misconfigured environment variables, broken integrations with external services, or unexpected runtime errors in the deployed environment.</p>



<h3 class="wp-block-heading">Testing Staging Environments from Pull Requests</h3>



<p class="wp-block-paragraph">The same mechanism works for staging environments and Heroku review apps. When a pull request triggers a deployment to a staging environment, Assertible runs your API tests against that environment and reports the results as a GitHub status check directly on the pull request.</p>



<p class="wp-block-paragraph">This means reviewers can see at a glance whether the new changes pass API tests before merging — adding an additional quality gate beyond code review alone.</p>



<figure class="wp-block-image"><img decoding="async" src="https://s3-us-west-2.amazonaws.com/assertible/blog/assertible-status-checks.png" alt="GitHub pull request showing Assertible status checks for continuous testing" /><figcaption>Assertible reports API test results as GitHub status checks on pull requests, blocking merges if tests fail.</figcaption></figure>



<h2 class="wp-block-heading">Extending the Pipeline</h2>



<h3 class="wp-block-heading">Additional Automation with Heroku Add-ons</h3>



<p class="wp-block-paragraph">Heroku&#8217;s add-on ecosystem provides many ways to extend this workflow. You can automate database migrations, queue background jobs, flush CDN caches, or send deployment notifications to Slack — all as additional commands within the CircleCI deployment block.</p>



<h3 class="wp-block-heading">Using Other CI Providers</h3>



<p class="wp-block-paragraph">The core pattern described here — build, deploy, emit a GitHub deployment event, trigger automated tests — is not tied to any specific toolchain. The same approach works with other CI providers such as Travis CI, Jenkins, Wercker, or GitHub Actions. The key requirement is the ability to make an authenticated HTTP request (or run a shell script) that creates a GitHub Deployment event with a <code>success</code> status after deployment completes.</p>



<p class="wp-block-paragraph">Assertible&#8217;s open-source <code>assertible/deployments</code> repository contains scripts and documentation for integrating with multiple CI providers.</p>



<h2 class="wp-block-heading">Summary</h2>



<p class="wp-block-paragraph">A complete continuous development pipeline for a Node.js application can be assembled from three focused tools:</p>



<ul class="wp-block-list">
<li><strong>CircleCI</strong> handles building and unit testing on every push, and orchestrates the deployment step.</li>
<li><strong>Heroku</strong> receives the automated deployment and hosts the running application.</li>
<li><strong>Assertible</strong> listens for GitHub deployment events and runs post-deployment API tests to verify the live environment.</li>
</ul>



<p class="wp-block-paragraph">The result is a pipeline where every push to <code>master</code> automatically progresses through build, deploy, and test stages — with failures surfaced quickly at each gate, long before users are affected.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/tutorial-set-up-a-continuous-testing-pipeline-with-node-js/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
