<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Christopher Wavrin</title>
    <description>The latest articles on DEV Community by Christopher Wavrin (@wavrin).</description>
    <link>https://dev.to/wavrin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F331896%2Fc5905f71-75b5-4923-82bb-2d0cf75fca68.jpeg</url>
      <title>DEV Community: Christopher Wavrin</title>
      <link>https://dev.to/wavrin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wavrin"/>
    <language>en</language>
    <item>
      <title>Legacy system serverless implementation</title>
      <dc:creator>Christopher Wavrin</dc:creator>
      <pubDate>Tue, 05 Mar 2024 02:06:05 +0000</pubDate>
      <link>https://dev.to/wavrin/legacy-system-serverless-implementation-1af</link>
      <guid>https://dev.to/wavrin/legacy-system-serverless-implementation-1af</guid>
      <description>&lt;p&gt;I was recently on a project here at &lt;a href="https://www.lineate.com/"&gt;Lineate&lt;/a&gt; with a large publisher of education material. To produce more than 1,000 titles per year they generate an enormous amount of content for a series of Web sites and needed a fully functional content management tool that was available at all times. However, some of their websites publish only one or two times each year, so this complicated system was wasting their resources and time. We streamlined the tool by migrating the legacy Python content management application to pure AWS lambda functions. As a result, we simplified maintenance, eliminated the need for constant security patching of servers, freed up the time of both developers and systems engineers, and significantly reduced their hosting costs.&lt;/p&gt;

&lt;p&gt;Previously, the application servers were running a small Python 2.x program that was used exclusively for content uploading and editing. The server resources needed for this application were not insignificant due to the nature of the editing workflow. New content was uploaded in bulk, so the servers had to have enough CPU and memory to handle these events without affecting the program’s performance.&lt;/p&gt;

&lt;p&gt;Because they rarely used the content management tool, both development and maintenance of the application became unnecessary. We knew that we could leverage a modern serverless approach to create a simple but effective program that would better fit our client’s needs. We initiated a small project that migrated the Python 2.x application into a Python 3.x application consisting of about a dozen lambda functions (AWS lambda, to be specific). Our solution followed the common serverless approach of having each function do one thing—and one thing only.&lt;/p&gt;

&lt;p&gt;Introducing lambda functions is not without some challenges. But with so much serverless development happening in the industry, new tools are available to alleviate the complexity. For example, it can be difficult to organize lambda code and, in this case, the AWS services needed to interact with the functions. Fortunately, AWS provides the &lt;a href="https://aws.amazon.com/serverless/sam/"&gt;Serverless Application Model (SAM)&lt;/a&gt; to help build an application that clearly expresses the desired functions, defines how the functions interact with APIs and databases, and describes the infrastructure required. SAM allows developers to follow infrastructure-as-code standards by including the AWS infrastructure along with the serverless functions in a single code repository. &lt;/p&gt;

&lt;p&gt;There are alternatives to SAM. In our case, we were working with a relatively simple Python application, but larger projects may require a more robust solution. AWS offers several options, such as &lt;a href="https://aws.amazon.com/cdk/"&gt;AWS Cloud Develpment Kit (CDK)&lt;/a&gt;, which allows developers to define infrastructure using a variety of programming languages (Python, Typescript, Java, etc.). AWS describes infrastructure primarily with &lt;a href="https://aws.amazon.com/cloudformation/"&gt;AWS CloudFormation&lt;/a&gt; templates, but they are often avoided because they can become unwieldy and contain a lot of hard-to-read boilerplate. Both SAM and CDK automatically generate the necessary Cloud Formation templates under the hood.&lt;/p&gt;

&lt;p&gt;Another option is Terraform. Our team at Lineate has extensive experience using Terraform because many of our customers have large cloud infrastructures and often prefer a non-AWS-specific solution so they’ll have more options. Terraform is great even if you are only going to use AWS, but having Terraform provide your infrastructure allows for reusability in both hybrid and non-AWS-cloud services.&lt;/p&gt;

&lt;p&gt;For our work with this customer, though, we felt that SAM was perfectly suited to our needs. SAM provided a remedy to another challenge we faced in cloud development—working with code locally. SAM allows for local testing of lambda functions, so we didn’t have to do a new deployment every time we wanted to try out a function. This sped up development dramatically. Not every AWS service can be tested locally so easily, but SAM provides ways for local code to interact with parts of the infrastructure in the cloud.&lt;/p&gt;

&lt;p&gt;This project was successful on many fronts: Lineate saved our client a considerable amount of money because they no longer have to pay for rarely used resources. The codebase of the content tool is now more manageable because we built it using just a dozen single-function lambdas. And our developers loved working with this technology. A win for all.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Adding plugins to a Gridsome site</title>
      <dc:creator>Christopher Wavrin</dc:creator>
      <pubDate>Fri, 07 Feb 2020 15:40:56 +0000</pubDate>
      <link>https://dev.to/wavrin/adding-plugins-to-a-gridsome-site-59fi</link>
      <guid>https://dev.to/wavrin/adding-plugins-to-a-gridsome-site-59fi</guid>
      <description>&lt;p&gt;&lt;a href="https://gridsome.org/"&gt;Gridsome&lt;/a&gt; is a great static site generator, written in Vue.js, to host websites. I have &lt;a href="https://www.wavrin.com/new-site-with-gridsome-and-amplify/"&gt;written&lt;/a&gt; before about why I chose Gridsome. I started this site with a great &lt;a href="https://github.com/gridsome/gridsome-starter-blog"&gt;starter template&lt;/a&gt;, but wanted to add a few more features to it. Thankfully, the Gridsome community has a number of quality plugins to make this easy.&lt;/p&gt;

