<?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 Archives | Clever Cloud</title>
	<atom:link href="https://www.clever.cloud/blog/tag/node/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.clever.cloud/blog/tag/node/</link>
	<description>From Code to Product</description>
	<lastBuildDate>Fri, 27 Oct 2023 12:48:39 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://cdn.clever-cloud.com/uploads/2023/03/cropped-cropped-favicon-32x32.png</url>
	<title>node Archives | Clever Cloud</title>
	<link>https://www.clever.cloud/blog/tag/node/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Deploy node projects as static &#8211; MDX-Deck demo</title>
		<link>https://www.clever.cloud/blog/engineering/2020/05/05/deploy-node-mxd-deck/</link>
		
		<dc:creator><![CDATA[Valeriane Venance]]></dc:creator>
		<pubDate>Tue, 05 May 2020 14:27:00 +0000</pubDate>
				<category><![CDATA[Engineering]]></category>
		<category><![CDATA[mxd-deck]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[static deployment]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2020/05/05/deploy-node-mxd-deck/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="nodebanner 1" decoding="async" fetchpriority="high" srcset="https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1.png 1400w, https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1-300x116.png 300w, https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1-1024x395.png 1024w, https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1-768x296.png 768w, https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p>As some of you may know, we love to present tech talks at Clever Cloud, and this often comes with visual presentations slides. There are numerous tools to help you do that, but one particularly caught my attention as it is also destined to developers first.<span id="more-2824"></span> <a href="https://github.com/jxnblk/mdx-deck">MDX-deck</a> allows you to write <a href="https://reactjs.org/">React</a> components and content in <a href="https://www.markdownguide.org/">Markdown</a> among other cool stuffs. Check out the official repo to find out more about the capabilities of the project.

Wether you&#39;re doing presentations or not, read carefully, we are about to deploy a static application made out of a React build and use the Clever Cloud hooks to do so. Ready? Let&#39;s go.
<h3 id="requirements">Requirements</h3>
<ul>
 	<li>you need to have <a href="https://www.npmjs.com/get-npm">npm</a> and <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">git</a> installed on your machine.</li>
 	<li>you need a <a href="https://api.clever-cloud.com/v2/sessions/signup">Clever Cloud account</a> with at least a validated email to benefit the free credits.</li>
</ul>
<h3 id="setting-up-our-mdx-deck">Setting up our MDX-Deck</h3>
Go to your console and type in
<pre><code class="language-bash">$ mkdir presentation //creating a new folder
$ cd presentation
$ git init // creating fresh git folder
$ npm init //creating new project
</code></pre>
Just type enter for eveything you&#39;re prompted of except for <code>description</code> if you would like to provide one, <code>author</code> that you must fill, <code>license</code> that you can edit to the licence you want your project to be under.

Now we will create our presentation file with <code>$ touch deck.mdx</code> and add the package to the project with <code>$ npm i -D mdx-deck</code>.

Open the project in your text editor and start with fine tuning <code>package.json</code> Here we want to remove the line
<pre><code class="language-json">&quot;main&quot;: &quot;index.js&quot;,
</code></pre>
and add a start and a build command using the mxd-deck CLI with the file we just created to our scripts
<pre><code class="language-json">&quot;scripts&quot;: {
    &quot;start&quot;: &quot;mdx-deck deck.mdx&quot;,
    &quot;build&quot;: &quot;mdx-deck build deck.mdx&quot;,
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
},
</code></pre>
We will only use <code>start</code> to test locally and use <code>build</code> to deploy. We are done with <code>package.json</code>, we can now move to <code>deck.mdx</code>. Add this in the file:
<pre><code class="language-markdown"># Congratulations!

---

## You&#39;re up and live on Clever Cloud!

---
</code></pre>
You can note that we have just created two slides, each one ending with <code>---</code> and that we are using the Markdown syntax. Let&#39;s see how it renders with <code>npm start</code>. Your browser will open at <code>http://localhost:8000</code> displaying our first slide. Use side arrows to navigate between pages.
<h2 id="deploy-to-clever-cloud-as-static-with-hooks">Deploy to clever cloud as static with hooks</h2>
Now we will create a static application in the <a href="https://console.clever-cloud.com/">Clever Cloud console</a>. Under the organization of our choice, we will click the <strong>Create</strong> button and select <strong>application</strong>, then <strong>Static</strong>. Follow the instructions, and just select <strong>git</strong> when you have the choice between it and FTP. A git remote will be provided to you. Add it to your local repository with the provided command and get back to the Clever Cloud console. Select <strong>Environment variables</strong> in the left menu of your application and add <code>CC_PRE_RUN_HOOK</code> with value <code>npm run build</code> and <code>CC_WEBROOT</code> with value <code>/public</code>. Do not forget to add each new variable and to update changes when you are done editing.

Now we can push our sources to the clever git remote we set previously by adding and committing them, then pushing with <code>$ git push clever master</code>. It is also possible to du it using the Clever Cloud CLI with <code>clever deploy</code>. Documentation <a href="https://www.clever.cloud/developers/clever-tools/getting_started/">here</a>

In the Clever Cloud console, the deployment logs will appear and after a little you will be able to navigate to your application by going to the <strong>overview</strong> page of your application and clicking the link icon on the top right. Use right arrow to navigate to slide two. But what did just happen?
<h2 id="explanation">Explanation</h2>
The <code>CC_PRE_RUN_HOOK</code> is a command run only if specified. This hook is run before the dependencies are fetched and has the specificity to make your deployment fail if it no successful. This is helpful as we do not want to try running a failed build result and have confusing errors harder to debug.
Here, we gave it the value of <code>npm run-script build</code>, this basically tells npm to run our build command specified in <code>package.json</code>. Build command which runs mdx-deck build cli. That leaves us with a new <code>/public</code> folder containing our website static web pages. The other environment variable we used is <code>CC_WEBROOT</code>. This variable tells the server to set the DocumentRoot to the  <code>/public</code> folder wich contains your web pages. This is where a visitor will end up when visiting your website.

You can, of course adapt, it to any other npm project static build.]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="nodebanner 1" decoding="async" srcset="https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1.png 1400w, https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1-300x116.png 300w, https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1-1024x395.png 1024w, https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1-768x296.png 768w, https://cdn.clever-cloud.com/uploads/2021/08/nodebanner-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p>As some of you may know, we love to present tech talks at Clever Cloud, and this often comes with visual presentations slides. There are numerous tools to help you do that, but one particularly caught my attention as it is also destined to developers first.<span id="more-2824"></span> <a href="https://github.com/jxnblk/mdx-deck">MDX-deck</a> allows you to write <a href="https://reactjs.org/">React</a> components and content in <a href="https://www.markdownguide.org/">Markdown</a> among other cool stuffs. Check out the official repo to find out more about the capabilities of the project.

