<?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 Chris Barbour on Medium]]></title>
        <description><![CDATA[Stories by Chris Barbour on Medium]]></description>
        <link>https://medium.com/@hexlabs.chris.barbour?source=rss-5723af8282df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Hbn9Kdo5N60csaipk--kTw.png</url>
            <title>Stories by Chris Barbour on Medium</title>
            <link>https://medium.com/@hexlabs.chris.barbour?source=rss-5723af8282df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:45:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hexlabs.chris.barbour/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[We built the CI dashboard we always wanted]]></title>
            <link>https://medium.hexlabs.io/we-built-the-ci-dashboard-we-always-wanted-dc8edae9747a?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc8edae9747a</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Mon, 19 Oct 2026 13:01:04 GMT</pubDate>
            <atom:updated>2026-10-19T13:35:24.392Z</atom:updated>
            <content:encoded><![CDATA[<h4>Meet GitBoard: every repo and every pipeline, on one live board</h4><blockquote><a href="https://gitboard.io/"><em>GitBoard</em></a><em>, from the team at </em><a href="https://hexlabs.io/"><em>HexLabs</em></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nk5sgMiLBcvaMCmCmHM79Q.png" /></figure><p>Every team we’ve worked on has had the same ritual. Someone merges, someone else asks <em>“is it green?”</em>, and three people open three different tabs to find out.</p><p>We’re a small team, and our code is spread out the way most teams’ code is now: a dozen services across a couple of GitHub organisations, one monorepo with more workflows than anyone can name, and a corner of the business that still runs on Bitbucket Pipelines. Every CI tool has a great page for <strong>one</strong> repository. None of them could tell us how <strong>everything</strong> was doing.</p><p>So we built one. It’s called <strong>GitBoard</strong>, and today we want to show it off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VWzlJpoXTIDUHkI0sQsI2g.png" /><figcaption><em>One board for the whole organisation. Each card is a repository, and its colour tells you how it’s doing.</em></figcaption></figure><h3>The problems we kept hitting</h3><p>Before writing any code, we listed what kept going wrong. It wasn’t that builds failed. Builds fail. What hurt was everything around the failure:</p><ol><li><strong>Nobody noticed.</strong> A nightly job went red on Tuesday and was found on Thursday.</li><li><strong>“What’s in production?”</strong> No one could answer that without opening the deploy workflow and reading run logs.</li><li><strong>Monorepos hide failures.</strong> One red X on a repository with 12 projects tells you almost nothing.</li><li><strong>Pull requests are noise.</strong> A draft PR with a failing lint check shouldn’t look like your main branch is on fire.</li><li><strong>Finding the failing line takes too many clicks.</strong> Repo, then Actions, then the run, then the job, then the step, then scroll.</li><li><strong>Half the company was on a different CI tool,</strong> so there was never one place to look.</li></ol><p>GitBoard is our answer to each of those.</p><h3>1. Live, not refreshed</h3><p>GitBoard listens to your build tool’s events directly, so cards change the moment a run starts, fails, or finishes, on every screen that has the board open. Updates are pushed straight to your browser, so there’s nothing to refresh.</p><p>When a build breaks or a fix lands, a toast tells you. On the Professional plan, deployments get toasts too: a release reaching production, a deployment failing, or one waiting for approval.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tSJ9MMIKfL8o8EXTTS52NQ.png" /><figcaption>The board updates itself. On Professional, it tells you when a release reaches production.</figcaption></figure><p>The browser tab’s title and favicon follow the board’s state too, so you can tell from the tab bar that something’s red.</p><h3>2. “What’s actually in production?”</h3><p>This was the question we asked most, and it’s the one we’re proudest of answering. It’s part of our Professional plan. Each card shows your environments (dev, staging, production) with the version or commit that’s live in each one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*GB_Nphi7niOSOsuJvF8z2w.png" /><figcaption><em>Staging is on v1.9.0, and production is waiting for someone to approve it.</em></figcaption></figure><p>That orange <strong>approval</strong> is the reason this exists. A deployment waiting for a reviewer used to sit unnoticed for hours. Now it turns the whole card orange, as <strong>Needs action</strong>.</p><p>Click an environment and you get the full picture: what’s live, what’s deploying, who shipped it, and how far each environment is behind the one before it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8u2MXP4qzoyGbifOrQdLzw.png" /><figcaption><em>Production is one release behind staging. You can see it at a glance, without opening any logs.</em></figcaption></figure><p>Releases are tracked too, also on Professional. Each card shows the latest release and how many pushes have landed since, so you know when it’s time to cut the next one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*BHi7rb5fwVjncZAz1_aqsA.png" /></figure><h3>3. Monorepos, made legible</h3><p>A monorepo with one big CI workflow is the worst case for a status page: one red X and no idea which project caused it.</p><p>GitBoard splits a monorepo into projects, on every plan. Each project gets its own status and its own place on the card. On Professional, each project also shows its own environments and the version that’s live.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*DZeTaOjbrD3Ebq0jwFAmSg.png" /><figcaption><em>api is failing, web is deploying, and the other ten projects are fine. You know who needs to look.</em></figcaption></figure><p>Projects are found automatically from workflow names, file names and which workflows run together. If you’d rather be exact, add a .gitboard.yml to the repository:</p><pre>projects:<br>  api:<br>    workflows: [&quot;api / *&quot;, &quot;deploy-api.yml&quot;]<br>  web: [&quot;web-*&quot;]</pre><p>It works with Nx-style setups where every project builds in one shared workflow, too. Jobs named after a project, like Lint (api), go to that project.</p><h3>4. Pull requests in their place</h3><p>Busy repositories have dozens of open pull requests, and their checks fail all the time. That’s normal, and it shouldn’t make your main branch look broken.</p><p>On GitBoard, <strong>a card’s colour only ever comes from your default branch and your environments.</strong> Pull requests get their own line on the card (how many are open, failing, running and passing), and one click opens all of them with their checks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pxQ3EJUmkc1z-rOlboE3tg.png" /><figcaption><em>Every open pull request and its checks, without turning the board red. Drafts stay out of the way.</em></figcaption></figure><h3>5. From “it’s red” to “here’s why” in a few clicks</h3><p>When something fails, click it. The side panel opens at the workflow, then the run, then the job, then the step that failed, with the logs right there. Every level links to the exact place on GitHub, down to the individual step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x69QDL0f3NfolMuEEB6Yyg.png" /><figcaption><em>Workflow, run, job, step. The failing step is the red bar.</em></figcaption></figure><h3>6. Put it on the wall</h3><p>We wanted a board that people actually look at, so GitBoard has a <strong>TV mode</strong>. It’s built for a screen across the room: big type, a live count of what’s failing, what needs action and what’s running, and the cards that need attention pulled to the top. It pulses when something fails, and it can chime so nobody misses it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbM-6xbMRhOAfPql1J4-pQ.png" /><figcaption><em>TV mode puts what’s broken first, and everything that’s fine shrinks to a strip at the bottom.</em></figcaption></figure><h3>7. GitHub, GitLab and Bitbucket, side by side</h3><p>GitHub Actions, GitLab and Bitbucket Pipelines show up on the same board, with statuses that mean the same thing everywhere. If your company has multiple, and many do, there’s finally one place to look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7DMTrSW7Y4FpLbxPhSo9xA.png" /><figcaption>Github, GitLab and Bitbucket all flow to GitBoard</figcaption></figure><p>On top of that:</p><ul><li><strong>Views for every team.</strong> Filter, sort and group the board, split it into sections, and save it. Every view has its own link to share or put on a screen.</li><li><strong>Sign in with GitHub.</strong> There’s no new password. Install the GitBoard app on the organisations you choose and pick all your repositories or just some.</li><li><strong>Members and roles,</strong> so the whole team can share an organisation’s board.</li></ul><h3>We never read your code</h3><p>This mattered a lot to us as engineers, so we designed around it. The GitHub app asks for <strong>read-only</strong> access to workflow runs, deployments and pull requests, plus one optional file, .gitboard.yml. That&#39;s all. GitBoard never reads the rest of your repository, and your data can be deleted on demand.</p><h3>Try it</h3><p>GitBoard is free forever for public repositories, so open source projects can use it today. Here’s what each plan includes:</p><blockquote><strong>Free</strong>: your personal board, with unlimited public repositories, the live board and TV mode, monorepo projects, pull requests, drilling down to the failing step with the last 24 hours of runs, and one saved view.</blockquote><blockquote><strong>Professional</strong> which starts with a free trial: everything in Free, plus private repositories, environments and approvals, releases and drift, the environment matrix and its alerts, the full run history, unlimited saved views, and organisations with up to 5 members.</blockquote><p>Getting started takes about a minute:</p><ol><li>Sign in with GitHub at <a href="https://gitboard.io/"><strong>gitboard.io</strong></a>.</li><li>Install the GitBoard app on your organisation and pick your repositories (and connect Bitbucket too, if you use it).</li><li>Watch the board fill up as your builds run.</li></ol><p>We built GitBoard because we were tired of asking <em>“is it green?”</em> We’d love to hear what you think, and what you’d want on your board next.</p><p><strong>👉 </strong><a href="https://gitboard.io/"><strong>gitboard.io</strong></a><strong> from the team at </strong><a href="https://hexlabs.io/"><strong>hexlabs.io</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc8edae9747a" width="1" height="1" alt=""><hr><p><a href="https://medium.hexlabs.io/we-built-the-ci-dashboard-we-always-wanted-dc8edae9747a">We built the CI dashboard we always wanted</a> was originally published in <a href="https://medium.hexlabs.io/">HexLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TypeSafe DynamoDb with TypeScript]]></title>
            <link>https://medium.hexlabs.io/typesafe-dynamodb-with-typescript-f0fe538186a7?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0fe538186a7</guid>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[single-table-design]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Wed, 06 Dec 2023 20:01:52 GMT</pubDate>
            <atom:updated>2023-12-06T20:01:52.232Z</atom:updated>
            <content:encoded><![CDATA[<p>Writing code for AWS DynamoDb takes a lot of work. There are many ways to trip you up because validation of your expressions happens at <strong>runtime</strong>.</p><p>Get &amp; Delete functions are the simplest since they only take the partitionKey and sortKey however, Update and Query functions have many permutations.</p><p>With a Query, you can:</p><ul><li><strong>Filter</strong> (a whole world of pain)</li><li><strong>Page</strong></li><li><strong>Limit</strong> (not the limit you would expect)</li><li><strong>Reverse Sort</strong></li></ul><p>With an Update, you can:</p><ul><li><strong>Add </strong>Fields</li><li><strong>Update </strong>Fields</li><li><strong>Delete </strong>Fields</li><li><strong>Atomic Increment </strong>/<strong> Decrement</strong></li></ul><p>Writing code that utilizes these functions <strong>safely </strong>is complex, leading to mistakes only found once your app is running.</p><p><a href="https://www.npmjs.com/package/@hexlabs/dynamo-ts#hexlabsdynamo-ts">@hexlabs/dynamo-ts</a> provides a way to do all this, and more, using TypeScript’s type system to protect your app from simple typos when dealing with complex queries.</p><h3>Features</h3><ul><li>Table Definitions with TypeScript Types / Interfaces</li><li>All standard features of the Document Client from aws-sdk</li><li>Batching, Query All, Scan All, Pagination</li><li>Typed Filtering</li><li>Typed Projections</li><li>CloudFormation &amp; Jest Table JSON generation</li><li>CRUD service class</li><li>Single Table Design feature with multiple join types</li></ul><h3>A Simple Table</h3><p>Let’s start with a simple example, we are building <a href="https://gitboard.io/">gitboard.io</a> which brings together all your builds onto one dashboard. We built it using <a href="https://www.npmjs.com/package/@hexlabs/dynamo-ts#hexlabsdynamo-ts">@hexlabs/dynamo-ts</a>. A central feature of GitBoard is the repository . This represents a git repository in any source control management system, like GitHub.</p><h4>Install Dependencies</h4><pre>npm i -S @hexlabs/dynamo-ts @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb</pre><h4>RepositoryTable</h4><p>A repository has an owner and a name and we will partition the data by a unique identifier, let’s call it identifier.</p><p>A type for this in TypeScript would look like this:</p><pre>interface RepositoryTable {<br>  identifier: string;<br>  owner: string;<br>  name: string;<br>}</pre><p>We can use this type to create a TableDefinition</p><pre>import { TableDefinition } from &#39;@hexlabs/dynamo-ts&#39;;<br><br>const repoTableDefinition = TableDefinition<br>  .ofType&lt;RepositoryTable&gt;()<br>  .withPartitionKey(&#39;owner&#39;)// &lt;- This will be type checked<br>  .withSortKey(&#39;identifier&#39;); // &lt;- This will be type checked</pre><p>We need a DynamoDBDocument from aws-sdk before anything else:</p><pre>import { DynamoDB } from &#39;@aws-sdk/client-dynamodb&#39;;<br>import { DynamoDBDocument } from &#39;@aws-sdk/lib-dynamodb&#39;;<br><br>const dynamoClient = DynamoDBDocument.from(new DynamoDB({}));</pre><p>Next, we create a TableClient</p><pre>import { TableClient } from &#39;@hexlabs/dynamo-ts&#39;;<br><br>const repoTable = new TableClient(repoTableDefinition, {<br>  tableName: &#39;repository-table&#39;,<br>  client: dynamoClient,<br>  logStatements: true,<br>});</pre><h4><strong>PUT</strong></h4><p>Let’s add a repository to our table. As you type the IDE will help you with types and TypeScript will not compile if you miss something.</p><pre>await repoTable.put({<br>  identifier: &#39;repo-1&#39;,<br>  owner: &#39;gitboard-io&#39;,<br>  name: &#39;gitboard-web&#39;<br>})</pre><figure><img alt="IntelliSense when useing PUT" src="https://cdn-images-1.medium.com/max/478/1*B1hwnamGR5b_uPrneXBvBg.png" /><figcaption>IDE showing type help for put</figcaption></figure><h4>GET</h4><p>To get the item we just inserted, provide both the partition key and the sort key.</p><pre>const result = await repoTable.get({<br>  identifier: &#39;repo-1&#39;,<br>  owner: &#39;gitboard-io&#39;,<br>})</pre><p>result.item will have the correct type for your table. RepositoryTable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*34h11ajLGBNbAZ7GbENidg.png" /></figure><h4>Basic Query</h4><p>Now, we can query for all the repositories that are owned by a specific owner. Here is also a simple example of a filter checking for names beginning with &quot;service&quot;. Try playing about with the filter builder, you can reuse the compare function in combination with and and or to join multiple filter expressions.</p><pre>const gitboardRepos = await repoTable.query({<br>  owner: &#39;gitboard-io&#39;,<br>}, { filter: compare =&gt; compare().name.beginsWith(&#39;service&#39;) })<br><br>// A contrived example of filter using &#39;and&#39;<br>{ <br>  filter: compare =&gt; compare().name.beginsWith(&#39;service&#39;)<br>          .and(compare().name.exists)<br>}</pre><blockquote>The compare function uses types so that you can only select keys from your table’s type definition. It will also allow you to access deeply nested fields inside sub objects using dot notation `a.b.c`</blockquote><h4>DELETE</h4><p>Deletes are similar to get, they require the keys defined by the table.</p><pre>await repoTable.delete({<br>  identifier: &#39;repo-1&#39;,<br>  owner: &#39;gitboard-io&#39;,<br>})</pre><p>That’s it for the simple parts. Let’s dig into something a bit harder.</p><h3>Single Table Design (Joins)</h3><p>DynamoDb does not handle joins very well, there&#39;s a good reason for this. DynamoDb is fast. To be so efficient, they need to do things differently to SQL databases. Querying across heterogeneous data sets and joining the data is a costly process so Dynamo sidesteps it.</p><blockquote>Alex DeBrie has an article on the subject: <a href="https://www.alexdebrie.com/posts/dynamodb-single-table/">The What, Why and When of Single-Table Design with DynamoDB</a></blockquote><p>There’s a way to achieve table joins using a technique called singe-table design. This is simply a name for plopping all your related data into one table so that when you query it you get back all the related data sets at once.</p><p>To do this in Dynamo, you need to be smart in the way that you utilize partition keys and sort keys.</p><ol><li>The first thing to know is that you always require the partition key when querying, this means you always need to know your partition key (or all of the parts that make it up)</li><li>The second thing to know is that you can use beginsWith when querying the sort key. This means if you order its parts correctly you can make multiple ways to query for items.</li></ol><p>Let’s continue with the example of gitboard.io. GitBoard stores information about repositories as we have seen. It also stores information about builds that run in GitHub or some other build system. This then gets presented as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*q9W2E_bmSZbkQBojoXk9FQ.png" /><figcaption>a failing build in gitboard.io</figcaption></figure><p>To do this we need table entries for Repositories, Workflows, Runs, Jobs and Steps.</p><p>We want to present Repositories and Workflows together. Then when you click into a workflow, we want all the runs, jobs and steps.</p><p>So we want two queries:</p><ol><li>Get all repositories and workflows for a particular owner.</li><li>Get the latest workflow runs, jobs, and steps for a particular workflow.</li></ol><p>If we were to build this with DynamoDb you might make a table for each entity, or possibly one for each of these two access patterns. However, this can be done with one table, which we can organize in such a way that it is efficient to retrieve these data with two single queries.</p><h4>Without HexLabs Dynamo-ts</h4><p>I will first show how to use single-table design, without our library to help. Then I will show how our library makes this super simple.</p><p>Let’s start with the partition. In gitboard.io we isolate data by account, an account is our way of separating users, organizations, and enterprises. We also isolate the data by creating separate tables. Here, I will show a more terse version for demonstrative purposes.</p><p>We will partition repositories by a user, and users will have a unique id. Our partitionKey will be userId .</p><p>Now we can create two separate sort keys that represent repositories and workflows. Let’s use unique IDs, repoId &amp; workflowId</p><pre>// A Repository Table Entry<br>userId = my-user-id<br>repoId = repo1<br><br>Partition             |  Sort        | ...<br>#REPOINFO$my-user-id  |  #REPO$repo1 | ... other fields</pre><pre>// A Workflow Table Entry<br>workflowId = BuildAndDeploy<br><br>Partition             |  Sort                                         | ...<br>#REPOINFO$my-user-id  |  #WORKFLOW#REPO$repo1#WORKFLOW$BuildAndDeploy | ... other fields</pre><p>☹ That’s stinking. It’s ok there’s a library for it, called <a href="https://www.npmjs.com/package/@hexlabs/dynamo-ts#hexlabsdynamo-ts">@hexlabs/dynamo-ts</a>.</p><h4><strong>What’s going on? # $ ???</strong></h4><h4><strong>Partition Key</strong></h4><p>So, first thing, let’s look at our partition, it starts with #REPOINFO for both of these entries. We want to partition by userId. However, we want to get both repositories and their workflows while avoiding anything else that may be in this table. By prepending our partition key we can isolate our queries to specific data sets that we need. In this case, it’s repository info, hence REPOINFO.</p><p>Now if I query only providing #REPOINFO$my-user-id for the partitionKey, I will get all the repositories and workflows for that userId.</p><h4><strong>Sort Key</strong></h4><p>Now, for the sort key. Notice the sort key starts with a # followed by the name of the entity: #WORKFLOW #REPO. This allows us to select each type individually if we want. The sort key is optional so we can get both data sets together by leaving it out. The sort key for workflows allows us to also query by a specific repository if we wish since the repo comes straight after the #WORKFLOW . To get all the workflows for the repository repo1 you would use the following sortKey check:</p><p>beginsWith(sortKey, #WORKFLOW#REPO$repo1)</p><p>It’s not hard to see, that this is tough. This is only one example, there are many ways to change this up too. That prefix in the sort key can be left out, parts can move over to the partition key to create more elaborate tables with sub-joins. Also, to now implement workflow runs, jobs, and steps. It would get very taxing to work out all of the partitions and sorts needed.</p><p>This is compounded by the fact that you need to organize the data when it comes out as a flat list of items.</p><h4>With HexLabs Dynamo-ts</h4><p>We have simplified this down to two types of join in our library.</p><ol><li>There is a join in which you want all the data from one type along with all the data from a direct child relationship. We call this, simply a <strong>join</strong>.</li><li>Then there&#39;s another case, in which, you want to relate a set of data to a parent and be able to query the child and parent in isolation. We call this, simply a <strong>child</strong>.</li></ol><p>In our case, we have the following types:</p><ul><li><strong>Repository</strong></li><li><strong>Workflow</strong> (<strong>join</strong> to Repository)</li><li><strong>Run</strong> (<strong>child</strong> of Workflow)</li><li><strong>Job</strong> (<strong>join</strong> to Run, Steps inline)</li></ul><h4>Table Definitions</h4><p>This is how simple we can represent this in <a href="https://www.npmjs.com/package/@hexlabs/dynamo-ts#hexlabsdynamo-ts">@hexlabs/dynamo-ts</a></p><pre>export const repo =<br>TablePartInfo<br>.from&lt;RepoTable&gt;()<br>.withKeys(&#39;account&#39;, &#39;repo&#39;); // account is our partition, repo is the id for repository<br><br>export const workflow =<br>repo<br>  .joinPart&lt;WorkflowTable&gt;() // join to repo<br>  .withKey(&#39;workflow&#39;);<br><br>export const run =<br>workflow<br>  .childPart&lt;RunTable&gt;() // child of workflow<br>  .withKey(&#39;run&#39;);<br><br>export const job =<br>  run<br>  .joinPart&lt;JobTable&gt;() // join to run<br>  .withKey(&#39;job&#39;);</pre><h4>Table Clients</h4><p>Now we can create clients for each of these tables.</p><pre>const config: DynamoConfig = {<br>  tableName,<br>  client: DynamoDBDocument.from(this.dynamoDbClient),<br>};<br>const clients = TablePartClient.fromParts(config, repo,workflow, run, job);</pre><h4>Single Table Put</h4><p>Each table gets a client that allows you to put or query at that level. To <strong>put</strong> a run, for example, we need the following IDs: account, repo, workflow, run. That is because for each child we need to know all the parent&#39;s information. Here is an example put, note that it is type-safe. The client contains each of the table clients, here we use the one for run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*GvXkCAeeTBBJVuBpy5wLuQ.png" /></figure><p>Look at all that lovely help we get, there is no need to think about # and $ all over the place. It’s all done for you.</p><p>Here’s an example of what that translates to in raw DynamoDB JSON:</p><pre>&quot;PutItemInput&quot;: {<br>  &quot;TableName&quot;: &quot;gitboard-repo-status&quot;,<br>  &quot;Item&quot;: {<br>    &quot;partition&quot;: &quot;#ACCOUNT$my-user-id#REPO$repo1#WORKFLOW$workflow1&quot;,<br>    &quot;sort&quot;: &quot;#RUN$run1&quot;<br>    &quot;runNumber&quot;: &quot;56&quot;,<br>    &quot;attempt&quot;: 3,<br>    &quot;commit&quot;: {<br>      &quot;hash&quot;: &quot;4dsdalksfjdsakl&quot;,<br>      &quot;message&quot;: &quot;A Message!&quot;<br>    },<br>    &quot;status&quot;: &quot;success&quot;,<br>    &quot;run&quot;: &quot;run1&quot;,<br>    &quot;account&quot;: &quot;my-user-id&quot;,<br>    &quot;repo&quot;: &quot;repo1&quot;,<br>    &quot;workflow&quot;: &quot;workflow1&quot;<br>  }<br>}</pre><h4>Single Table Query</h4><p>Now we want to get our two access patterns, repositories with workflows and runs &amp; jobs with a workflow.</p><p>Here is how to get repositories with workflows. We select the client for the child and call queryWithParents</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNBHit4jI4bWslhZAYxLjQ.png" /></figure><p>Oooo, look at that return type, it contains RepoTable with Workflows tied together by ID. This returns an array of the type shown.</p><p>Here is the equivalent query in raw DynamoDB JSON:</p><pre>&quot;QueryInput&quot;: {<br>  &quot;TableName&quot;: &quot;gitboard-repo-status&quot;,<br>  &quot;KeyConditionExpression&quot;: &quot;#k = :pk&quot;,<br>  &quot;ReturnConsumedCapacity&quot;: &quot;TOTAL&quot;,<br>  &quot;ExpressionAttributeNames&quot;: {<br>    &quot;#pk&quot;: &quot;partition&quot;<br>  },<br>  &quot;ExpressionAttributeValues&quot;: {<br>    &quot;:pk&quot;: &quot;#ACCOUNT$my-user-id&quot;<br>  }<br>}</pre><blockquote>Note that the scanned count and return count will be the same.</blockquote><p>Now, let’s try the more difficult sub-element query to access all the runs, and jobs under a workflow, given a workflowId</p><pre>const result = await client.job.queryWithParents({account, repo, workflow });<br>//The type for result.member is {item: RunTable, member: JobTable[]}[]</pre><p>Very clean! and all from the same table.</p><p>Here is the corresponding DynamoDB JSON for reference:</p><pre>&quot;QueryInput&quot;: {<br>  &quot;TableName&quot;: &quot;gitboard-repo-status&quot;,<br>  &quot;KeyConditionExpression&quot;: &quot;#pk = :pk&quot;,<br>  &quot;ExpressionAttributeNames&quot;: {<br>    &quot;#pk&quot;: &quot;partition&quot;<br>  },<br>  &quot;ExpressionAttributeValues&quot;: {<br>    &quot;:pk&quot;: &quot;#ACCOUNT$my-user-id#REPO$repo1#WORKFLOW$workflow1&quot;<br>  }<br>}</pre><p>Thanks for reading! Please have a look at the open-source library on GitHub <a href="https://www.npmjs.com/package/@hexlabs/dynamo-ts#hexlabsdynamo-ts">@hexlabs/dynamo-ts</a>. I am sure it will help you if you use TypeScript and DynamoDB. Give us a star on GitHub if you liked it.</p><p>Please follow me for more stories like this!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0fe538186a7" width="1" height="1" alt=""><hr><p><a href="https://medium.hexlabs.io/typesafe-dynamodb-with-typescript-f0fe538186a7">TypeSafe DynamoDb with TypeScript</a> was originally published in <a href="https://medium.hexlabs.io/">HexLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Shareable CloudFormation Stacks for One-Click Deployment in AWS]]></title>
            <link>https://medium.hexlabs.io/create-shareable-cloudformation-stacks-for-one-click-deployment-in-aws-6b8483dee46a?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b8483dee46a</guid>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[stack]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Fri, 06 Jan 2023 15:46:12 GMT</pubDate>
            <atom:updated>2023-01-08T10:24:00.483Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Quick Create Stack Example" src="https://cdn-images-1.medium.com/max/1024/1*Gi_zbbFB6Ucu2-IOGRGerA.png" /><figcaption>An example showing the quick-create stack page we generate in <a href="https://klouds.io/">klouds.io</a></figcaption></figure><p>At <a href="https://hexlabs.io/">HexLabs</a>, we have created a SaaS product called <a href="https://klouds.io/">klouds.io</a> to help with costs and observability in AWS. To get access to the user’s account we create a secure read-only cross-account IAM role. The problem we had, was how we create that role with as few steps as possible for the user, one click would be ideal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*VTLB3uJCSc92Yc4ClnapIA.png" /><figcaption>An IAM role (red) with a policy granting access to our cost reports bucket (green) shown in <a href="https://klouds.io/">klouds.io</a></figcaption></figure><p>We discovered that you can store a CloudFormation stack in S3 (publically accessible), then generate a <strong>URL</strong> that brings the user directly to the stack creation page on AWS with that stack selected. All the user has to do, is review the stack and its parameters then click the <strong>Create Stack </strong>button.</p><h3>Create a one-click URL</h3><p>If your template requires parameters you can pass them as query parameters prefixed with param_ as shown below. You can choose the region the stack is created in by prefixing the URL with the region code as shown below.</p><p>This is the format for the URL:</p><pre>https://&lt;&lt;region&gt;&gt;.console.aws.amazon.com/cloudformation/home<br>#/stacks/quickcreate<br>?templateUrl=&lt;&lt;location in s3&gt;&gt;<br>&amp;stackName=&lt;&lt;stack name&gt;&gt;<br>&amp;param_&lt;&lt;TemplateParam1&gt;&gt;=&lt;&lt;value&gt;&gt;<br>&amp;param_&lt;&lt;TemplateParam1&gt;&gt;=&lt;&lt;value&gt;&gt;</pre><p>A more detailed explanation of this link can be found <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stacks-quick-create-links.html">here from Amazon.</a></p><h4>Get an S3 URL for your Stack</h4><p>Before you generate a URL for stack creation you need your CloudFormation stack template deployed to an S3 bucket. We do this using GitHub Actions but you can also use the console as shown here.</p><p><strong>Create an S3 Bucket</strong></p><p>Create a bucket to hold your templates. The contents of this bucket will be accessible to the world so be careful what you put in here.</p><p>Go to the S3 page on the AWS Console <a href="https://s3.console.aws.amazon.com/s3/bucket/create?region=eu-west-1">here</a>. Input the name you want the bucket to have, this will appear in the URL and must be unique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdseA5PlERuJzT5hzzdcMQ.png" /><figcaption>Creating an S3 bucket on the AWS console</figcaption></figure><p>Remove the block on public access to your bucket and accept the warning.</p><p>Click the <strong>Create Bucket</strong> button at the bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WNnmLFX4Z24xlHxJXJ8WMw.png" /></figure><p>Next, select the bucket you have just created and select the Properties Tab at the top.</p><p><strong>Enable Static Website Hosting</strong></p><p>At the bottom of the Properties tab you will find a section titled <strong>Static website hosting</strong>. Click Edit on this section and select <strong>Enable.</strong></p><p>Set <strong>Index Document</strong> to index.html and optionally set the error document. These specify what gets served by default or in the event of an error. They don’t matter for hosting documents since we will reference them directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OhxXZwUJ4uOSoaK3rW4W7Q.png" /></figure><p>Save the changes.</p><p>We now have a URL available that we can use to direct traffic to the bucket. Now we need to grant access to everything in the bucket.</p><p>Go to the Permissions tab for your bucket and find the section titled <strong>Bucket policy </strong>and click<strong> Edit. </strong>Insert the following to grant access to everything in the bucket. Replace &lt;&lt;bucket name&gt;&gt; with your bucket’s name.</p><pre>{<br>  “Version”: “2012–10–17”,<br>  “Statement”: [<br>   {<br>     “Effect”: “Allow”,<br>     “Principal”: “*”,<br>     “Action”: “s3:GetObject”,<br>     “Resource”: “arn:aws:s3:::&lt;&lt;bucket name&gt;&gt;/*”<br>   }<br>  ]<br>}</pre><p>Now, all we need to do is upload a CloudFormation Template.</p><p>Go to the Objects Tab for your bucket and Click <strong>Upload. </strong>Add a file and click upload. If you don’t have one, here is one I created that you can download and upload to your bucket. It is a stack that creates one s3 bucket.</p><blockquote><a href="http://klouds-templates.s3-website-eu-west-1.amazonaws.com/bucket.json">http://klouds-templates.s3-website-eu-west-1.amazonaws.com/bucket.json</a></blockquote><p>Once your file has been uploaded, you need to build an S3 URL for it. The one above is the website URL for my file but we need to use its S3 URL which looks slightly different.</p><blockquote><a href="http://klouds-templates.s3.eu-west-1.amazonaws.com/bucket.json">http://klouds-templates.<strong>s3.eu-west-1</strong>.amazonaws.com/bucket.json</a></blockquote><p>Yours will be the same but with the names replaced</p><pre>http://&lt;&lt;bucketname&gt;&gt;.s3.&lt;&lt;bucket region&gt;&gt;.amazonaws.com/&lt;&lt;file name&gt;&gt;</pre><p>Now we can construct a URL for our one-click template deployment. Use the S3 URL as shown above and the URL template earlier in this article.</p><p>Here is an example of one using my bucket template.</p><p><a href="https://us-east-1.console.aws.amazon.com/cloudformation/home#/stacks/quickcreate?templateUrl=http://klouds-templates.s3.eu-west-1.amazonaws.com/bucket.json&amp;stackName=MyStackFromUrl">https://us-east-1.console.aws.amazon.com/cloudformation/home#/stacks/quickcreate?templateUrl=http://klouds-templates.s3.eu-west-1.amazonaws.com/bucket.json&amp;stackName=MyStackFromUrl</a></p><p>This should show the following screen where you can click Create Stack. Put this behind a button on your website to get assets built into your user&#39;s AWS accounts fast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jkUSn9oe-VwUrS78jQrRag.png" /><figcaption>The Quick Create Stack Screen</figcaption></figure><p>Thanks for reading, for more articles on AWS, TypeScript or Open Source projects follow me or follow <a href="https://medium.hexlabs.io/">HexLabs</a> where I will post more like this regularly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b8483dee46a" width="1" height="1" alt=""><hr><p><a href="https://medium.hexlabs.io/create-shareable-cloudformation-stacks-for-one-click-deployment-in-aws-6b8483dee46a">Create Shareable CloudFormation Stacks for One-Click Deployment in AWS</a> was originally published in <a href="https://medium.hexlabs.io/">HexLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Partial Type Inference]]></title>
            <link>https://medium.hexlabs.io/partial-type-inference-f669ae24c44e?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/f669ae24c44e</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[type-inference]]></category>
            <category><![CDATA[advanced-types]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Thu, 29 Sep 2022 07:51:52 GMT</pubDate>
            <atom:updated>2022-09-29T07:53:02.667Z</atom:updated>
            <content:encoded><![CDATA[<h3>Partial Type Inference in TypeScript</h3><p>When we build functions with multiple generic types that get inferred by the arguments that are passed we create a problem for the developer using the function. They lose the ability to control the types without specifying the others. The generics parameters are not partially inferred.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MgIKvVp-i52v-g34JRcOAg.png" /><figcaption>The final recursive version of tuplise</figcaption></figure><p>Here is a contrived example function with 2 generic parameters. All it does is convert the two parameters into a tuple that gets the types of each of the parameters A and B.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/912c408d24da42c15f298455d18bd7ae/href">https://medium.com/media/912c408d24da42c15f298455d18bd7ae/href</a></iframe><p>Here is an example use:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d339e736279d18a84bede2bf9169c2b9/href">https://medium.com/media/d339e736279d18a84bede2bf9169c2b9/href</a></iframe><p>The <strong>typeof</strong> myTuple will be:</p><pre><strong>typeof</strong> myTuple === [a: <strong>number</strong>, b: <strong>string</strong>];</pre><h3>The Problem</h3><p>The user of this function can pass any arguments and get the types for those arguments as expected, but say they now want to change one of the types to be another type, for example, in the myTuple value above, say the user wanted the second argument to be a union: &#39;123&#39; | &#39;234&#39; . There are two ways of doing this:</p><p>Define it in the generic parameters:</p><pre><strong>const</strong><em> </em>myTuple = tuplise&lt;<strong>number</strong>, &#39;123&#39; | &#39;234&#39;&gt;(123, &#39;123&#39;);<br><strong>typeof</strong> myTuple === [a: <strong>number</strong>, b: &#39;123&#39; | &#39;234&#39;];</pre><p>Or cast:</p><pre><strong>const</strong><em> </em>myTuple = tuplise(123, &#39;123&#39; <strong>as</strong> &#39;123&#39; | &#39;234&#39;);<br><strong>typeof</strong> myTuple === [a: <strong>number</strong>, b: &#39;123&#39; | &#39;234&#39;];</pre><p>In the first example, we need to pass <strong>number</strong> even though it should have been inferred. This is because we cannot partially infer the set of generics unless they are defaulted.</p><h3><strong>The Solution</strong></h3><p>The solution to this is to split the function by currying its parts. We do this by returning a new function for each parameter and placing the next generic parameter into that function for it to be inferred later.</p><p>Here is what it looks like when split:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36d30a28cc7c7e6eba6ad39acfd5373c/href">https://medium.com/media/36d30a28cc7c7e6eba6ad39acfd5373c/href</a></iframe><p>This gives the user more power by giving them more options.</p><p>Taking this further, we now have the power to repeat indefinitely. Here is the same solution except you can continue digging deeper and specify your own custom generics at any time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/485e1e2e94657d3b2fc4c5686ecf34e3/href">https://medium.com/media/485e1e2e94657d3b2fc4c5686ecf34e3/href</a></iframe><p>And here is the type created from calling it three levels deep:</p><pre><em>const </em>myTuple = tuplise(123)<br>.and&lt;&#39;123&#39; | &#39;234&#39;&gt;(&#39;123&#39;)<br>.and({a: <em>true</em>})<br>.get();</pre><pre>typeof myTuple = [number, (&quot;123&quot; | &quot;234&quot;), {a: boolean}]</pre><p>Thanks for reading. Hope you enjoyed this, please clap and follow me for more like it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f669ae24c44e" width="1" height="1" alt=""><hr><p><a href="https://medium.hexlabs.io/partial-type-inference-f669ae24c44e">Partial Type Inference</a> was originally published in <a href="https://medium.hexlabs.io/">HexLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run / Debug AWS Lambda Locally with TypeScript without containers]]></title>
            <link>https://medium.hexlabs.io/run-debug-lambdas-locally-with-typescript-without-containers-a4e649acd4c4?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4e649acd4c4</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[local]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Tue, 13 Sep 2022 15:16:31 GMT</pubDate>
            <atom:updated>2022-09-13T18:11:35.189Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are building TypeScript APIs with API Gateway and AWS Lambda, running and debugging locally can be a pain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vXtF81CrOhpc7wDpX7P2Q.png" /><figcaption>Some Lambdas and API gateway resources, rendered with <a href="https://klouds.io/">kouds.io</a></figcaption></figure><p>At HexLabs, we built an entire ecosystem of TypeScript tools to help us build API Lambdas and found that running locally wasn’t simple, especially if you want to debug.</p><p>Here are a few links for those libraries, if you are interested.</p><ul><li><a href="https://www.npmjs.com/package/@hexlabs/kloudformation-ts">@hexlabs/kloudformation-ts</a></li><li><a href="https://www.npmjs.com/package/@hexlabs/schema-api-ts">@hexlabs/schema-api-ts</a></li><li><a href="https://www.npmjs.com/package/@hexlabs/http-api-ts">@hexlabs/http-api-ts</a></li></ul><p>The tools above let us generate API code with routing from an OpenAPI Schema specification stored in the codebase. We also get SDKs, model types and routing. We only need to build schemas and write the implementations. However, we still lacked the ability to run locally as if we were running in the wild, on AWS. A lot of bugs can be found by simply hitting your endpoint from Postman for the first time.</p><h4>The Problem</h4><ul><li>We want to run as fast as possible and be able to hot-reload so that we can develop and call endpoints as soon as we save.</li><li>Any stack traces should show exactly the line that caused the issue.</li><li>Endpoints should exist as if API Gateway was serving them but on localhost.</li><li>Auth should carry through as though Cognito had sent it.</li><li>Debugging should be a click of a button in the IDE.</li></ul><h4>The Solution</h4><p>We solved this by creating an express server that uses ts-node at runtime to compile and run TypeScript. The express server takes a JSON representation of your API Gateway configuration and exposes the same endpoints. By adding a start script to the scripts section in package.json you can right-click and select debug in WebStorm.</p><p>We generate the API definition from our Schema using the libraries above, but here I will show how to do it without any of those libraries so anyone can try it.</p><p>The open-source library we created is called: @hexlabs/lambda-api-runner-ts</p><p><a href="https://www.npmjs.com/package/@hexlabs/lambda-api-runner-ts">@hexlabs/lambda-api-runner-ts</a></p><h3>Get Started</h3><p>I will show you how this library works with an empty TypeScript project so you can see how it can be integrated with any setup, not only if you use our libraries. Please do though :)</p><p>Start by cloning this repo, it’s a simple skeleton TypeScript template:</p><pre>git clone <a href="/service/mailto:git@github.com">git@github.com</a>:hexlabsio/typescript-template.git</pre><p>Open a terminal and cd into the cloned directory:</p><pre>cd typescript-template</pre><p>Install cross-env so that we can write a start script that works across environments. Also, run npm install to get the rest of the dependencies.</p><pre>npm install -D cross-env<br>npm install</pre><p>Define your API. For this example, we will create a simple GET /hello endpoint. To do this create a file named paths.json at the root of the project with the following content.</p><blockquote>We generate this by defining our API in an OpenAPI schema and using @hexabs/schema-api-ts</blockquote><pre>{<br>  &quot;/hello&quot;: {<br>    &quot;methods&quot;: [<br>      &quot;GET&quot;<br>    ],<br>    &quot;paths&quot;: {}<br>  }<br>}</pre><p>Next, Create a handler. This is the entrypoint and it is what you would expose to Lambda.</p><p>Update src/index.ts to look like this:</p><pre><em>// The </em><strong><em>any</em></strong><em> here can be APIGatewayProxyEvent from </em>aws-lambda</pre><pre><em>export async function handler</em>(event: <em>any</em>) {<br>  console.log(event);<br>  <em>return </em>{ statusCode: 200, body: &#39;World!&#39; }<br>}</pre><blockquote>This above would call implementations for each of your API endpoints. Before that it needs to route to the correct endpoint by checking the path, resource and httpMethod properties on event.</blockquote><blockquote>If you want a lovely routing library try <em>@hexlabs/http-api-ts</em></blockquote><p>In package.json, add the following to the scripts object:</p><pre>&quot;start&quot;: &quot;cross-env-shell npx @hexlabs/lambda-api-runner-ts@0.1.5 start $INIT_CWD/paths.json handler $INIT_CWD/src/index.ts&quot;,</pre><p>This will run lambda-api-runner-ts by giving it the location to paths.json, the name of our handler (handler) and the location of our entrypoint.</p><p>Now, in the terminal, run the following:</p><pre>npm run start</pre><p>This will output some information and log the list of endpoints. Our example will output the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*EOEGWK-CY1IaTjyGoieDWQ.png" /></figure><p>All you need to do now is hit the endpoint. You can click the link to open it in the browser since it&#39;s only a GET request. You should see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*Z6spVWmTILrhSarpZ9lQlg.png" /></figure><h4>Debugging</h4><p>Add a breakpoint:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*RcMeRkynkPsqMqRTL9QBew.png" /></figure><p>In WebStorm, open package.json click the play icon beside start and select Debug &#39;start&#39;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*dqY7r7gV11mBJ7RbPLrL7g.png" /><figcaption>WebStorm debug</figcaption></figure><p>Or In VSCode, Click the Debug text as shown below and select the start command in the dropdown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NJMSj6BHX5QS7XTsFXdzHA.png" /><figcaption>VSCode debug</figcaption></figure><p>Hit the endpoint again, and the breakpoint will stop the progression. Now you can see all that juicy info.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ZuBOybXN0nTqupiibhxgmQ.png" /><figcaption>Breakpoint hit, event highlighted</figcaption></figure><p>Hope you found this interesting. If you are interested in more content, follow me. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4e649acd4c4" width="1" height="1" alt=""><hr><p><a href="https://medium.hexlabs.io/run-debug-lambdas-locally-with-typescript-without-containers-a4e649acd4c4">Run / Debug AWS Lambda Locally with TypeScript without containers</a> was originally published in <a href="https://medium.hexlabs.io/">HexLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Environment Variables in TypeScript]]></title>
            <link>https://medium.hexlabs.io/environment-variables-in-typescript-31089ba78e40?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/31089ba78e40</guid>
            <category><![CDATA[environment-variables]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Wed, 07 Sep 2022 08:58:11 GMT</pubDate>
            <atom:updated>2022-09-13T12:26:27.033Z</atom:updated>
            <content:encoded><![CDATA[<p>Dealing with environment variables is simple, however, due to its simplicity, they are often pulled in at the last minute, or thrown in wherever they are needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*RQK55uOVuwOZG5LjPap9Pg.png" /><figcaption>Bad use of env variables</figcaption></figure><p>The above image clearly has an issue, the ! will cause an Error at some point when the url variable is used but the environment variable wasn’t set. That’s obvious. The solution is, of course, to default it or make url optional and do something else for the case when it is not there.</p><p>So you create a fancy solution to check and fix it inline, then your app grows, and you have 10 more dotted around your application, they all need this same solution.</p><p><a href="https://hexlabs.io/">HexLabs</a> have built a small open-source library to deal with this very thing. We use advanced types so you don’t need to supply type information. You can specify required environment variables that will be checked or optional ones that can be undefined. Further to this, you can supply your own transforms, if you want booleans or numbers instead of strings.</p><blockquote>This applies to any set of variables that look like environment variables, this article will show process.env from node, you can supply your own</blockquote><h4>@hexlabs/env-vars-ts</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*TuRhBFpN2LgNe2DL3NJDaA.png" /><figcaption>@hexlabs/env-vars-ts</figcaption></figure><pre>npm i -S @hexlabs/env-vars-ts</pre><p><a href="https://github.com/hexlabsio/env-vars-ts">GitHub - hexlabsio/env-vars-ts: Typesafe control over environment variables in Typescript</a></p><p>This is how you specify which environment variables you want.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7771d2260e6881f5b012ef5136a68d1/href">https://medium.com/media/a7771d2260e6881f5b012ef5136a68d1/href</a></iframe><p>This is lazy in that environment is a function, this means you can get the type of it, as shown on line 7, before actually getting the values.</p><p>Here is how you get the values from the environment:</p><pre><em>// Pass custom envs here, defaults to process.env<br>const </em>myApiEnvs = environment();</pre><pre>//This will throw an Error for any required envs that are not given</pre><h4>default values</h4><p>Any required environment variables allow default values, you can set them as follows:</p><pre>.defaults({ HOST: &#39;klouds.io&#39; })</pre><h4>Transforms</h4><p>Say you want some of your environment variables to be boolean toggles.</p><p>Here is how you do that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c4587618818769373d22a4dd11b9770/href">https://medium.com/media/4c4587618818769373d22a4dd11b9770/href</a></iframe><p>The type of MyEnvs in this case will get updated automatically to this:</p><pre>type MyEnvs becomes:<br>{ A_STRING: <strong>string</strong>; MY_TOGGLE: <strong>boolean</strong>; MY_OTHER_TOGGLE: <strong>boolean</strong> }</pre><h4>Example Usage</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftypescript-e5kszx%3Fembed%3D1%26file%3Dindex.ts%26view%3Deditor&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftypescript-e5kszx%3Ffile%3Dindex.ts%26view%3Deditor&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Ftypescript-e5kszx%2F811d75a6fe610d6006d00edb1a39611f&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/9348dccc4baf84a5c89a20e571581672/href">https://medium.com/media/9348dccc4baf84a5c89a20e571581672/href</a></iframe><p>Hope you find this interesting, please give it a go and if you like it, give it a star on GitHub. Thanks!</p><p>Follow for more like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31089ba78e40" width="1" height="1" alt=""><hr><p><a href="https://medium.hexlabs.io/environment-variables-in-typescript-31089ba78e40">Environment Variables in TypeScript</a> was originally published in <a href="https://medium.hexlabs.io/">HexLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Builder Pattern with TypeScript using Advanced Types]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.hexlabs.io/the-builder-pattern-with-typescript-using-advanced-types-e05a03ffc36e?source=rss-5723af8282df------2"><img src="https://cdn-images-1.medium.com/max/1308/1*kOAz36bnlm1uV9g1EqxJWg.png" width="1308"></a></p><p class="medium-feed-snippet">In this story, we will look at how we can leverage the type system in TypeScript to create a builder with the builder pattern.</p><p class="medium-feed-link"><a href="https://medium.hexlabs.io/the-builder-pattern-with-typescript-using-advanced-types-e05a03ffc36e?source=rss-5723af8282df------2">Continue reading on HexLabs »</a></p></div>]]></description>
            <link>https://medium.hexlabs.io/the-builder-pattern-with-typescript-using-advanced-types-e05a03ffc36e?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/e05a03ffc36e</guid>
            <category><![CDATA[builder-pattern]]></category>
            <category><![CDATA[advanced-types]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Mon, 05 Sep 2022 15:45:58 GMT</pubDate>
            <atom:updated>2022-09-05T15:51:33.660Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building Complex Types in TypeScript Part 2]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.hexlabs.io/building-complex-types-in-typescript-804c973ce66f?source=rss-5723af8282df------2"><img src="https://cdn-images-1.medium.com/max/1400/0*AeYuU9Rf0lU8LvSR.png" width="1400"></a></p><p class="medium-feed-snippet">Part 2: Complex Types</p><p class="medium-feed-link"><a href="https://medium.hexlabs.io/building-complex-types-in-typescript-804c973ce66f?source=rss-5723af8282df------2">Continue reading on HexLabs »</a></p></div>]]></description>
            <link>https://medium.hexlabs.io/building-complex-types-in-typescript-804c973ce66f?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/804c973ce66f</guid>
            <category><![CDATA[typelevel]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[advanced-types]]></category>
            <category><![CDATA[type]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 15:47:29 GMT</pubDate>
            <atom:updated>2022-09-02T08:45:17.647Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building Complex Types in TypeScript]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.hexlabs.io/building-complex-types-in-typescript-bfdf5e131dbe?source=rss-5723af8282df------2"><img src="https://cdn-images-1.medium.com/max/1634/1*d0LMS0r3m_U9W7yX8bnCCA.png" width="1634"></a></p><p class="medium-feed-snippet">Part 1: Building Blocks</p><p class="medium-feed-link"><a href="https://medium.hexlabs.io/building-complex-types-in-typescript-bfdf5e131dbe?source=rss-5723af8282df------2">Continue reading on HexLabs »</a></p></div>]]></description>
            <link>https://medium.hexlabs.io/building-complex-types-in-typescript-bfdf5e131dbe?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfdf5e131dbe</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[typelevel]]></category>
            <category><![CDATA[type]]></category>
            <category><![CDATA[advanced-types]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 15:43:19 GMT</pubDate>
            <atom:updated>2022-10-07T11:55:24.762Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[DynamoDB with TypeScript]]></title>
            <link>https://medium.hexlabs.io/dynamodb-with-typescript-d6763df90f13?source=rss-5723af8282df------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6763df90f13</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-sdk]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Chris Barbour]]></dc:creator>
            <pubDate>Wed, 24 Aug 2022 12:51:18 GMT</pubDate>
            <atom:updated>2022-08-24T14:34:46.600Z</atom:updated>
            <content:encoded><![CDATA[<p>At HexLabs, a lot of our AWS Account is made up of DynamoDB Tables and Indexes. It also accounts for a high proportion of our costs. As a result, we decided to build an open-source library to interact with the SDK in a way that was type-safe and easy to use.</p><p>The library is called dynamo-ts and can be found in NPM under @hexlabs/dynamo-ts or in GitHub <a href="https://github.com/hexlabsio/dynamo-ts">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*SNJR_HZbqZyUZW0QdNe-hA.png" /><figcaption>HexLabs DynamoDB resources visualised in <a href="https://klouds.io/">klouds.io</a></figcaption></figure><h3>A Comparison</h3><p>Using the current javascript SDK is hard, once you get into filters and projections, handling pagination, etc the requests get pretty hairy. Here is how dynamo-ts compares with a few examples.</p><h4>Get</h4><p>This comparison doesn’t look like much but look at the image below, when you change the identifier to be different from the table, it now will not compile.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc8800549985939e6dab791d45290929/href">https://medium.com/media/bc8800549985939e6dab791d45290929/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*dWIbQIRtK1YLFZH3tAFt4Q.png" /></figure><h4>Put</h4><p>Once again, doesn’t look like much of a difference, but the dynamo-ts version won’t compile unless the type matches the table definition, this means you won’t waste time discovering bugs at runtime.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae1f2ac69571eaf95f09da2d6fb13a93/href">https://medium.com/media/ae1f2ac69571eaf95f09da2d6fb13a93/href</a></iframe><h4>Query</h4><p>This is what it&#39;s all about, look how many strings you need to get right in the original, none of which are checked until runtime, for a <strong>very</strong> basic query with a filter. Add on and / or combinations, projections, limits, reverse sort, sort key comparisons, and paging. It gets messy. Dynamo-ts makes it much simpler, even those strings in the beginsWith function are checked, text must be one of the keys of the table definition and &#39;abc&#39; must be a string.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26f48338f302f521256e9a3a50683ab6/href">https://medium.com/media/26f48338f302f521256e9a3a50683ab6/href</a></iframe><h4>Batch Get</h4><p>Batch functions are built in too, you can use and to combine multiple tables for up to 25 individual requests combined into one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e648cbdc151968329e05d510cb3f01f/href">https://medium.com/media/1e648cbdc151968329e05d510cb3f01f/href</a></iframe><h3>Paging</h3><p>You can opt to gather all pages or get a next token back when querying or scanning. To page over all the data simply call queryAll or scanAll.</p><h3>Indexes</h3><p>Indexes also have query and scan functionality, once an index is defined as part of the table definition, simply call .index(&#39;index-name&#39;) to get an updated client with the correct data types your index will respond with.</p><p>Even the index name is typed so you can only supply it with valid index names.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98f4721c9098a4746e6b7e3f75efa813/href">https://medium.com/media/98f4721c9098a4746e6b7e3f75efa813/href</a></iframe><p>Thanks for reading, stay tuned for more open-source libraries, for more details on how to get started, see the following GitHub readme. If you like the project, please star it on GitHub :)</p><p><a href="https://github.com/hexlabsio/dynamo-ts">https://github.com/hexlabsio/dynamo-ts</a></p><p><a href="https://github.com/hexlabsio/dynamo-ts">GitHub - hexlabsio/dynamo-ts: A typesafe wrapper over the javascript sdk for AWS DynamoDb written in TypeScript</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6763df90f13" width="1" height="1" alt=""><hr><p><a href="https://medium.hexlabs.io/dynamodb-with-typescript-d6763df90f13">DynamoDB with TypeScript</a> was originally published in <a href="https://medium.hexlabs.io/">HexLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>