<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nicolas Dommanget on Medium]]></title>
        <description><![CDATA[Stories by Nicolas Dommanget on Medium]]></description>
        <link>https://medium.com/@nicolas-dmg?source=rss-b51c959f7c81------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8ew9CP_FyQXPDGiqR0YBzQ.jpeg</url>
            <title>Stories by Nicolas Dommanget on Medium</title>
            <link>https://medium.com/@nicolas-dmg?source=rss-b51c959f7c81------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:20:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicolas-dmg/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Start to Finish: Integrating Strava API in Next.js]]></title>
            <link>https://nicolas-dmg.medium.com/from-start-to-finish-integrating-strava-api-in-next-js-d08474ff69b7?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/d08474ff69b7</guid>
            <category><![CDATA[strava]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 10:53:03 GMT</pubDate>
            <atom:updated>2023-10-13T10:53:03.756Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbYfQ3a4NFFYUKParGx7aw.jpeg" /><figcaption>From Start to Finish: Integrating Strava API in Next.js</figcaption></figure><p>Recently, I saw a tweet with a dude asking if the contributors graph that we have on Github/Gitlab was existing for workouts. So it gave me the idea to try what is possible with Strava. (Spoiler: I did it — <a href="https://stravastreaks.nicolas-dmg.fr/">Here</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d6ABf4rHOuwK0nf2NOs9Vg.jpeg" /></figure><h3>Little introduction</h3><p>As you can guess, I took some time to play with the <a href="https://developers.strava.com/">Strava API</a>. And today, I will share how I made it work with Next.js (my favorite React.js Framework).</p><p>To start this article, I used my Next.js boilerplate which I’ve emptied a bit. If you want to start</p><pre>git clone git@gitlab.com:dommangetnicolas/nextjs-strava.git<br>cd nextjs-strava<br>git reset --hard c6a426799de2655604593381b3cae75d20abedbe</pre><p>Now that we are set, we can install dependencies:</p><pre>npm i</pre><h3>Authenticating with Strava</h3><p>First things first, we will make our users able to authenticate with their Strava account.</p><p>We will start by adding <strong>sign-in </strong>and <strong>sign-out </strong>buttons inside <em>src/pages/index.tsx</em>:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2Fm3PCA0R6tjk3VxEaQnGE%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2Fm3PCA0R6tjk3VxEaQnGE&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7ee9ab3fa7f48fa5f4d7693a5d8f5cd/href">https://medium.com/media/e7ee9ab3fa7f48fa5f4d7693a5d8f5cd/href</a></iframe><h4>Obtain your Strava API Keys</h4><p>In order to continue, we will need your developer’s API Keys. You can find them here: <a href="https://www.strava.com/settings/api">https://www.strava.com/settings/api</a></p><p>Copy your <strong>client_id</strong>, <strong>client_secret </strong>inside the environment variables file (.env.development.local):</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FDFYBNiDUQKtICYibTPL4%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FDFYBNiDUQKtICYibTPL4&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/225a4e75acc9a28c930adbaeb31a6c90/href">https://medium.com/media/225a4e75acc9a28c930adbaeb31a6c90/href</a></iframe><blockquote>We will talk later about NEXT_PUBLIC_STRAVA_REDIRECT_URI</blockquote><h4>How is OAuth working with Strava?</h4><p>You can find detailed information about the Strava OAuth System <a href="https://developers.strava.com/docs/authentication/">here</a>. But I’ll quickly explain to you how it is working and show you how we are going to implement it.</p><ol><li>First, we will redirect our user to a Strava “Authorization page”. In query params, we will provide our <strong>client_id</strong> and <strong>redirect_uri</strong>. The redirect URL is required to allow Strava to redirect to the right place on our app.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*1TPSEVvhg_GC1uBXhM6QFQ@2x.png" /><figcaption>Strava Auth page</figcaption></figure><p>2. Once Strava has redirected the user to our app accompanied by a code, we will send it to our back-end.</p><p>3. Our back-end will request an access token to the Strava API by passing the code we received coupled with our client_secret and client_id.</p><p>4. After that, we’ll store the access_token in our db (A JSON file in the case of this article).</p><h4>Redirecting the user to Strava</h4><p>In this step, we will implement the “Sign in with Strava” button. I’ll create a simple function under <em>src/modules/auth/functions/getStravaAuthUrl.ts</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FsPEe5eWbC8DNJorOMyHf%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FsPEe5eWbC8DNJorOMyHf&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fapi%2Fimage%2FsPEe5eWbC8DNJorOMyHf&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d09f1c696333a8d2cf0b601a75a7e681/href">https://medium.com/media/d09f1c696333a8d2cf0b601a75a7e681/href</a></iframe><p>This little function gives us the redirect URL based on our environment variables. You can now set <em>NEXT_PUBLIC_STRAVA_REDIRECT_URI </em>as follow:</p><pre>NEXT_PUBLIC_STRAVA_REDIRECT_URI=&lt;base_app_url&gt;/auth/strava</pre><p>You can update <em>src/pages/index.tsx </em>signin button like this:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FmXVOoQHC1Z64AEjpkTeJ%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FmXVOoQHC1Z64AEjpkTeJ&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/60883de8402c907bc3080210775470a9/href">https://medium.com/media/60883de8402c907bc3080210775470a9/href</a></iframe><h4>Handling the callback from Strava</h4><p>While redirecting to Strava auth page, we told it to redirect to <em>/auth/strava</em>. We now need a page to handle this callback. You can find an example below: (<em>src/auth/strava.tsx)</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FW0giIH4S3Id24BMI3OOO%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FW0giIH4S3Id24BMI3OOO&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/febc17da0b4d4e472ef114e597b6eba2/href">https://medium.com/media/febc17da0b4d4e472ef114e597b6eba2/href</a></iframe><p>In the sign-in callback, we are reading the Strava code from query parameters. Once we get the code, we send it to our back-end (which will be implemented just after).</p><p>The back-end route that we need to create under <em>src/pages/api/auth/strava.ts </em>will handle the code received by Strava.</p><ul><li>We will call the Oauth route of Strava to get a user access token.</li><li>Save this authToken in db</li><li>Create our own JWT token and set it as a cookie</li></ul><p>I am saving the Strava auth_token in db and not directly in cookies because I want to keep control of it and not share it with the client.</p><p>Our API route looks like this:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2F4FvF6nlBHCZ1AJ4kjFrE%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F4FvF6nlBHCZ1AJ4kjFrE&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebdfdedd09964794a67018fef0a645a5/href">https://medium.com/media/ebdfdedd09964794a67018fef0a645a5/href</a></iframe><h3>Creating a simple User Dashboard</h3><p>Now our awesome users can access our app using their Strava account. We can get their activities by calling the Strava API with the saved Auth Token.</p><p>We’ll quickly create a new API Route under <em>src/pages/api/activities.ts </em>as below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FzotwKVVhqnLNnNWeIdgs%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FzotwKVVhqnLNnNWeIdgs&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/46630354761d0fabda904c5349c43f1e/href">https://medium.com/media/46630354761d0fabda904c5349c43f1e/href</a></iframe><p>Here we are getting our JWT token from the cookies in order to retrieve the access_token from the database. Then we just have to call Strava with this access_token to fetch the athlete activities.</p><h4>A simple list of activities</h4><p>We’ll create a simple list of activities as follow:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FoyuYFdxrBXahe8ufA2nX%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FoyuYFdxrBXahe8ufA2nX&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/615b12ae122f55f519f15437a80641c7/href">https://medium.com/media/615b12ae122f55f519f15437a80641c7/href</a></iframe><h3>Wrap up</h3><p>We are now able to use Strava to authenticate our users and fetch their data. We can do much more with the <a href="https://stravastreaks.nicolas-dmg.fr/">Strava API</a>.</p><p>Access the Gitlab repo <a href="https://gitlab.com/dommangetnicolas/nextjs-strava">here</a>.</p><p><strong>You can find my other articles and follow me </strong><a href="http://go.nicolas-dmg.fr/blog"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://nicolas-dmg.medium.com/why-you-should-use-alternatives-to-google-analytics-62991999ecf3">Why you should use alternatives to Google Analytics</a></li><li><a href="https://nicolas-dmg.medium.com/delete-your-old-gitlab-ci-pipelines-2bac04623edc">Delete your old GitLab CI pipelines</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d08474ff69b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should use alternatives to Google Analytics]]></title>
            <link>https://nicolas-dmg.medium.com/why-you-should-use-alternatives-to-google-analytics-62991999ecf3?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/62991999ecf3</guid>
            <category><![CDATA[analytics-tool]]></category>
            <category><![CDATA[google-analytics]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[web-analytics]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Thu, 12 Jan 2023 17:05:03 GMT</pubDate>
            <atom:updated>2023-10-14T17:01:58.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtqqbyiqCTybi4zyd-W4Kg.jpeg" /><figcaption>Alternatives to Google Analytics</figcaption></figure><p>One of the aspects of creating a solution on the internet is analyzing its traffic and visitor behavior.</p><p>Google Analytics is the most popular tool in this ecosystem. It is so big that we can think that it is alone. But we would be wrong to think that. In this article, we will discover that other solutions exist and they are doing a great job.</p><h3>Why would we use an alternative?</h3><p>Google Analytics is an excellent tool with many advantages. But it also comes with its share of disadvantages.</p><h4>Data sampling</h4><p>Google is getting a loooot of data from millions of websites. So they get a lot of data to process. To reduce this volume, they are doing data sampling.</p><p>To translate, they only use a sample of each website to realize their analytics.</p><h4>Learning curve</h4><p>If you never have used this tool, it can be challenging to get to the heart of the matter as there is a lot to learn.</p><p>If it is not your principal job, you may not have the time to learn the tool to use it efficiently.</p><h4>Forget EU</h4><p>Your website may be based in the European Union or operating inside her so you will have to complain to the GDPR (<a href="https://gdpr.eu/">General Data Protection Regulation</a>).</p><p>Unfortunately, it is hard to make the Google Analytics setup in compliance with GDPR.</p><h3>What are the alternatives?</h3><p>In 2023, every solution has its alternatives. They are not always as good as the initial solution but we will discover a few of them.</p><h4><a href="https://plausible.io/">Plausible</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*II3XIYCgWZSIo8GE.png" /><figcaption>Plausible dashboard</figcaption></figure><p>Their website describes Plausible as a “Simple and privacy-friendly Google Analytics alternative”. Personally, I am using it because it is <strong>a light tool</strong> and it is <strong>compliant with GDPR</strong>.</p><p>Plausible is also <a href="https://github.com/plausible/analytics/">open source</a> and self-hostable on your server (They also provide hosting plans).</p><h4><a href="https://matomo.org/">Matomo</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rF1XiueQT8p_m1OT.png" /><figcaption>Matomo dashboard</figcaption></figure><p>Matomo is also a GDRP-friendly alternative to Google Analytics. It allows importing data from Google Analytics so the migration is made easier.</p><p>It is a simple-to-use solution. They are developing it in open source.</p><h3>Wrap up</h3><p>We didn’t list every solution here but you are now aware that other solutions exist and why you should change for them instead of Google Analytics.</p><p><strong>You can find my other articles and follow me </strong><a href="http://go.nicolas-dmg.fr/blog"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Automate your React Native App with Fastlane</a></li><li><a href="https://yaardstudio.medium.com/make-your-blog-using-next-js-ghost-615dd3429354">Make your blog using Next.js &amp; Ghost</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62991999ecf3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Which CMS to choose for your blog]]></title>
            <link>https://nicolas-dmg.medium.com/which-cms-to-choose-for-your-blog-c18182ccfed3?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/c18182ccfed3</guid>
            <category><![CDATA[storyblok]]></category>
            <category><![CDATA[ghost-cms]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[blog]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Thu, 05 Jan 2023 12:01:43 GMT</pubDate>
            <atom:updated>2023-10-15T07:47:14.422Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a blog is a challenge. Don’t bother choosing a technical solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTUX7WqCBYoDC8OsVGxDhw.jpeg" /><figcaption>Which CMS to choose for your blog</figcaption></figure><p>You have finally decided to create THAT blog. You already know what it will be about, but you don’t know how to make it. This article will talk about the leading solutions, compare them, and find the best one for your needs.</p><h3>What is a CMS?</h3><p><strong>CMS </strong>stands for “content management system”. It is a solution that allows you to create, edit, and organize content. In most cases, the CMS provides you with a web interface to manage the content. This web interface is linked to a server that stores all the content you create. When a visitor comes to your website, the server will directly serve the page with the requested content.</p><p>Regular CMSs<strong> </strong>have an interface to develop and design your website/blog. You can choose your theme, and colors and change things as you want.</p><p>A <strong>headless CMS </strong>is a kind of CMS that allows you to create and edit content like a regular one but doesn’t embed a front end (the part that is shown to your client). You will ask me why would we use a solution without the interface for your visitors. In fact, you will have a front end for your visitors but not provided by your CMS. A headless CMS allows you to plug a custom front end directly into the content server.</p><p>Having a headless CMS allows you to create as many front ends as you want and connect them with the CMS. It also makes it possible to create a fully customized front end.</p><h3>Leading CMS</h3><h4>WordPress</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DchPxeuzWRkDeefdiTS3tw.jpeg" /></figure><p>There is a good chance that you thought about WordPress. WordPress has been one of the most popular CMS for many years. It is a self-hosted (run it on your server) solution that can excel in many domains: Landing Pages, eCommerce stores (WooCommerce), and Blogs, …</p><p><strong>Pros of using WordPress:</strong></p><ul><li>It is an open-source solution with a big community</li><li>Has a lot of awesome plugins (thanks to the community)</li><li>Easy to learn</li></ul><p><strong>Cons of using WordPress:</strong></p><ul><li>Updates and performance: Hard to maintain up to date. Too many plugins can make it slow 🐌</li><li>Vulnerability: Victim of its success, it is the favorite target of attacks. Being open-source makes it even more vulnerable.</li></ul><h4>Ghost</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3Rzx8dv620Ni35yn.png" /></figure><p>Ghost is younger than WordPress (Released in 2013). It is a much more sober solution working with essential features (Articles, Pages, Tags, Members).</p><p>Ghost is also an open-source solution and receives a lot of regular updates. This makes it a very good solution to manage your content. Both as a CMS and as a headless CMS.</p><p><strong>Pros of using Ghost:</strong></p><ul><li>Good performance</li><li>SEO Friendly</li><li>Really easy to use</li></ul><p><strong>Cons of using Ghost:</strong></p><ul><li>Its sobriety can make it limited</li><li>Small community</li><li>Not enough integrations</li></ul><h4>Storyblok</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*vim2zGH5I7sU-cdw" /></figure><p>Storyblok is a headless CMS oriented for developers. It is a fast-growing solution that allows you to create a simple website, a blog, a web application…</p><p>Their solution allows you to focus on your content and use it on a mobile application, a website, …</p><p><strong>Pros of using Storyblok:</strong></p><ul><li>Easy to use</li><li>Developer-oriented with a great API</li></ul><p><strong>Cons of using Storyblok:</strong></p><ul><li>Young ecosystem</li><li>Migration from other CMS can be difficult</li></ul><h3>Conclusion</h3><p>We discovered what is a CMS and the leading solutions. We hope that this article helped you to make your choice. You are now ready to start your blog. Let’s write your first article ✍️</p><p><strong>You can find our other articles and follow me </strong><a href="https://go.yaardstudio.com/blog"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Automate your React Native App with Fastlane</a></li><li><a href="https://yaardstudio.medium.com/make-your-blog-using-next-js-ghost-615dd3429354">Make your blog using Next.js &amp; Ghost</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c18182ccfed3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your blog using Next.js & Ghost]]></title>
            <link>https://nicolas-dmg.medium.com/make-your-blog-using-next-js-ghost-615dd3429354?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/615dd3429354</guid>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[writing]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Thu, 01 Sep 2022 10:04:21 GMT</pubDate>
            <atom:updated>2023-10-15T07:59:17.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7KvuhC5cqeBkoJZaZZexHw.jpeg" /><figcaption>Next.js &amp; Ghost CMS</figcaption></figure><p>Recently I started creating a blog using WordPress. However, as a developer, I was frustrated about not being able to customize the theme I installed easily. As a React developer, I asked myself if it was possible to use my favorite framework.</p><p>That is how I discovered headless CMS and <a href="https://ghost.org/">Ghost</a>.</p><h3>What is a headless CMS?</h3><p>CMS stands for Content Management System. It is a system that provides you with an interface to edit and manage content. This interface communicates directly with the server (where your content is stored).</p><p>However, it is possible to use a CMS without the interface. It is what we call a headless CMS, basically a server managing content.</p><p>Headless CMS allows you to create your front end and choose how it is built. It will only manage, and organize your content and serve it to your custom front end.</p><h3><strong>Ghost a soft CMS</strong></h3><p>After having discovered headless CMS, I tried to find something more contemporary and elegant than WordPress. That is how I found <a href="http://go.nicolas-dmg.fr/Fb3Qok">Ghost</a>.</p><p>Ghost is an open-source blogging platform allowing editing, management, publishing, and SEO Optimisation, …</p><p>You can self-host it as well as you can use their <a href="https://ghost.org/pricing/">offers</a>.</p><h3>What about Next.js?</h3><p>Although Ghost provides a theme installer, you may want to create your front end. As a React developer, I chose Next.js, a server-side renderer framework.</p><p>Ghost is providing a <a href="https://ghost.org/docs/content-api/javascript/">JavaScript SDK</a> usable with Next.js. We’ll see how to set up and use it.</p><h4>Setting up Ghost with Next.js</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C127%252C255%252C1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%252520GhostContentAPI%252520from%252520%252522%252540tryghost%25252Fcontent-api%252522%25253B%25250A%25250Aconst%252520ghost%252520%25253D%252520new%252520GhostContentAPI%2528%25257B%25250A%252520%252520url%25253A%252520process.env.GHOST_URL%252520%25253F%25253F%252520%252522%252522%25252C%25250A%252520%252520key%25253A%252520process.env.GHOST_KEY%252520%25253F%25253F%252520%252522%252522%25252C%25250A%252520%252520version%25253A%252520%252522v5.0%252522%25252C%25250A%25257D%2529%25253B%25250A%25250Aexport%252520default%252520ghost%25253B%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C127%25252C255%25252C1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%25252520GhostContentAPI%25252520from%25252520%25252522%25252540tryghost%2525252Fcontent-api%25252522%2525253B%2525250A%2525250Aconst%25252520ghost%25252520%2525253D%25252520new%25252520GhostContentAPI%252528%2525257B%2525250A%25252520%25252520url%2525253A%25252520process.env.GHOST_URL%25252520%2525253F%2525253F%25252520%25252522%25252522%2525252C%2525250A%25252520%25252520key%2525253A%25252520process.env.GHOST_KEY%25252520%2525253F%2525253F%25252520%25252522%25252522%2525252C%2525250A%25252520%25252520version%2525253A%25252520%25252522v5.0%25252522%2525252C%2525250A%2525257D%252529%2525253B%2525250A%2525250Aexport%25252520default%25252520ghost%2525253B%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/162b0655b120037e49acd1913656f3fa/href">https://medium.com/media/162b0655b120037e49acd1913656f3fa/href</a></iframe><p>After having installed the SDK using Yarn or NPM, you will be able to create a configuration file dedicated to Ghost. You can reuse the code above, here I am using environment variables.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C127%252C255%252C1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DGHOST_URL%25253D%25253Cyour-instance-url%25253E%25250AGHOST_KEY%25253D%25253Ckey-generated-in-your-account%25253E&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C127%25252C255%25252C1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3DGHOST_URL%2525253D%2525253Cyour-instance-url%2525253E%2525250AGHOST_KEY%2525253D%2525253Ckey-generated-in-your-account%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/61ebc1ef3f881d05fea8e01b5efc6656/href">https://medium.com/media/61ebc1ef3f881d05fea8e01b5efc6656/href</a></iframe><p>To retrieve the Ghost key, you will have to create an integration as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sag00WWq1PeTXe_rxrxWlw.gif" /></figure><h4>Fetch some posts</h4><p>Now that everything is ready it is time to retrieve some data. You can use the code below on the page you want to fetch posts:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C127%252C255%252C1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dexport%252520const%252520getStaticProps%25253A%252520GetStaticProps%25253CProps%25253E%252520%25253D%252520async%252520%2528props%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520const%252520%25257B%252520locale%252520%25253D%252520%252522%252522%252520%25257D%252520%25253D%252520props%25253B%25250A%25250A%252520%252520const%252520results%252520%25253D%252520await%252520ghost.posts.browse%2528%25257B%252520limit%25253A%252520%252522all%252522%252520%25257D%2529%25253B%25250A%25250A%252520%252520return%252520%25257B%25250A%252520%252520%252520%252520props%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252520posts%25253A%252520results%25252C%25250A%252520%252520%252520%252520%252520%252520...%2528await%252520serverSideTranslations%2528locale%2529%2529%25252C%25250A%252520%252520%252520%252520%25257D%25252C%25250A%252520%252520%25257D%25253B%25250A%25257D%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C127%25252C255%25252C1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dexport%25252520const%25252520getStaticProps%2525253A%25252520GetStaticProps%2525253CProps%2525253E%25252520%2525253D%25252520async%25252520%252528props%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520const%25252520%2525257B%25252520locale%25252520%2525253D%25252520%25252522%25252522%25252520%2525257D%25252520%2525253D%25252520props%2525253B%2525250A%2525250A%25252520%25252520const%25252520results%25252520%2525253D%25252520await%25252520ghost.posts.browse%252528%2525257B%25252520limit%2525253A%25252520%25252522all%25252522%25252520%2525257D%252529%2525253B%2525250A%2525250A%25252520%25252520return%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520props%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520posts%2525253A%25252520results%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520...%252528await%25252520serverSideTranslations%252528locale%252529%252529%2525252C%2525250A%25252520%25252520%25252520%25252520%2525257D%2525252C%2525250A%25252520%25252520%2525257D%2525253B%2525250A%2525257D%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/38da41400aba7f3287859c08e7c1bb76/href">https://medium.com/media/38da41400aba7f3287859c08e7c1bb76/href</a></iframe><p>This bunch of code will use the ghost instance we previously created, and call the browse method that will return every post. Once we get the posts, we just have to pass them through props .</p><p>The response data we got is an array containing PostOrPage objects. They are the same objects as when you fetch a single post.</p><h4>Fetch a post</h4><p>Fetching a single post will be the same as fetching a list of posts. Here is the corresponding bunch of code:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C127%252C255%252C1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dexport%252520const%252520getStaticProps%25253A%252520GetStaticProps%25253CProps%25252C%252520Params%25253E%252520%25253D%252520async%252520%2528props%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520const%252520%25257B%252520locale%252520%25253D%252520%252522%252522%25252C%252520params%252520%25257D%252520%25253D%252520props%25253B%25250A%252520%252520const%252520%25257B%252520slug%252520%25253D%252520%252522%252522%252520%25257D%252520%25253D%252520%25257B%252520...params%252520%25257D%25253B%25250A%25250A%252520%252520const%252520post%252520%25253D%252520await%252520ghost.posts.read%2528%25257B%252520slug%252520%25257D%2529%25253B%25250A%25250A%252520%252520return%252520%25257B%25250A%252520%252520%252520%252520props%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252520post%25252C%25250A%252520%252520%252520%252520%252520%252520...%2528await%252520serverSideTranslations%2528locale%2529%2529%25252C%25250A%252520%252520%252520%252520%25257D%25252C%25250A%252520%252520%25257D%25253B%25250A%25257D%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C127%25252C255%25252C1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dexport%25252520const%25252520getStaticProps%2525253A%25252520GetStaticProps%2525253CProps%2525252C%25252520Params%2525253E%25252520%2525253D%25252520async%25252520%252528props%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520const%25252520%2525257B%25252520locale%25252520%2525253D%25252520%25252522%25252522%2525252C%25252520params%25252520%2525257D%25252520%2525253D%25252520props%2525253B%2525250A%25252520%25252520const%25252520%2525257B%25252520slug%25252520%2525253D%25252520%25252522%25252522%25252520%2525257D%25252520%2525253D%25252520%2525257B%25252520...params%25252520%2525257D%2525253B%2525250A%2525250A%25252520%25252520const%25252520post%25252520%2525253D%25252520await%25252520ghost.posts.read%252528%2525257B%25252520slug%25252520%2525257D%252529%2525253B%2525250A%2525250A%25252520%25252520return%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520props%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520post%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520...%252528await%25252520serverSideTranslations%252528locale%252529%252529%2525252C%2525250A%25252520%25252520%25252520%25252520%2525257D%2525252C%2525250A%25252520%25252520%2525257D%2525253B%2525250A%2525257D%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f597a55ea4780793358e020f598ce04/href">https://medium.com/media/0f597a55ea4780793358e020f598ce04/href</a></iframe><p>The main difference is that you have to pass a slug to retrieve your post. We are retrieving it using Next.js’s getStaticPaths method:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%25280%252C127%252C255%252C1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dexport%252520const%252520getStaticPaths%25253A%252520GetStaticPaths%25253CParams%25253E%252520%25253D%252520async%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520const%252520posts%252520%25253D%252520await%252520ghost.posts.browse%2528%25257B%252520limit%25253A%252520%252522all%252522%25252C%252520fields%25253A%252520%25255B%252522slug%252522%25255D%252520%25257D%2529%25253B%25250A%25250A%252520%252520const%252520paths%252520%25253D%252520posts.map%2528%2528post%2529%252520%25253D%25253E%252520%2528%25257B%252520params%25253A%252520%25257B%252520slug%25253A%252520post.slug%252520%25257D%252520%25257D%2529%2529%25253B%25250A%25250A%252520%252520return%252520%25257B%252520paths%25252C%252520fallback%25253A%252520false%252520%25257D%25253B%25250A%25257D%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%2525280%25252C127%25252C255%25252C1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dexport%25252520const%25252520getStaticPaths%2525253A%25252520GetStaticPaths%2525253CParams%2525253E%25252520%2525253D%25252520async%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520const%25252520posts%25252520%2525253D%25252520await%25252520ghost.posts.browse%252528%2525257B%25252520limit%2525253A%25252520%25252522all%25252522%2525252C%25252520fields%2525253A%25252520%2525255B%25252522slug%25252522%2525255D%25252520%2525257D%252529%2525253B%2525250A%2525250A%25252520%25252520const%25252520paths%25252520%2525253D%25252520posts.map%252528%252528post%252529%25252520%2525253D%2525253E%25252520%252528%2525257B%25252520params%2525253A%25252520%2525257B%25252520slug%2525253A%25252520post.slug%25252520%2525257D%25252520%2525257D%252529%252529%2525253B%2525250A%2525250A%25252520%25252520return%25252520%2525257B%25252520paths%2525252C%25252520fallback%2525253A%25252520false%25252520%2525257D%2525253B%2525250A%2525257D%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ac76ff1a650c903b36f6855e8f2ba39/href">https://medium.com/media/7ac76ff1a650c903b36f6855e8f2ba39/href</a></iframe><h4>Many more features</h4><p>Reading posts is not the only feature that the Javascript SDK provides. You can find every method in the documentation <a href="https://ghost.org/docs/content-api/#endpoints">here</a>. All you have to do is use them and build your front-end around them.</p><p>I have also developed a boilerplate that you can find on <a href="https://gitlab.com/dommangetnicolas/Blog-ghost">GitLab</a>. And also a live version <a href="https://blog-ghost-five.vercel.app/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NfDKp-fTCuqz-7lC9fUsHA.png" /><figcaption>Boilerplate live version</figcaption></figure><h3>Wrap up</h3><p>We are now able to use our content created in Ghost directly into our Next.js code base. We can do much more, such as <a href="https://ghost.org/docs/hosting/">self-host a Ghost instance</a>.</p><p>GIT Repository: <a href="https://gitlab.com/dommangetnicolas/Blog-ghost">https://gitlab.com/dommangetnicolas/Blog-ghost</a></p><p>Live version: <a href="https://blog-ghost-five.vercel.app/">https://blog-ghost-five.vercel.app/</a></p><p><strong>You can find my other articles and follow me </strong><a href="http://go.nicolas-dmg.fr/blog"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Automate your React Native App with Fastlane</a></li><li><a href="https://nicolas-dmg.medium.com/delete-your-old-gitlab-ci-pipelines-2bac04623edc">Delete your old GitLab CI pipelines</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=615dd3429354" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Delete your old GitLab CI pipelines]]></title>
            <link>https://nicolas-dmg.medium.com/delete-your-old-gitlab-ci-pipelines-2bac04623edc?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bac04623edc</guid>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Mon, 31 May 2021 18:03:18 GMT</pubDate>
            <atom:updated>2021-08-10T07:03:25.876Z</atom:updated>
            <content:encoded><![CDATA[<p>No more long history of pipelines, let’s clean it all up 🧹</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2rJEwvBb7ugTJajq24BxrA.png" /><figcaption>Unsplash: <a href="https://unsplash.com/@jjying">JJ Ying</a></figcaption></figure><h3>Introduction</h3><p>Failed, passed, canceled, pending, there are a lot of chances that you have a long list of old jobs in your GitLab project.</p><p>Hopefully, GitLab provides API endpoints to list them or delete pipelines one by one. You see where I’m going with this, we will call the “list” endpoint. Save the list into an array. Then loop over the array and call the delete endpoint.</p><p>As we love automation, we will write a JS script 🤖</p><h3>Endpoints</h3><p>First, we need to read the GitLab doc to know more about these endpoints and how to call them. You can read it <a href="https://docs.gitlab.com/ee/api/pipelines.html">here</a>.</p><p>This page documents multiple features:</p><ul><li>list project pipelines</li><li>get a single pipeline</li><li>get variables of a pipeline</li><li>…</li><li>delete a pipeline</li></ul><p>We will focus on two of them, <strong>list project pipelines </strong>and <strong>delete a pipeline</strong>.</p><h3>Call the GitLab API</h3><p>As you may know; you need to be authenticated when calling the GitLab API. First, you need to create an Auth Token (<a href="https://gitlab.com/-/profile/personal_access_tokens">here</a>) with the API rights. Then, you will have to pass the token in the headers as “PRIVATE-TOKEN”.</p><p>An example with CURL:</p><pre>curl --header &quot;PRIVATE-TOKEN: &lt;your_access_token&gt;&quot; &quot;https://gitlab.example.com/api/v4/projects/1/pipelines/46&quot;</pre><p>As we want to write a JS script, we will use Axios to call the endpoint. You will have to configure your Axios instance as follow:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2Fj1uo3OvNk3FeGbvT2yni%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2Fj1uo3OvNk3FeGbvT2yni&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/50a98f5f5682bca321cfad2bd094b0d0/href">https://medium.com/media/50a98f5f5682bca321cfad2bd094b0d0/href</a></iframe><h3>List pipelines</h3><p>Now that we are able to call GitLab API, we will list the project’s pipelines.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FJXrK79q0DXCLtDnKru06%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FJXrK79q0DXCLtDnKru06&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4a68cd53e297293e7ea0813006135ce/href">https://medium.com/media/c4a68cd53e297293e7ea0813006135ce/href</a></iframe><p>This bunch of calls will get the last 100 pipelines. They will be useful in the next of the article as we will loop other them to get each pipeline id and delete them one by one.</p><h3>Delete a pipeline</h3><p>To delete a pipeline, we will operate as follow:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FuWYyWtt45r1H7V2uyWds%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FuWYyWtt45r1H7V2uyWds&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5d3df9240ad524404725477d024ebf1/href">https://medium.com/media/f5d3df9240ad524404725477d024ebf1/href</a></iframe><p>We make a delete HTTP request to the GitLab API endpoint and pass the id in the path.</p><h3>Delete all pipelines</h3><p>As we know how to get pipelines and delete a single pipeline, we are able to loop on our pipeline array and delete them one by one as follow:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FIpPtRerpK373lME6CPQO%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FIpPtRerpK373lME6CPQO&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8b343562a0aa84e1c45a16c1cf05267/href">https://medium.com/media/f8b343562a0aa84e1c45a16c1cf05267/href</a></iframe><h3>Wrap Up &amp; Bonus</h3><p>We are now able to clean the pipeline history in our GitLab projects. Here is the full code:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FsEfwt2dPJpAnXBrznxn4%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FsEfwt2dPJpAnXBrznxn4&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d07724dd96e03e97dc6726d7987754cc/href">https://medium.com/media/d07724dd96e03e97dc6726d7987754cc/href</a></iframe><p>As you can see, I have added some features. This code uses “dotenv” library to load an environment file like this:</p><pre>PROJECT_ID=20210318</pre><pre>PRIVATE_TOKEN=AAAA-BBBBBBBBBBB</pre><p>GitLab Repo: <a href="https://dmg.link/blog-pipelines-repo">https://dmg.link/blog-pipelines-repo</a>.</p><p><strong>You can find my other articles and follow me </strong><a href="https://dmg.link/blog"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Automate your React Native App with Fastlane</a></li><li><a href="https://medium.com/swlh/how-to-use-face-id-with-react-native-or-expo-134231a25fe4">How to Use Face ID With React Native or Expo</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bac04623edc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Face ID With React Native or Expo]]></title>
            <link>https://medium.com/swlh/how-to-use-face-id-with-react-native-or-expo-134231a25fe4?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/134231a25fe4</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[biometrics]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Mon, 18 Jan 2021 12:36:16 GMT</pubDate>
            <atom:updated>2021-08-10T07:02:51.405Z</atom:updated>
            <content:encoded><![CDATA[<p>Bring biometric auth to your React Native or Expo app. Let your users sign in with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*txNqfJ8UkLqk3czDsybslA.png" /><figcaption>Unsplash: <a href="https://unsplash.com/photos/atW3fbSy_9Y">Debby Hudson</a></figcaption></figure><h3>Introduction</h3><p>Like many applications, your app may have authentication. Your users might sign in with an email/password.</p><p>So once they sign in everyone using their phone can access the data inside the app. It can be a problem if your apps keep sensitive data. One solution is to re-ask the password each time the user uses the application. It is a good solution but it affects the user experience.</p><p>You may have seen that apps like banking, health, etc.. use biometric to let users continue, that is the solution we will experience in this article.</p><p>We will see both approaches:</p><ul><li>React Native</li><li>Expo</li></ul><h3>Setup</h3><p>To follow the article, you will need an Expo or a React Native app. We will create a dummy auth application as follow:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FOhrBzlwVfsGNg2Cjyp3q%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FOhrBzlwVfsGNg2Cjyp3q&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae3185667e7f0b05855460418e7025d2/href">https://medium.com/media/ae3185667e7f0b05855460418e7025d2/href</a></iframe><p>In the file above, I have created a simple button with a callback. We will implement the method in the next parts.</p><h3>Biometric with Expo</h3><p>Once you have an expo and our dummy App.tsx file, you will be able to install the expo module for Local Authentication:</p><pre>expo install expo-local-authentication</pre><p>Now, the Expo module that handles Face ID is installed. We can edit our app as follow:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2Fd85fbCZKXE4R0z09PFCX%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2Fd85fbCZKXE4R0z09PFCX&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/69008a6cd94933cf0c3fb141f148140e/href">https://medium.com/media/69008a6cd94933cf0c3fb141f148140e/href</a></iframe><p>This sample code:</p><ul><li>Check if device is compatible with biometrics methods</li><li>Check if a Face or Finger exists</li><li>And finally authenticate the user</li></ul><p>It is as simple as that. You can pass options to the authenticateAsync method, such as:</p><ul><li><strong>promptMessage: </strong>Label shown on Face ID / Touch ID.</li><li><strong>cancelLabel: </strong>Customize the cancel label.</li><li><strong>fallbackLabel: </strong>Customize the passcode label.</li><li><strong>disableDeviceFallback: </strong>Decide if after multiple tries for Face / Finger to fallback on device passcode.</li></ul><p>You can find more information about local authentication on <a href="https://docs.expo.io/versions/latest/sdk/local-authentication/">Expo docs</a>.</p><h4>Permissions</h4><p>As a lot of native modules, you may need to handle permisssions. With expo-local-authentication, you don’t really have to carry about it.</p><p>On Android, permissions are automatically added. On iOS, you will need to add “infoPlist.NSFaceIDUsageDescription” in your app.json file</p><p><strong>Permissions on Bare project</strong></p><p>For iOS, you will need to add “NSFaceIDUsageDescription” in your info.plist file.</p><p>For Android, you will need below lines in your AndroidManifest.xml:</p><pre>&lt;uses-permission android:name=&quot;android.permission.USE_BIOMETRIC&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.USE_FINGERPRINT&quot; /&gt;</pre><h3>Biometric with React Native</h3><p>On React Native, it exists a few libraries to handle Local Authentication. Such as <a href="https://www.npmjs.com/package/react-native-biometrics">react-native-biometrics</a>, <a href="https://www.npmjs.com/package/react-native-touch-id">react-native-touch-id</a>, etc..</p><p>We can also use <a href="https://www.npmjs.com/package/expo-local-authentication">expo-local-authentication</a> in our bare React Native app.</p><p>What ? The same package as Expo ? Exactly, when I have chosen a package to add Local Authentication, I found that expo-local-authentication was really good to realise the job.</p><p>But it’s an Expo Package, so it’s no compatible ? Effectively, by default some Expo packages can’t be used in a bare project. But it exists a solution provided by Expo, the Expo unimodules. <a href="https://docs.expo.io/bare/installing-unimodules/">React Native Unimodules</a> will allow you tu use Expo modules in a bare app.</p><p>How can I use it ? Expo has written a really good documentation about unimodules that you can find <a href="https://docs.expo.io/bare/installing-unimodules/">here</a>.</p><p>Once you have installed unimodules, you can implement Local Authentication the same way as for <a href="#941b">Expo</a>. 😎</p><h3>Bonus — Check if device is compatible on mount</h3><p>In the sample code below, you can see how to check if device is compatible on component mount:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FciAGF04hPXa46Ez4klce%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FciAGF04hPXa46Ez4klce&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee853d03d0a1f4de8ae740ba25ceb252/href">https://medium.com/media/ee853d03d0a1f4de8ae740ba25ceb252/href</a></iframe><p>Expo-local-authentication allows you to add Face ID / Touch ID to your React Native app.</p><p>GitLab Repo: <a href="https://dmg.link/blog-biometric-repo">dmg.link/blog-biometric-repo</a></p><p><strong>You can find my other articles and follow me </strong><a href="http://nicolas-dmg.medium.com/"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Automate your React Native App with Fastlane</a></li><li><a href="https://levelup.gitconnected.com/schedule-your-node-js-task-with-agenda-js-3dc40aab3316">Schedule your Node.js task with agenda.js 📔</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=134231a25fe4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-use-face-id-with-react-native-or-expo-134231a25fe4">How to Use Face ID With React Native or Expo</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Schedule your Node.js task with agenda.js ]]></title>
            <link>https://levelup.gitconnected.com/schedule-your-node-js-task-with-agenda-js-3dc40aab3316?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dc40aab3316</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[scheduling]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Mon, 14 Dec 2020 12:02:40 GMT</pubDate>
            <atom:updated>2021-08-10T06:59:28.610Z</atom:updated>
            <content:encoded><![CDATA[<h3>Schedule your Node.js tasks with agenda.js 📔</h3><p>Need to create recurring tasks? Execute tasks later? Agenda is what you may need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZ4BDLhnctESXufCPcEmEA.jpeg" /><figcaption>Unsplash: <a href="https://unsplash.com/@esteejanssens">Estée Janssens</a></figcaption></figure><h3>Introduction</h3><p>When building a Node.js application, you may need to execute recurring tasks or run them later. ⏰</p><p>You might know CRON jobs on Linux systems. CRON is a time-based job scheduler. It allows us to realize tasks every minute, day, months, etc.</p><p>With our Node.js app, we want to run something like CRON. But how? Hopefully it exists multiple solutions to schedule tasks on Node.js:</p><ul><li>node-schedule</li><li>node-cron</li><li>bull</li><li>agenda</li></ul><p>Today, we will take a look at Agenda. It is described as “A light-weight job scheduling library for Node.js” on <a href="https://www.npmjs.com/package/agenda">NPM</a>.</p><p>It offers features like concurrent jobs, delayed jobs, repeatable jobs, etc. powered with MongoDB.</p><p>In this article, we will create a sample App with Node.js and Agenda. 🗓</p><h3>Setup</h3><p>Before using Agenda, we need a Node.js app and a MongoDB database to store our jobs.</p><p><strong>Let’s init the app:</strong></p><pre>npm init &amp;&amp; touch app.js</pre><pre>npm install agenda</pre><p><strong>Write a bit of code and connect it to MongoDB:</strong></p><p>(If you don’t have a Mongo database, you can create a Docker container as follow)</p><pre>docker run -d -p 27017:27017 --name mongodb mongo</pre><ul><li>app.js:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C144%252C226%252C1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dconst%252520Agenda%252520%25253D%252520require%2528%2527agenda%2527%2529%25253B%25250A%25250Aconst%252520dbURL%252520%25253D%252520%2527mongodb%25253A%25252F%25252F127.0.0.1%25253A27017%25252FAgendaMedium%2527%25253B%25250A%25250Aconst%252520agenda%252520%25253D%252520new%252520Agenda%2528%25257B%25250A%252520%252520%252520%252520db%25253A%252520%25257Baddress%25253A%252520dbURL%25252C%252520collection%25253A%252520%2527Agenda%2527%25257D%25252C%25250A%252520%252520%252520%252520processEvery%25253A%252520%252720%252520seconds%2527%25252C%25250A%252520%252520%252520%252520useUnifiedTopology%25253A%252520true%25250A%25257D%2529%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C144%25252C226%25252C1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dconst%25252520Agenda%25252520%2525253D%25252520require%252528%252527agenda%252527%252529%2525253B%2525250A%2525250Aconst%25252520dbURL%25252520%2525253D%25252520%252527mongodb%2525253A%2525252F%2525252F127.0.0.1%2525253A27017%2525252FAgendaMedium%252527%2525253B%2525250A%2525250Aconst%25252520agenda%25252520%2525253D%25252520new%25252520Agenda%252528%2525257B%2525250A%25252520%25252520%25252520%25252520db%2525253A%25252520%2525257Baddress%2525253A%25252520dbURL%2525252C%25252520collection%2525253A%25252520%252527Agenda%252527%2525257D%2525252C%2525250A%25252520%25252520%25252520%25252520processEvery%2525253A%25252520%25252720%25252520seconds%252527%2525252C%2525250A%25252520%25252520%25252520%25252520useUnifiedTopology%2525253A%25252520true%2525250A%2525257D%252529%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/86ef8c5349f7ce668e2ed52a7826574a/href">https://medium.com/media/86ef8c5349f7ce668e2ed52a7826574a/href</a></iframe><p>All you need is to create an Agenda instance passing db URL and collection name.</p><p>A new collection will be created in your database.</p><h3>Create a job</h3><p>Now that we have an Agenda instance, we can create our jobs.</p><p>In this example, we will create a dummy job to log “Hello ${name}”. So in app.js, we can add:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FweeuPrd7QQzVI45IndIb%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FweeuPrd7QQzVI45IndIb&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccdfe6003c3b909858d00fe1a0f9d099/href">https://medium.com/media/ccdfe6003c3b909858d00fe1a0f9d099/href</a></iframe><p>When creating a job, you can get data in the attrs variable.</p><h3>Schedule a job</h3><p>Once we have jobs, we can run them. In this part, we will schedule the job to run in 10 minutes as follow:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FchrRXzPgreVnbxIVr9fE%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FchrRXzPgreVnbxIVr9fE&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/64c53a9de34d0356c8920b10cb645c38/href">https://medium.com/media/64c53a9de34d0356c8920b10cb645c38/href</a></iframe><p>This will create a document in our Agenda collection:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O_WTsKOLgdrfa8g9uxOS_A.png" /><figcaption>Scheduled job in MongoDB</figcaption></figure><h3>Run a job repeatedly</h3><p>Agenda allows us to run recurring jobs. For example every year. We will create a dummy job to wish a happy new year:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FF0m3nvhjvy3qazrxxHrf%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FF0m3nvhjvy3qazrxxHrf&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/500264fcce08ae4564fd8f7b485654d4/href">https://medium.com/media/500264fcce08ae4564fd8f7b485654d4/href</a></iframe><p>In this example, you can observe that I am using the CRON syntax.</p><p>Agenda helps you to plan jobs, run them later or repeatedly. You can find more information and features <a href="https://www.npmjs.com/package/agenda">here</a>.</p><p>GitLab Repo: <a href="https://dmg.link/blog-agenda-repo">dmg.link/blog-agenda-repo</a></p><p><strong>You can find my other articles and follow me </strong><a href="http://nicolas-dmg.medium.com/"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Automate your React Native App with Fastlane</a></li><li><a href="https://levelup.gitconnected.com/build-your-standalone-expo-app-locally-with-turtle-cli-87de3a487704">Build your standalone Expo App locally with Turtle CLI 🐢</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dc40aab3316" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/schedule-your-node-js-task-with-agenda-js-3dc40aab3316">Schedule your Node.js task with agenda.js 📔</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean and format your code before committing with Husky ]]></title>
            <link>https://nicolas-dmg.medium.com/clean-and-format-your-code-before-committing-with-husky-c88039b16510?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/c88039b16510</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[eslint]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Mon, 10 Aug 2020 11:01:02 GMT</pubDate>
            <atom:updated>2020-12-11T21:30:36.354Z</atom:updated>
            <content:encoded><![CDATA[<p>Husky helps to run tests on your code before committing, pushing…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXBMIFbjQUD8pVuk_Nnzcg.jpeg" /><figcaption>Unsplash: <a href="https://unsplash.com/photos/tnNVJd_nrw8">Cody Board</a></figcaption></figure><p>As a developer, you may want to keep your code clean and formatted. If you are coding in JavaScript you might be using ESLint ⚙️</p><p>ESLint helps you to format your code by applying custom rules. But if a developer of your team doesn’t lint his code, you will probably have a “dirty” code in your git repo…</p><p>…that’s when husky happens to help you.</p><p>“Husky can prevent bad git commit, git push and more 🐶 <em>woof!</em>”. It helps you to create simple <strong>git hooks</strong>. A git hook is a way to run custom scripts when a specific action occurs, example:</p><ul><li><strong>pre-commit</strong></li><li><strong>commit-msg</strong></li><li><strong>post-commit</strong></li><li><strong>post-merge</strong></li><li><strong>pre-push</strong></li><li><strong>And more</strong></li></ul><p>Let’s see how Husky will help us 😎</p><h3><strong>Setup</strong></h3><p>Husky is a simple npm package, so we can install it very easily:</p><pre>yarn add -D husky</pre><p>Here we are installing it as a development dependency.</p><p>Once the package installed, you need to edit your package.json file and add these lines (for example):</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FptfFJ36lCtqPioQMxnA7%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FptfFJ36lCtqPioQMxnA7&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1ab2a9aba5a5e7546cc7511812e6393/href">https://medium.com/media/e1ab2a9aba5a5e7546cc7511812e6393/href</a></iframe><p>These two hooks will run test scripts when committing and pushing to your server.</p><p>You can see all the git hooks <a href="https://git-scm.com/docs/githooks">here</a>.</p><h3>Usage</h3><p>There is no special action to do. Your hooks will be triggered when doing the provided actions. Such as:</p><pre>git commit -m &quot;Trigger pre-commit hook 🤓&quot;</pre><p>So you can add multiple triggers to run scrips like ESLint…</p><p>Husky will help you to run scripts when doing specific actions (e.g: Pre-commit -&gt; lint -&gt; commit; Pre-push -&gt; lint -&gt; Push.)</p><p><strong>You can find my other articles and follow me </strong><a href="https://medium.com/@nicolas_dmg"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Automate your React Native App with Fastlane</a></li><li><a href="https://levelup.gitconnected.com/build-your-standalone-expo-app-locally-with-turtle-cli-87de3a487704">Build your standalone Expo App locally with Turtle CLI 🐢</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c88039b16510" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 tips to wake up earlier ]]></title>
            <link>https://nicolas-dmg.medium.com/5-tips-to-wake-up-earlier-4254a74dcbdd?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/4254a74dcbdd</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[wake-up]]></category>
            <category><![CDATA[sleep]]></category>
            <category><![CDATA[habits]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Wed, 05 Aug 2020 16:01:02 GMT</pubDate>
            <atom:updated>2020-12-12T18:04:49.709Z</atom:updated>
            <content:encoded><![CDATA[<p>Because getting up early shouldn’t be a problem, here are 5 tips for getting up early.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u8afkkYVukdySRDc5bSnjA.jpeg" /><figcaption>Unsplash: <a href="https://unsplash.com/photos/-G3rw6Y02D0">Dawid Zawiła</a></figcaption></figure><h3>Introduction</h3><p>Did you ever think of waking up earlier to realize more things? Waking up earlier is a good idea to improve productivity as at 5 a.m there is less noise, stress and you can get more concentrated.</p><p>But you have to be able to stand up. Waking up at 5 a.m is not easy, if you aren’t used to it. You will find you any excuses or reasons to stay in bed.</p><p>I had the same problem when I tried to wake up earlier, then I’ve made a “Morning routine” and set up some habits and tips.</p><p>So today, I am going to share with you my 5 best tips to wake up earlier. ⚡️</p><h3>1. Get yourself a purpose to wake up early 🎯</h3><p>Waking up earlier is useless if you don’t have any aim. However, with a little bit of motivation, you can easily get one.</p><p>Do you do difficult things in life for no good reason? Chances are you won’t. It’s the same with the alarm clock.</p><p><strong>Why would you want to get up at this hour?</strong></p><p>There is a lot of reason to wake up early…</p><p>Example:</p><ul><li>Work on a project</li><li>Take time for yourself</li><li>Doing sport (Running, training, …)</li><li>Be quiet</li><li>Learn new things</li><li>Getting out of your comfort zone</li></ul><p>You need to find your own target. Then when you will have found it everything will go so much easier. Your goal is going to motivate you into waking you up earlier. You just have to keep it in your mind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1NmxcsVu2ZeLr3RqF4rCVw.jpeg" /><figcaption><a href="https://unsplash.com/photos/oqStl2L5oxI">Unsplash: Clark Tibbs</a></figcaption></figure><h3>2. Do something 💪</h3><p>If you wake up at 5 a.m, you need to have something to work on. Otherwise, you will fall in laziness and come back to your bed.</p><p>To counteract that, we can set up a morning routine. It will have two benefits, get busy doing something, prepare a successful day.</p><h4><strong>How to organize my morning routine?</strong></h4><p>There are a lot of different ways to organize it, so the “perfect morning routine” doesn’t exist. One piece of advice I can give you is: do what you enjoy and what prepares you for your day.</p><p>An example of a morning routine would be:</p><ul><li>Sport (Running, training, …)</li><li>Eating</li><li>Taking a shower</li><li>Relaxing (Meditate, …)</li></ul><p>As you can see, I gave only 4 steps. That’s enough, don’t try to overdo it. Otherwise, you might run out of breath and not be able to keep up the length.</p><h3>3. Get enough sleep 😴</h3><p>We might not mention this point because it makes so much sense… To get up early in good conditions, you’ll need to sleep enough. In conclusion, going to bed early.</p><p>It can be a sacrifice for your social life but if your intention is really to get up early, it’s worth it.</p><h4>What is “enough sleep”?</h4><p>First, sleeping time is not the same as bedtime. Just because you’re in bed for eight hours doesn’t mean you slept for eight hours.</p><p>For almost everyone, we need to sleep 8 hours by night. So if you want to wake up at 5 a.m, you will need to <strong>sleep </strong>at 10 p.m. As we said, bedtime isn’t sleeping time. Therefore, you need to estimate how long it takes you to fall asleep and add it to your bedtime. Example: In my case, I need 30 minutes. Thus, I am going to bed at 9.30 pm.</p><h4><strong>Avoid noises</strong></h4><p>As your brain is working every time, you need to reduce its exposition to noises (such as phone or screen) before and during your night.</p><p>Be sure to disconnect from screens an hour before sleeping. You can replace it by reading a book, relaxing, …</p><p>An important point is making you sure that you will not be disturbed while sleeping. Close your windows if your neighborhood is noisy, turn your phone on “Do not disturb” mode, …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RejBldf0U_XYp7crWsTYwA.jpeg" /><figcaption><a href="https://unsplash.com/photos/xrb1Y7As0pU">Unsplash: Coen Staal</a></figcaption></figure><h3>4. Waking up comfy 😎</h3><p>A lot of times I went back to bed because I was cold, it was messy, my day was unprepared. Waking up should not be an ordeal, so you need to ensure to get comfortable when you wake up.</p><p>To ensure to get comfy when getting, you can organize your things like setting the heat or prepare your breakfast the day before.</p><p>Avoids all frustrations, e.g. dishes from two days ago, dirty laundry, doing annoying things</p><p>By having a cozy and nice wake-up, your morning routine will be a delight to realize! 👌</p><h3>5. Let&#39;s be friend with your alarm clock! ⏰</h3><p>Before we talk about the alarm, we need to set the record straight… Your phone can’t be your alarm clock. Why? It’s a gateway to procrastination, there’s a good chance you’ll get lost in the notifications after you wake up.</p><h4>Use your phone as late as possible</h4><p>One of the goals of getting up early is to avoid noises. It will be stupid to add noises from social networks in our great routine.</p><p>So, let your phone away and use it only when you need it. Your brain will have less to worry about and you’ll save your energy for more important things.</p><h4>Choose the right alarm</h4><p>As we aren’t using our phone, we might use an alarm clock. In my case, I use a smartwatch and it works great (On the plus side, it vibrates on the wrist and only wakes you up…).</p><p>Your choice of alarm can be based on several points, if it wakes you up calmly or if you wish to be woken up suddenly. Feel free to try several.</p><h3>Conclusion</h3><p>Waking up early is a habit. You need to train and take care of it. Don’t forget the fact that it will not be easy every day, don’t be too strict or too lax.</p><p><strong>You can find my other articles and follow me </strong><a href="https://medium.com/@nicolas_dmg"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4254a74dcbdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build your standalone Expo App locally with Turtle CLI ]]></title>
            <link>https://levelup.gitconnected.com/build-your-standalone-expo-app-locally-with-turtle-cli-87de3a487704?source=rss-b51c959f7c81------2</link>
            <guid isPermaLink="false">https://medium.com/p/87de3a487704</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[expo]]></category>
            <dc:creator><![CDATA[Nicolas Dommanget]]></dc:creator>
            <pubDate>Mon, 03 Aug 2020 11:01:01 GMT</pubDate>
            <atom:updated>2021-08-10T06:56:43.643Z</atom:updated>
            <content:encoded><![CDATA[<p>Build iOS .ipa and Android .apk expo app locally by using Turtle CLI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BfKU-pYoL3zWCd8QPUI3Ng.jpeg" /><figcaption>Unsplash: <a href="https://unsplash.com/@adolfofelix">Adolfo Félix</a></figcaption></figure><h3>Introduction</h3><p>Recently, I had to build an expo app. I tried it by using <a href="https://expo.io/">expo.io</a> servers, but my build was in the queue and I didn’t have time to waste.</p><p>So I decided to see if it was possible to build an Expo app locally and I’ve found <strong>turtle-cli</strong>.</p><p><strong>What is Turtle CLI:</strong></p><p>Expo allows us to build our apps on their servers. They have built a special CLI to realize it and they Open-Sourced it. So anyone can use and contribute to Turtle CLI.</p><p>It allows us to:</p><ul><li>Build iOS</li><li>Build Android</li><li>Make continuous integration</li></ul><p>In this article, we will use it to build on both iOS and Android 🎯</p><p>You will need:</p><ul><li>An Expo app</li><li>Node.js</li><li>macOS &amp; Xcode(For iOS)</li><li>Fastlane (App automation, you can read <a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">my article about it</a>)</li></ul><h3>Setup</h3><p>First, we need to install Turtle CLI:</p><pre>yarn global add turtle-cli </pre><p>Then you can check if Turtle CLI is properly installed:</p><pre>turtle-cli -V</pre><h3>Signing the app</h3><p>Foremost, we will need to create certificates, identifiers, and provisioning profiles.</p><h4>Android</h4><p>To be able to build our Android App, we will need to create a Keystore. You can do it by running: (Replace the values by yours)</p><pre>keytool -genkeypair -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000</pre><p>Example:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FaUfPPQINu8A0rfV2CwTW%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FaUfPPQINu8A0rfV2CwTW&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d84ca469d5c33ad77560c16a15a47485/href">https://medium.com/media/d84ca469d5c33ad77560c16a15a47485/href</a></iframe><p>If all went well, you should have a new file “.keystore”.</p><h4>iOS</h4><p>To sign an Apple App, you will need an Apple developer account. There are multiple steps to get our certificate and profile.</p><p>As it is not the goal of this article, we will not see these parts but you can look at these resources:</p><ul><li><strong>APP ID: </strong><a href="https://customersupport.doubledutch.me/hc/en-us/articles/229488228-iOS-How-to-Create-an-App-ID">Quick guide</a></li><li><strong>iOS Certificate: </strong><a href="https://customersupport.doubledutch.me/hc/en-us/articles/360001189514-iOS-How-to-Create-a-Distribution-Certificate">Quick guide</a></li><li><strong>Provisioning Profile: </strong><a href="https://customersupport.doubledutch.me/hc/en-us/articles/229496268-iOS-How-to-Create-a-Provisioning-Profile">Quick guide</a></li></ul><h3>Prepare the APP for the build</h3><p>Now we will prepare our APP to be built on our own servers. First, we need to “export” the app. At the project’s root, you can execute these commands:</p><ul><li>If your server has HTTPS:</li></ul><pre>expo export --public-url &lt;YOUR_URL&gt;</pre><ul><li>On a server with only HTTP:</li></ul><pre>expo export --dev --public-url &lt;YOUR_URL&gt;</pre><p>It will create a new folder called “dist”. This folder will be used to serve the App over HTTP/(S) and build the APP.</p><h3>Serve the APP</h3><p>Once exported, we can spin up a local server to serve the APP. Go to the “dist” folder and serve the app by running this command:</p><pre>python -m http.server 8000</pre><p>I’ve also written an article about this part. It will help you to create your own server and use HTTPS: <a href="https://medium.com/@nicolas_dmg/serve-static-files-through-http-s-with-python-3-3ba4b6c5f57e">Serve static files through HTTP/(S) with Python 3</a>.</p><h3>Build for iOS</h3><p>It’s time to build our .ipa by using our fresh setup 🛠</p><h4>Small verification</h4><p>First of all, be sure to have these things ready:</p><ul><li>Xcode</li><li>Fastlane installed (<a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Quick guide</a>)</li><li>Signing keys</li></ul><p>Now, we are ready. Let’s go 🚀</p><h4>Build the .ipa</h4><p>First, don’t forget to spin up the server into the “dist” folder. Once all is ready, you can run this command:</p><pre>EXPO_IOS_DIST_P12_PASSWORD=&quot;YOUR_PASSWORD&quot; \<br>turtle build:ios \<br>  --team-id YOUR_TEAM_ID \<br>  --dist-p12-path P12_CERT_PATH \<br>  --provisioning-profile-path PROVISIONING_PROFILE_PATH \<br>  --allow-non-https-public-url \<br>  --public-url http://127.0.0.1:8000/ios-index.json</pre><p>This command will build your .ipa. If you don’t have HTTPS on your server, you can add “--allow-non-https-public-url”.</p><p>If everything is fine, you will get your “.ipa” in “/User/YOUR_USERNAME/expo-apps</p><h4>Use your .ipa</h4><p>The “.ipa” allows you to <strong>install your app </strong>and/or<strong> distribute it</strong>.</p><p><strong>Install it on a real device:</strong></p><p>By using <a href="https://apps.apple.com/us/app/apple-configurator-2/id1037126344?mt=12">Apple Configurator 2</a>, you will be able to install your app on your Apple devices. Don’t forget to build your app with an AdHoc profile otherwise, your APP may not start</p><p><strong>Distribute it:</strong></p><p>To upload your APP on App Store Connect, you may use <a href="https://apps.apple.com/us/app/transporter/id1450874784?mt=12">Transporter</a>. It allows you to send your version directly to TestFlight.</p><p>Our app is ready to use on Apple devices 🍏</p><h3>Build for Android</h3><p>As we want to have our APP on both platforms, we need to build the Android versions.</p><h4>Small verification</h4><p>One more time, we need to verify a few things:</p><ul><li>Be sure to have <a href="https://jdk.java.net/java-se-ri/8-MR3">Java JDK 8</a></li><li>Check that the expo server is still up</li></ul><p>Let’s go to android 🚀</p><h4>Build the APK</h4><p>As with iOS, we need to execute a command (Be patient, the build can be long):</p><pre>EXPO_ANDROID_KEYSTORE_PASSWORD=&quot;YOUR_KEYSTORE_PWD&quot; \<br>EXPO_ANDROID_KEY_PASSWORD=&quot;YOUR_KEY_PWD&quot; \<br>turtle build:android \<br>  --type apk \<br>  --keystore-path KEYSTORE_PATH \<br>  --keystore-alias &quot;KEY_ALIAS&quot; \<br>  --allow-non-https-public-url \<br>  --public-url http://127.0.0.1:8000/android-index.json</pre><p>This command is quite the same as for iOS and should give you a fresh APK file.</p><h4>Use your APK</h4><p>Our APK is ready, we can use it in different ways:</p><ul><li>Share the file and install it directly on an Android device</li><li>Use adb to install it through USB</li><li>Upload it on Google Play Console</li></ul><p>Now, you are able to build an Expo app locally. You will save a lot of time as you will not be queued on expo.io servers.</p><p>If you don’t have disabled OTA (Over The Air updates), you need to let your server up and accessible from the web (the one that serves the dist folder).</p><p><strong>You can find my other articles and follow me </strong><a href="https://medium.com/@nicolas_dmg"><strong>here</strong></a><strong>. Thanks for reading, I hope you learned something new today 🚀</strong></p><ul><li><a href="https://levelup.gitconnected.com/automate-your-react-native-app-with-fastlane-ea516b4a893">Automate your React Native App with Fastlane</a></li><li><a href="https://medium.com/@nicolas_dmg/serve-static-files-through-http-s-with-python-3-3ba4b6c5f57e">Serve static files through HTTP/(S) with Python 3</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87de3a487704" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/build-your-standalone-expo-app-locally-with-turtle-cli-87de3a487704">Build your standalone Expo App locally with Turtle CLI 🐢</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>