Wether you&#39;re doing presentations or not, read carefully, we are about to deploy a static application made out of a React build and use the Clever Cloud hooks to do so. Ready? Let&#39;s go.
<h3 id="requirements">Requirements</h3>
<ul>
 	<li>you need to have <a href="https://www.npmjs.com/get-npm">npm</a> and <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">git</a> installed on your machine.</li>
 	<li>you need a <a href="https://api.clever-cloud.com/v2/sessions/signup">Clever Cloud account</a> with at least a validated email to benefit the free credits.</li>
</ul>
<h3 id="setting-up-our-mdx-deck">Setting up our MDX-Deck</h3>
Go to your console and type in
<pre><code class="language-bash">$ mkdir presentation //creating a new folder
$ cd presentation
$ git init // creating fresh git folder
$ npm init //creating new project
</code></pre>
Just type enter for eveything you&#39;re prompted of except for <code>description</code> if you would like to provide one, <code>author</code> that you must fill, <code>license</code> that you can edit to the licence you want your project to be under.

Now we will create our presentation file with <code>$ touch deck.mdx</code> and add the package to the project with <code>$ npm i -D mdx-deck</code>.

Open the project in your text editor and start with fine tuning <code>package.json</code> Here we want to remove the line
<pre><code class="language-json">&quot;main&quot;: &quot;index.js&quot;,
</code></pre>
and add a start and a build command using the mxd-deck CLI with the file we just created to our scripts
<pre><code class="language-json">&quot;scripts&quot;: {
    &quot;start&quot;: &quot;mdx-deck deck.mdx&quot;,
    &quot;build&quot;: &quot;mdx-deck build deck.mdx&quot;,
    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
},
</code></pre>
We will only use <code>start</code> to test locally and use <code>build</code> to deploy. We are done with <code>package.json</code>, we can now move to <code>deck.mdx</code>. Add this in the file:
<pre><code class="language-markdown"># Congratulations!

---

## You&#39;re up and live on Clever Cloud!