&lt;p&gt;There are three features I wanted:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Analytics to track site visits&lt;/li&gt;
&lt;li&gt;A sitemap.xml to help crawlers index the site&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://disqus.com/"&gt;Disqus&lt;/a&gt; comments on each blog post&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first two - Google Analytics and a sitemap generator - have official &lt;a href="https://gridsome.org/plugins/"&gt;Gridsome plugins&lt;/a&gt;. But for Disqus comments I will have to do a tiny extra, using a Vue.js plugin instead. One quick note: I'm using &lt;em&gt;yarn&lt;/em&gt; instead of &lt;em&gt;npm&lt;/em&gt;, so that's what you'll see below. The plugin pages have instructions for npm if that's how you do things. :)&lt;/p&gt;

&lt;h3&gt;
  
  
  Google Analytics
&lt;/h3&gt;

&lt;p&gt;The @gridsome/plugin-google-analytics &lt;a href="https://gridsome.org/plugins/@gridsome/plugin-google-analytics"&gt;page&lt;/a&gt; makes this quite simple.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;yarn add @gridsome/plugin-google-analytics&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This adds the library to your &lt;code&gt;packages.json&lt;/code&gt; file. Now you just need to copy/paste the code into your &lt;code&gt;gridsome.config.js&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  plugins: [
    {
      use: '@gridsome/plugin-google-analytics',
      options: {
        id: 'UA-XXXXXXXXX-X'
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put your actual tracking ID in there and you are set. &lt;code&gt;gridsome build&lt;/code&gt; is all you need before deploying this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sitemap
&lt;/h3&gt;

&lt;p&gt;Following the instructions on the &lt;a href="https://gridsome.org/plugins/@gridsome/plugin-sitemap"&gt;@gridsome/plugin-sitemap page&lt;/a&gt;: &lt;code&gt;yarn add @gridsome/plugin-sitemap&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You do need to make sure that your &lt;code&gt;gridsome.config.js&lt;/code&gt; has a &lt;code&gt;siteUrl&lt;/code&gt; set. The plugin example has some different configuration options, depending on your pages and url structure. Mine is pretty simple, as all I have are blog posts for the top directory. So my plugin code for my &lt;code&gt;gridsome.config.js&lt;/code&gt; is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  plugins: [
    {
      use: '@gridsome/plugin-sitemap',
      options: {
        cacheTime: 600000, // default
        exclude: ['/exclude-me'],
        config: {
          '/*': {
            changefreq: 'weekly',
            priority: 0.5
          }
        }
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I left the "exclude" part in, even though I don't currently use it. After you build your site, your sitemap should be available at &lt;code&gt;/sitemap.xml&lt;/code&gt; You may not see it locally, but &lt;code&gt;gridsome build&lt;/code&gt; and deploy that, and you should see it in production.&lt;/p&gt;

&lt;p&gt;I would suggest using &lt;a href="https://www.google.com/webmasters/"&gt;Google Webmasters&lt;/a&gt; to show Google exactly where your sitemap is. It will then tell you if you have any errors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Disqus Comments
&lt;/h3&gt;

&lt;p&gt;This one's just a bit tricker because there is not an official Gridsome plugin. You will have to use the &lt;a href="https://github.com/ktquez/vue-disqus"&gt;vue-disqus&lt;/a&gt; component. Make sure to check the link for current instructions, but at this time:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install vue-disqus&lt;/code&gt; gets it into your &lt;code&gt;package.json&lt;/code&gt; You will now need to install it in your Vue app. In your &lt;code&gt;main.js&lt;/code&gt; you'll need to import it and then register it. Here is what my &lt;code&gt;main.js&lt;/code&gt; looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import '~/assets/style/index.scss'

import DefaultLayout from '~/layouts/Default.vue'

import VueDisqus from "vue-disqus";

export default function (Vue, { router, head, isClient }) {
  Vue.component('Layout', DefaultLayout);
  Vue.use(VueDisqus);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, if you are going to use comments like I do - underneath each blog post - you would put the following code in your template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;div class="comments"&amp;gt;
    &amp;lt;vue-disqus shortname="your_shortname_disqus" :identifier="page_id" url="http://example.com/path"&amp;gt;&amp;lt;/vue-disqus&amp;gt;
  &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just add your short name from your Disqus account and the url of your site. And that's it.&lt;/p&gt;

&lt;p&gt;Check all your work locally with &lt;code&gt;gridsome develop&lt;/code&gt;. Once you confirm it all looks good, build again: &lt;code&gt;gridsome build&lt;/code&gt; and deploy.&lt;/p&gt;

</description>
      <category>gridsome</category>
      <category>vue</category>
    </item>
  </channel>
</rss>