---
</code></pre>
You can note that we have just created two slides, each one ending with <code>---</code> and that we are using the Markdown syntax. Let&#39;s see how it renders with <code>npm start</code>. Your browser will open at <code>http://localhost:8000</code> displaying our first slide. Use side arrows to navigate between pages.
<h2 id="deploy-to-clever-cloud-as-static-with-hooks">Deploy to clever cloud as static with hooks</h2>
Now we will create a static application in the <a href="https://console.clever-cloud.com/">Clever Cloud console</a>. Under the organization of our choice, we will click the <strong>Create</strong> button and select <strong>application</strong>, then <strong>Static</strong>. Follow the instructions, and just select <strong>git</strong> when you have the choice between it and FTP. A git remote will be provided to you. Add it to your local repository with the provided command and get back to the Clever Cloud console. Select <strong>Environment variables</strong> in the left menu of your application and add <code>CC_PRE_RUN_HOOK</code> with value <code>npm run build</code> and <code>CC_WEBROOT</code> with value <code>/public</code>. Do not forget to add each new variable and to update changes when you are done editing.

Now we can push our sources to the clever git remote we set previously by adding and committing them, then pushing with <code>$ git push clever master</code>. It is also possible to du it using the Clever Cloud CLI with <code>clever deploy</code>. Documentation <a href="https://www.clever.cloud/developers/clever-tools/getting_started/">here</a>

In the Clever Cloud console, the deployment logs will appear and after a little you will be able to navigate to your application by going to the <strong>overview</strong> page of your application and clicking the link icon on the top right. Use right arrow to navigate to slide two. But what did just happen?
<h2 id="explanation">Explanation</h2>
The <code>CC_PRE_RUN_HOOK</code> is a command run only if specified. This hook is run before the dependencies are fetched and has the specificity to make your deployment fail if it no successful. This is helpful as we do not want to try running a failed build result and have confusing errors harder to debug.
Here, we gave it the value of <code>npm run-script build</code>, this basically tells npm to run our build command specified in <code>package.json</code>. Build command which runs mdx-deck build cli. That leaves us with a new <code>/public</code> folder containing our website static web pages. The other environment variable we used is <code>CC_WEBROOT</code>. This variable tells the server to set the DocumentRoot to the  <code>/public</code> folder wich contains your web pages. This is where a visitor will end up when visiting your website.

You can, of course adapt, it to any other npm project static build.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Elastic Basics: Indexation</title>
		<link>https://www.clever.cloud/blog/features/2020/04/02/indexing-elasticsearch-clever-cloud/</link>
		
		<dc:creator><![CDATA[Valeriane Venance]]></dc:creator>
		<pubDate>Thu, 02 Apr 2020 17:10:00 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[elastic]]></category>
		<category><![CDATA[elasticsearch]]></category>
		<category><![CDATA[indexation]]></category>
		<category><![CDATA[node]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2020/04/02/indexing-elasticsearch-clever-cloud/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="elastic indexation clever cloud 1" decoding="async" srcset="https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1-1368x528.jpg 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><p>In my <a href="https://www.clever.cloud/blog/features/2020/03/30/elastic-canvas-clever-cloud/">last article</a> I created a simple Canvas workpad in my Kibana. To do so I already had meetup data indexed in my Elastic instance. Today I am going to tell you how I did gather data and added it to Elasticsearch.</p>
<span id="more-2972"></span>

<h2 id="selecting-meetups-i-want-to-track">Selecting meetups I want to track</h2>
<p>The first thing to do is to select a list of meetup groups you want to keep track of. There are many ways to do that using the <a href="https://www.meetup.com/meetup_api/">Meetup API</a>. For instance, you can search to similar groups using the <a href="https://www.meetup.com/fr-FR/meetup_api/docs/:urlname/similar_groups/?uri=%2Fmeetup_api%2Fdocs%2F%3Aurlname%2Fsimilar_groups%2F">similar_groups endpoint</a>. I let you read the API documentation to find a way to select the events you will track. You just need to format the response to extract the cities and the names of the Meetups groups in a JSON file formatted as follows:</p>
<pre><code class="language-json">{
  &quot;City name 1&quot;: [
    &quot;meetup group name 1&quot;,
    &quot;meetup group name 2&quot;,
    ...
  ],
  &quot;City name 2&quot;: [
    &quot;meetup group name 1&quot;,
    ...
  ]
}
</code></pre>
<h2 id="getting-data-about-meetup-events">Getting data about meetup events</h2>
<p>Once you have this, you can use the <a href="https://github.com/CleverCloud/meetups-elastic-import">node.js application we created</a>. Of course it has the Elasticsearch dependency in package.json. You are strongly invited to check out the source code at this point. You can see in the index.js many parts of interest:</p>
<ul>
<li>The creation of an express server listening on port 8080. We need it, so Clever Cloud will know our app is up running.</li>
</ul>
<pre><code class="language-javascript">app.get(&#39;/&#39;, (req, res) =&gt; {
    res.send(&#39;Hello !&#39;);
});
app.listen(8080, () =&gt; console.log(&#39;Listening on port 8080!&#39;)); 
</code></pre>
<ul>
<li>The meetup API call:</li>
</ul>
<pre><code class="language-javascript">axios.get(`https://api.meetup.com/${meetupName}/events/?status=past,upcoming\&amp;fields=comment_count`)
</code></pre>
<ul>
<li>the creation of Elasticsearch indexes:</li>
</ul>
<pre><code class="language-javascript">await client.indices.create({
  index: &quot;meetup&quot;,
  body : {
    &quot;mappings&quot;: {
      &quot;properties&quot;: {
        &quot;time&quot;:  {&quot;type&quot;: &quot;date&quot;, &quot;format&quot;: &quot;epoch_millis&quot;},
        &quot;group.name&quot;: {&quot;type&quot;: &quot;keyword&quot;},
        &quot;yes_rsvp_count&quot; : {&quot;type&quot;: &quot;integer&quot;},
        &quot;grouploc&quot;: {&quot;type&quot;: &quot;geo_point&quot;},
        &quot;venueloc&quot;:{&quot;type&quot;: &quot;geo_point&quot;}
      }
    }
  }
});
</code></pre>
<ul>
<li>The creation of another server where our meetup API calls happen, listening on port 8081. We can also notice that we&#39;ve restricted our server to allow only localhost connections.</li>
</ul>
<pre><code class="language-javascript">localapp.listen(8081, &#39;localhost&#39;, function() {
  console.log(&quot;... port %d in %s mode&quot;, 8081, localapp.settings.env);
</code></pre>
<p>Now in <code>./clevercloud/cron.json</code> you can notice a cron task, wich will trigger a curl on <code>http://localhost:8081/</code> every night at 1 AM:</p>
<pre><code class="language-json">&quot;0 1 * * * /usr/host/bin/curl http://localhost:8081/&quot;
</code></pre>
<p>It is this cron that will call our second server to trigger the meetup API calls.</p>
<p>True fact: to use it in its current version, you must keep your application running all the time for one hour of usage maximum. A way to improve the application regarding this issue would be to implement authentication to our application, so we still are the only one having access.</p>
<p>Then remove the cron from this project to have it running in your main application instead. Your main application will be the one consuming this indexed data. Taking advantage on the fact that every virtual machine running on Clever Cloud already has the Clever Tools CLI installed, we could improve our cron to start the application for an hour then stop it when it has finished its indexation job.</p>
<p>So you will end up with two machines, one with your main application, and the second one running for one hour each night.</p>
<p>We must also know that Clever Cloud does not monitor what&#39;s going on on port 8081. You could add a logging system or use Elastic APM to monitor your application during its execution time.</p>
<p>This is an approach among many others, do not hesitate to talk with us about your own implementation.</p>
<p>Okay, let&#39;s go back to our main goal, and to do so, you can use our sample data meetup list or use your own by replacing the json in the <code>meetups.json</code>file.</p>
<h2 id="try-it-out">Try it out</h2>
<p>You can <code>$ git clone</code> the repo in your console, and go into your Clever Cloud console.</p>
<p>Under the organization of your choice, select <strong>New</strong>, <strong>Application</strong>, <strong>Node</strong>. When prompted if you need add-ons, select <strong>Elastic Stack</strong>, select the plan you need and <strong>enable Kibana</strong> as an option.</p>
<p>In the environment variables menu of your application, add <code>NODE_ENV=production</code> and add the provided <code>clever remote</code> to your local git folder. Then push using <code>git push -u clever master</code>.</p>
<p>Your deployment will start and thanks to the <code>ES_ADDON_URI</code> we provided in our index.js file, we have nothing else to configure, our application will start sending data to elastic.</p>
<h2 id="visualize-your-data-and-go-further">Visualize your data and go further</h2>
<p>Either in your Kibana or Elastic instance menu in the Clever Cloud console, in the information page you will find a <strong>Open Kibana</strong> button. Click it and login using your Clever Cloud credentials.</p>
<p>Into Kibana click on the <strong>Management</strong> (gear) icon in the left side menu. Under the Kibana title, select <strong>Index Patterns</strong>, then <strong>meetup*</strong> to see how the data is indexed.</p>
<figure style="position:relative;width:50%;height:auto;margin:0 auto">
  <img data-action="zoom"  alt="index of meetups in Kibana" src="https://cdn.clever-cloud.com/uploads/2021/08/kibana-meetups.png"/>
</figure>

<p>Of course at this point, you are able to do the exact same as I did in the previous article <a href="https://www.loom.com/share/e36ce43a8d104984bba96cde3c67d714">video</a>.</p>
<p>Here is the ElasticSQL query I used in the Canvas demonstration:</p>
<pre><code class="language-sql">SELECT AVG(&quot;yes_rsvp_count&quot;) AS average, &quot;group.name&quot; FROM &quot;meetup*&quot;
GROUP BY &quot;group.name&quot;
ORDER BY average DESC
LIMIT 5
</code></pre>
<p>Happy indexing!</p>
]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="elastic indexation clever cloud 1" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/08/elastic-indexation-clever-cloud-1-1368x528.jpg 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p><p>In my <a href="https://www.clever.cloud/blog/features/2020/03/30/elastic-canvas-clever-cloud/">last article</a> I created a simple Canvas workpad in my Kibana. To do so I already had meetup data indexed in my Elastic instance. Today I am going to tell you how I did gather data and added it to Elasticsearch.</p>
<span id="more-2972"></span>

<h2 id="selecting-meetups-i-want-to-track">Selecting meetups I want to track</h2>
<p>The first thing to do is to select a list of meetup groups you want to keep track of. There are many ways to do that using the <a href="https://www.meetup.com/meetup_api/">Meetup API</a>. For instance, you can search to similar groups using the <a href="https://www.meetup.com/fr-FR/meetup_api/docs/:urlname/similar_groups/?uri=%2Fmeetup_api%2Fdocs%2F%3Aurlname%2Fsimilar_groups%2F">similar_groups endpoint</a>. I let you read the API documentation to find a way to select the events you will track. You just need to format the response to extract the cities and the names of the Meetups groups in a JSON file formatted as follows:</p>
<pre><code class="language-json">{
  &quot;City name 1&quot;: [
    &quot;meetup group name 1&quot;,
    &quot;meetup group name 2&quot;,
    ...
  ],
  &quot;City name 2&quot;: [
    &quot;meetup group name 1&quot;,
    ...
  ]
}
</code></pre>
<h2 id="getting-data-about-meetup-events">Getting data about meetup events</h2>
<p>Once you have this, you can use the <a href="https://github.com/CleverCloud/meetups-elastic-import">node.js application we created</a>. Of course it has the Elasticsearch dependency in package.json. You are strongly invited to check out the source code at this point. You can see in the index.js many parts of interest:</p>
<ul>
<li>The creation of an express server listening on port 8080. We need it, so Clever Cloud will know our app is up running.</li>
</ul>
<pre><code class="language-javascript">app.get(&#39;/&#39;, (req, res) =&gt; {
    res.send(&#39;Hello !&#39;);
});
app.listen(8080, () =&gt; console.log(&#39;Listening on port 8080!&#39;)); 
</code></pre>
<ul>
<li>The meetup API call:</li>
</ul>
<pre><code class="language-javascript">axios.get(`https://api.meetup.com/${meetupName}/events/?status=past,upcoming\&amp;fields=comment_count`)
</code></pre>
<ul>
<li>the creation of Elasticsearch indexes:</li>
</ul>
<pre><code class="language-javascript">await client.indices.create({
  index: &quot;meetup&quot;,
  body : {
    &quot;mappings&quot;: {
      &quot;properties&quot;: {
        &quot;time&quot;:  {&quot;type&quot;: &quot;date&quot;, &quot;format&quot;: &quot;epoch_millis&quot;},
        &quot;group.name&quot;: {&quot;type&quot;: &quot;keyword&quot;},
        &quot;yes_rsvp_count&quot; : {&quot;type&quot;: &quot;integer&quot;},
        &quot;grouploc&quot;: {&quot;type&quot;: &quot;geo_point&quot;},
        &quot;venueloc&quot;:{&quot;type&quot;: &quot;geo_point&quot;}
      }
    }
  }
});
</code></pre>
<ul>
<li>The creation of another server where our meetup API calls happen, listening on port 8081. We can also notice that we&#39;ve restricted our server to allow only localhost connections.</li>
</ul>
<pre><code class="language-javascript">localapp.listen(8081, &#39;localhost&#39;, function() {
  console.log(&quot;... port %d in %s mode&quot;, 8081, localapp.settings.env);
</code></pre>
<p>Now in <code>./clevercloud/cron.json</code> you can notice a cron task, wich will trigger a curl on <code>http://localhost:8081/</code> every night at 1 AM:</p>
<pre><code class="language-json">&quot;0 1 * * * /usr/host/bin/curl http://localhost:8081/&quot;
</code></pre>
<p>It is this cron that will call our second server to trigger the meetup API calls.</p>
<p>True fact: to use it in its current version, you must keep your application running all the time for one hour of usage maximum. A way to improve the application regarding this issue would be to implement authentication to our application, so we still are the only one having access.</p>
<p>Then remove the cron from this project to have it running in your main application instead. Your main application will be the one consuming this indexed data. Taking advantage on the fact that every virtual machine running on Clever Cloud already has the Clever Tools CLI installed, we could improve our cron to start the application for an hour then stop it when it has finished its indexation job.</p>
<p>So you will end up with two machines, one with your main application, and the second one running for one hour each night.</p>
<p>We must also know that Clever Cloud does not monitor what&#39;s going on on port 8081. You could add a logging system or use Elastic APM to monitor your application during its execution time.</p>
<p>This is an approach among many others, do not hesitate to talk with us about your own implementation.</p>
<p>Okay, let&#39;s go back to our main goal, and to do so, you can use our sample data meetup list or use your own by replacing the json in the <code>meetups.json</code>file.</p>
<h2 id="try-it-out">Try it out</h2>
<p>You can <code>$ git clone</code> the repo in your console, and go into your Clever Cloud console.</p>
<p>Under the organization of your choice, select <strong>New</strong>, <strong>Application</strong>, <strong>Node</strong>. When prompted if you need add-ons, select <strong>Elastic Stack</strong>, select the plan you need and <strong>enable Kibana</strong> as an option.</p>
<p>In the environment variables menu of your application, add <code>NODE_ENV=production</code> and add the provided <code>clever remote</code> to your local git folder. Then push using <code>git push -u clever master</code>.</p>
<p>Your deployment will start and thanks to the <code>ES_ADDON_URI</code> we provided in our index.js file, we have nothing else to configure, our application will start sending data to elastic.</p>
<h2 id="visualize-your-data-and-go-further">Visualize your data and go further</h2>
<p>Either in your Kibana or Elastic instance menu in the Clever Cloud console, in the information page you will find a <strong>Open Kibana</strong> button. Click it and login using your Clever Cloud credentials.</p>
<p>Into Kibana click on the <strong>Management</strong> (gear) icon in the left side menu. Under the Kibana title, select <strong>Index Patterns</strong>, then <strong>meetup*</strong> to see how the data is indexed.</p>
<figure style="position:relative;width:50%;height:auto;margin:0 auto">
  <img data-action="zoom"  alt="index of meetups in Kibana" src="https://cdn.clever-cloud.com/uploads/2021/08/kibana-meetups.png"/>
</figure>

<p>Of course at this point, you are able to do the exact same as I did in the previous article <a href="https://www.loom.com/share/e36ce43a8d104984bba96cde3c67d714">video</a>.</p>
<p>Here is the ElasticSQL query I used in the Canvas demonstration:</p>
<pre><code class="language-sql">SELECT AVG(&quot;yes_rsvp_count&quot;) AS average, &quot;group.name&quot; FROM &quot;meetup*&quot;
GROUP BY &quot;group.name&quot;
ORDER BY average DESC
LIMIT 5
</code></pre>
<p>Happy indexing!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to deploy The Lounge, an IRC client and logger</title>
		<link>https://www.clever.cloud/blog/features/2019/04/23/thelounge-irc/</link>
		
		<dc:creator><![CDATA[Laurent Doguin]]></dc:creator>
		<pubDate>Tue, 23 Apr 2019 16:35:00 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[yarn]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2019/04/23/thelounge-irc/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="the lounge irc 1" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1-1368x528.jpg 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p><p>Yesterday I started talking with a partner on how we would collaborate. I just wanted an IM so I invited them on our Gitter and Slack. But they don&#39;t use any of these solutions. They use IRC. Which is great but then I did not have any logger or private server around. And being most of the time on the go, I have no stable connection. I need this logger. So I deployed one on Clever Cloud. This is how I did it.</p>
<span id="more-2957"></span>

<h2 id="how-to-deploy-the-lounge">How to deploy The Lounge</h2>
<p>Googling my way through a nice solution called <a href="https://thelounge.chat/">The Lounge</a>. It&#39;s in their word:</p>
<blockquote>
<p>“The self-hosted web IRC client.<br>Always connected.”</p>
</blockquote>
<p>So it allows me to connect to a server, and can act as a logger too. And it works on mobile as a PWA. Always a nice plus. It&#39;s written in JavaScript and uses SQLLite for persistence. In Clever Cloud terms, it means I will need a Node.JS runtime to run the server and an FS-Bucket addon to store files. Here&#39;s how I have deployed everything.</p>
<pre><code class="language-bash">git clone https://github.com/thelounge/thelounge.git
cd thelounge
clever create --type node thelounge
clever env set NODE_ENV production
clever addon create fs-bucket --plan s fsLounge
clever service link-addon fsLounge
clever env set THELOUNGE_HOME /app/home/
clever env set CC_FS_BUCKET /home:bucket-84d43724-d8ff-44a3-a4d9-053c45c3a5e4-fsbucket.services.clever-cloud.com
clever env set CC_PRE_RUN_HOOK &#39;yarn build &amp;&amp; cp ./config.js /app/home/config.js&#39;
clever env set NODE_BUILD_TOOL yarn
</code></pre>
<p>To configure it you can copy the default configuration in the home directory. First I have copied the default conf at the project root: <code>cp defaults/config.js ./config.js</code></p>
<p>I then edited <code>./config.js</code> to change the port to <em>8080</em>. If you look at the CC_PRE_RUN_HOOK variable you can see the file will be copied in the home directory define in the environment variable THELOUNGE_HOME. Do not forget to commit your changes!</p>
<p>If you want to know exactly what you can configure you can take a look at their <a href="https://thelounge.chat/docs/configuration">documentation</a>. </p>
<p>Now we should be all good to go so one last command and The Lounge will be online: <code>clever deploy</code></p>
<p>From now on you should see the deployment logs. Once it&#39;s over and you see success, type <code>clever open</code> and it will open the Lounge in your default web brower.</p>
<p>If you haven&#39;t change the default config you should be prompted with a Login screen. We do have to create a user. To do so they have a CLI tool. Or you can configure an LDAP server or another supported user directory. We will use the CLI tool. Fastest way to do this is to ssh to your instance by typing <code>clever ssh</code>.</p>
<p>From there you can cd into the directory of the application and type <code>node index list</code> to see the current users. As expected there are none. So go ahead and type <code>node index add username</code>. You will be prompted for a password. The user will be created and now you can login :) Here is my terminal output for these operations:</p>
<pre><code class="language-bash">bas@35e83ff3-f546-4c93-8c1d-c564d6f8673f ~ $ cd app_1ae60928-cb87-4c73-8e74-44ffd7b6e49a/
bas@35e83ff3-f546-4c93-8c1d-c564d6f8673f ~/app_1ae60928-cb87-4c73-8e74-44ffd7b6e49a $ node index list
2019-01-16 16:24:48 [INFO] There are currently no users. Create one with thelounge add &lt;name&gt;.
bas@35e83ff3-f546-4c93-8c1d-c564d6f8673f ~/app_1ae60928-cb87-4c73-8e74-44ffd7b6e49a $ node index add ldoguin
2019-01-16 16:24:52 [PROMPT] Enter password: 
2019-01-16 16:24:56 [PROMPT] Save logs to disk? (yes) 
2019-01-16 16:24:58 [INFO] User ldoguin created.
2019-01-16 16:24:58 [INFO] User file located at /app/home/users/ldoguin.json.
</code></pre>
<p>And that&#39;s it now you have your own IRC client, always online, that works on mobile and support push notifications. If you want to go further you can add your own domain name and you will have automatic SSL support thanks to our Let&#39;s encrypt automatic integration. You can also spend some time on TheLounge website and look at the different themes you can install or how to change the CSS. Happy Hacking!</p>
]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="the lounge irc 1" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/08/the-lounge-irc-1-1368x528.jpg 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p><p>Yesterday I started talking with a partner on how we would collaborate. I just wanted an IM so I invited them on our Gitter and Slack. But they don&#39;t use any of these solutions. They use IRC. Which is great but then I did not have any logger or private server around. And being most of the time on the go, I have no stable connection. I need this logger. So I deployed one on Clever Cloud. This is how I did it.</p>
<span id="more-2957"></span>

<h2 id="how-to-deploy-the-lounge">How to deploy The Lounge</h2>
<p>Googling my way through a nice solution called <a href="https://thelounge.chat/">The Lounge</a>. It&#39;s in their word:</p>
<blockquote>
<p>“The self-hosted web IRC client.<br>Always connected.”</p>
</blockquote>
<p>So it allows me to connect to a server, and can act as a logger too. And it works on mobile as a PWA. Always a nice plus. It&#39;s written in JavaScript and uses SQLLite for persistence. In Clever Cloud terms, it means I will need a Node.JS runtime to run the server and an FS-Bucket addon to store files. Here&#39;s how I have deployed everything.</p>
<pre><code class="language-bash">git clone https://github.com/thelounge/thelounge.git
cd thelounge
clever create --type node thelounge
clever env set NODE_ENV production
clever addon create fs-bucket --plan s fsLounge
clever service link-addon fsLounge
clever env set THELOUNGE_HOME /app/home/
clever env set CC_FS_BUCKET /home:bucket-84d43724-d8ff-44a3-a4d9-053c45c3a5e4-fsbucket.services.clever-cloud.com
clever env set CC_PRE_RUN_HOOK &#39;yarn build &amp;&amp; cp ./config.js /app/home/config.js&#39;
clever env set NODE_BUILD_TOOL yarn
</code></pre>
<p>To configure it you can copy the default configuration in the home directory. First I have copied the default conf at the project root: <code>cp defaults/config.js ./config.js</code></p>
<p>I then edited <code>./config.js</code> to change the port to <em>8080</em>. If you look at the CC_PRE_RUN_HOOK variable you can see the file will be copied in the home directory define in the environment variable THELOUNGE_HOME. Do not forget to commit your changes!</p>
<p>If you want to know exactly what you can configure you can take a look at their <a href="https://thelounge.chat/docs/configuration">documentation</a>. </p>
<p>Now we should be all good to go so one last command and The Lounge will be online: <code>clever deploy</code></p>
<p>From now on you should see the deployment logs. Once it&#39;s over and you see success, type <code>clever open</code> and it will open the Lounge in your default web brower.</p>
<p>If you haven&#39;t change the default config you should be prompted with a Login screen. We do have to create a user. To do so they have a CLI tool. Or you can configure an LDAP server or another supported user directory. We will use the CLI tool. Fastest way to do this is to ssh to your instance by typing <code>clever ssh</code>.</p>
<p>From there you can cd into the directory of the application and type <code>node index list</code> to see the current users. As expected there are none. So go ahead and type <code>node index add username</code>. You will be prompted for a password. The user will be created and now you can login :) Here is my terminal output for these operations:</p>
<pre><code class="language-bash">bas@35e83ff3-f546-4c93-8c1d-c564d6f8673f ~ $ cd app_1ae60928-cb87-4c73-8e74-44ffd7b6e49a/
bas@35e83ff3-f546-4c93-8c1d-c564d6f8673f ~/app_1ae60928-cb87-4c73-8e74-44ffd7b6e49a $ node index list
2019-01-16 16:24:48 [INFO] There are currently no users. Create one with thelounge add &lt;name&gt;.
bas@35e83ff3-f546-4c93-8c1d-c564d6f8673f ~/app_1ae60928-cb87-4c73-8e74-44ffd7b6e49a $ node index add ldoguin
2019-01-16 16:24:52 [PROMPT] Enter password: 
2019-01-16 16:24:56 [PROMPT] Save logs to disk? (yes) 
2019-01-16 16:24:58 [INFO] User ldoguin created.
2019-01-16 16:24:58 [INFO] User file located at /app/home/users/ldoguin.json.
</code></pre>
<p>And that&#39;s it now you have your own IRC client, always online, that works on mobile and support push notifications. If you want to go further you can add your own domain name and you will have automatic SSL support thanks to our Let&#39;s encrypt automatic integration. You can also spend some time on TheLounge website and look at the different themes you can install or how to change the CSS. Happy Hacking!</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
