<?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 Harry Adel on Medium]]></title>
        <description><![CDATA[Stories by Harry Adel on Medium]]></description>
        <link>https://medium.com/@harryadel?source=rss-d6ff44bb8bcc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xkbAYcB3HdJOIsCkN0HdTQ.png</url>
            <title>Stories by Harry Adel on Medium</title>
            <link>https://medium.com/@harryadel?source=rss-d6ff44bb8bcc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 03:39:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harryadel/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[Next.js and the Future of Headless E-Commerce]]></title>
            <link>https://medium.com/unchained-commerce/next-js-and-the-future-of-headless-e-commerce-3a4b3a186f5c?source=rss-d6ff44bb8bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a4b3a186f5c</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[headless-commerce]]></category>
            <category><![CDATA[api-first]]></category>
            <dc:creator><![CDATA[Harry Adel]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 16:01:28 GMT</pubDate>
            <atom:updated>2020-12-23T16:01:28.649Z</atom:updated>
            <content:encoded><![CDATA[<p>While we’re a bit late to the party, we wanted to share with you guys our take on <a href="https://nextjsnotes.com/next-js-conf-highlights-2020/">Next.js Conf</a> and how this impacts the future of headless e-commerce sites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0u__eJybOvVmQEbSx9W9g.png" /></figure><p>So, in case you didn’t know, Next.js announced their partnership with BigCommerce to release <a href="https://nextjs.org/commerce">Next.js Commerce</a> where they’d allow you to configure a headless BigCommerce store with a custom Next.js site with just a few clicks. But rest assured, BigCommerce wouldn’t be the only way to integrate with Next.js Commerce as more integrations are yet to come, including household names like Shopify and others more. <strong>Don’t worry we’re cooking something of our own too.</strong> 😉</p><p>Such interest in e-commerce and, more precisely, headless e-commerce comes as no surprise to us as providing a <a href="https://developers.unchained.shop/why-headless">headless engine</a> has been one of our key <a href="https://developers.unchained.shop/platform">offerings</a> at Unchained since inception. Traditional Commerce prides itself on providing a full-stack experience where you get a tightly coupled front-end and back-end application giving you a speed boost at the beginning to launch your application quickly.</p><p>Later on, you start struggling to have it scale according to your needs but with headless e-commerce, you get to enjoy a constraint-free design philosophy: use a prebuilt front-end or build your own from scratch; customize your customers’ experiences on the fly to respond to sudden changes in the market; change your front-end without affecting your back-end or vice versa, the possibilities are endless.</p><h4>Why the future of e-commerce is headless</h4><p>The internet is in a constant state of change and entropy with new ways to access and consume content more revolutionary than ever before. And these channels differ greatly, you got: desktops, mobile phones, tablets, smart watches, TVs, glasses and more to come. As more and more digital devices rise and become commonplace in our daily lives, this requires the utmost flexibility to adjust to consumer needs at all times. Successful companies can only withstand such a tremendous whirlwind of changes by using the right tools and headless commerce is the right tool for the job.</p><p>This article is reposted from the <a href="https://unchained.shop/blog"><strong>Unchained Commerce Blog</strong></a><strong> </strong>and<strong> </strong>is licensed under a <a href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a4b3a186f5c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/unchained-commerce/next-js-and-the-future-of-headless-e-commerce-3a4b3a186f5c">Next.js and the Future of Headless E-Commerce</a> was originally published in <a href="https://medium.com/unchained-commerce">Unchained Commerce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating off of Meteor Accounts — Case Study]]></title>
            <link>https://medium.com/unchained-commerce/migrating-off-of-meteor-accounts-case-study-24481faa374d?source=rss-d6ff44bb8bcc------2</link>
            <guid isPermaLink="false">https://medium.com/p/24481faa374d</guid>
            <category><![CDATA[headless]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[headless-commerce]]></category>
            <dc:creator><![CDATA[Harry Adel]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 15:59:30 GMT</pubDate>
            <atom:updated>2020-12-23T15:59:30.605Z</atom:updated>
            <content:encoded><![CDATA[<h3>Migrating off of Meteor Accounts — Case Study</h3><p>Howdy! Today we’re going to be exploring our departure from one of Meteor’s most important packages and our plans for the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*myR4hasPrLuYi1MkulQWWg.png" /></figure><p>So in case you don’t know about us. We’re an <a href="https://github.com/unchainedshop/unchained">open-source</a>, API-first, headless framework that been built using Meteor and is currently used across a bunch of <a href="https://unchained.shop/referenzen">companies</a> based in Switzerland.</p><p>For a while we’ve been considering migrating off of Meteor which aligns more with our goal of becoming a framework agnostic tool which all developers can benefit from whether they prefer Meteor or otherwise. Don’t get me wrong. We absolutely adore Meteor and think it’s a great tool, just not for our current use case. You can read more about our decision <a href="https://github.com/unchainedshop/unchained/issues/115">here</a>.</p><p>For this migration to be considered successful a couple of goals had to be <a href="https://github.com/unchainedshop/unchained/issues/225#issue-701047641">met</a>:</p><p>- Current cookies / tokens need to be still working after migration</p><p>- 2FA support and other authentication strategies for our future needs</p><p>- Easy way to extend user fields just like Meteor accounts</p><p>- A clear documentation and migration path for currently used hooks</p><p>We pondered using many package like <a href="https://github.com/jaredhanson/passport">Passport</a> or <a href="https://github.com/nmaro/ooth">Ooth</a> but settled on <a href="https://github.com/accounts-js/accounts">Accounts-js</a> because of its modularity, it’s comprised of multiple package that you can mix and match, and its inspired by Meteor Accounts system after all.</p><p>We agreed to split this work into phases in order to receive incremental benefits, fix bugs as soon as they’d arise and to avoid frustration/burnout.</p><h4>Phase one:</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3lvqNXheb679S%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3lvqNXheb679S%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F3lvqNXheb679S%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="268" frameborder="0" scrolling="no"><a href="https://medium.com/media/55033e68a050c4fbf948f7927ed05f52/href">https://medium.com/media/55033e68a050c4fbf948f7927ed05f52/href</a></iframe><p>Our goal was to replace the login part and its associated methods and hooks (which we’re using lots of). Successfully getting this part done means the whole migration is a success otherwise we’d have stopped right in our tracks.</p><p>We initially felt great about the implementation as Accounts-js is split into different packages. We didn’t need the <a href="https://www.accountsjs.com/docs/transports/graphql">GraphQL layer</a> since we had our APIs but surely the <a href="https://www.accountsjs.com/docs/strategies/password">passwords</a> package came in handy. However, right off the bat, we hit a wall. Although Accounts-js is Meteor accounts protégé it employs a drastically different authentication mechanism one that relies on <a href="https://www.accountsjs.com/docs/server#session">JWT tokens</a> (short lived and long lived/refresh tokens) while Meteor relies on unique hashes.</p><p>Moreover, during the registration and login process <a href="https://willvincent.com/2018/08/09/replicating-meteors-password-hashing-implementation/">Meteor hashes passwords</a> using sha265 algorithm before sending them to using, a relic of the past where SSL wasn’t popular so as to avoid exposing the user’s password over the network. Thankfully, this part we’re already managing outside of the authentication code.</p><p>Another roadblock we hit was how different both packages handled email validation. user@unchained would pass in Meteor but user@unchained.local is only acceptable for Accounts-js. This minor difference involved editing a huge portion of our test cases.</p><p>Because of the aforementioned reasons we had to extend the accounts-server class and override the login and logout methods</p><pre><a href="https://github.com/unchainedshop/unchained/blob/246fa449c5ee641be4e6b95e81c687abc04f1e20/packages/platform/setup-accounts.js#L23"><em>https://github.com/unchainedshop/unchained/blob/246fa449c5ee641be4e6b95e81c687abc04f1e20/packages/platform/setup-accounts.js#L23</em></a><em><br></em></pre><pre><em>export</em> <em>default</em> ({ mergeUserCartsOnLogin = true } = {}) =&gt; {</pre><pre>  Accounts.validateNewUser((user) =&gt; {</pre><pre>  const clone = cloneDeep(user);</pre><pre>  delete clone._id;</pre><pre>  Users.simpleSchema().validate(clone);</pre><pre><em>  return</em> true;</pre><pre>});</pre><pre>Accounts.onCreateUser((options = {}, user = {}) =&gt; {</pre><pre>const newUser = user;</pre><pre>const { guest, skipEmailVerification, profile } = options;</pre><pre>newUser.profile = profile;</pre><pre>newUser.guest = !!guest;</pre><pre>newUser.created = newUser.createdAt || new Date();</pre><pre>delete newUser.createdAt; <em>// comes from the meteor-apollo-accounts stuff</em></pre><pre><em>if</em> (newUser.services.google) {</pre><pre>  newUser.profile = {</pre><pre>   name: newUser.services.google.name,</pre><pre>   ...newUser.profile,</pre><pre>  };</pre><pre>  newUser.emails = [</pre><pre>   { address: newUser.services.google.email, verified: true },</pre><pre>  ];</pre><pre>}</pre><pre><em>if</em> (newUser.services.facebook) {</pre><pre>  newUser.profile = {</pre><pre>   name: newUser.services.facebook.name,</pre><pre>   ...newUser.profile,</pre><pre>  };</pre><pre>  newUser.emails = [</pre><pre>   { address: newUser.services.facebook.email, verified: true },</pre><pre>  ];</pre><pre>}</pre><pre><em>if</em> (!guest &amp;&amp; !skipEmailVerification) {</pre><pre>  Meteor.setTimeout(() =&gt; {</pre><pre>  const { sendVerificationEmail = true } = Accounts._options; <em>//   eslint-disable-line</em></pre><pre>  Accounts.sendVerificationEmail(user._id);</pre><pre>  }, 1000);</pre><pre>}</pre><pre><em>return</em> newUser;</pre><pre>});</pre><p>Meteor Accounts system is unique in a sense that <em>validateNewUser</em> runs on the user object before it gets inserted in the database and it allows actually to abort the creation process by returning false or throwing an error.</p><p>In the same vein, <em>onCreateUser</em> allows you to customize the user object and even abort the creation if you wish to do so. But, in Accounts-js we’re only able to find <em>validateNewUser</em> function which runs before the creation and had to lump our code into one.</p><p>This is the after:</p><pre><em>https://github.com/unchainedshop/unchained/blob/master/packages/platform/setup-accounts.js#L27</em></pre><pre><em>export</em> <em>default</em> ({ mergeUserCartsOnLogin = true } = {}) =&gt; {</pre><pre>  accountsPassword.options.validateNewUser = (user) =&gt; {</pre><pre>   const clone = cloneDeep(user);</pre><pre><em>   if</em> (clone.email) {</pre><pre>    clone.emails = [{</pre><pre>    address: clone.email,</pre><pre>    verified: false,</pre><pre>    }];</pre><pre>   delete clone.email;</pre><pre>   }</pre><pre>  delete clone._id;</pre><pre>  Users.simpleSchema()</pre><pre>  .extend({</pre><pre>  password: String,</pre><pre>  })</pre><pre>  .omit(&#39;created&#39;)</pre><pre>  .validate(clone);</pre><pre>  const newUser = user;</pre><pre><em>  if</em> (user?.services?.google) {</pre><pre>   newUser.profile = {</pre><pre>   name: user.services.google.name,</pre><pre>   ...user.profile,</pre><pre>   };</pre><pre>   newUser.emails = [</pre><pre>    { address: user.services.google.email, verified: true },</pre><pre>   ];</pre><pre>  }</pre><pre><em>  if</em> (user?.services?.facebook) {</pre><pre>   newUser.profile = {</pre><pre>    name: user.services.facebook.name,</pre><pre>    ...user.profile,</pre><pre>  };</pre><pre>   newUser.emails = [</pre><pre>    { address: user.services.facebook.email, verified: true },</pre><pre>   ];</pre><pre>  }</pre><pre><em>  return</em> newUser;</pre><pre>  };</pre><pre>};</pre><p>As you can see the hooks are entirely different but the most notable part is the social media login which we had to circumvent in order to avoid any breaking changes.</p><p>We got off the hook pretty easily if we’re a traditional full stack Meteor this login/logout part might have taken much more time. Please note accounts-js offers an <a href="https://github.com/accounts-js/meteor-adapter">adapter</a> for Meteor applications.</p><h4>Phase Two:</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FNx85vtTY70T3W%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FNx85vtTY70T3W%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdHl5NHJ3bjI1OHJjYmFlczMyM2g5OXZqY3I2MHhnZnYxcjlsYW9xbyZlcD12MV9naWZzX2dpZklkJmN0PWc%2FNx85vtTY70T3W%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="313" frameborder="0" scrolling="no"><a href="https://medium.com/media/be0ba57969c703ef92876cac46613d18/href">https://medium.com/media/be0ba57969c703ef92876cac46613d18/href</a></iframe><p>By far the lengthiest phase. We had to convert user management utilities like password reset, change password etc. And many of these mutation employed the User collection helpers which in turn affected the emails sending code. Doing the slightest of changes caused a chain reaction type of effect.</p><p>Again, we ran into an easy part and a hard part. The easiest part was to convert the collection helpers. And this where our pick of accounts-js shines the most. The user management APIs are so simple and such a delight to use.</p><p>Here’re a few examples:</p><pre><em> https://github.com/unchainedshop/unchained/blob/master/packages/core-users/db/helpers.js#L112</em></pre><pre>async setUsername(username) {</pre><pre><em> await</em> dbManager.setUsername(this._id, username);</pre><pre><em> return</em> Users.findOne({ _id: this._id });</pre><pre>},</pre><pre>async addEmail(email, { verified = false } = {}) {</pre><pre><em> await</em> accountsPassword.addEmail(this._id, email, verified);</pre><pre><em> return</em> Users.findOne({ _id: this._id });</pre><pre>},</pre><pre>async removeEmail(email) {</pre><pre><em> await</em> accountsPassword.removeEmail(this._id, email);</pre><pre><em> return</em> Users.findOne({ _id: this._id });</pre><pre>},</pre><p>Now, onto the weird/hard part, Accounts-js sets mail behavior globally; there’s no way of fine-tuning per request. For instance you can’t exempt a newly created user from having a verification email sent. See <a href="https://github.com/accounts-js/accounts/blob/1c3591df64e53fc36f047c543b2491668ef3fe2e/packages/password/src/accounts-password.ts#L593">here</a>.</p><p>We had a case of guest users so we’d create a password-less account for them but don’t want to trigger the verification email. So, we had to manage this part within the mail sending code.</p><pre><em>https://github.com/unchainedshop/unchained/blob/master/packages/core-accountsjs/accounts-server.js#L11</em></pre><pre>prepareMail: (to, token, user, pathFragment) =&gt; {</pre><pre><em>  return</em> {</pre><pre>   template: &#39;ACCOUNT_ACTION&#39;,</pre><pre>   recipientEmail: to,</pre><pre>   action: pathFragment,</pre><pre>   userId: user.id || user._id,</pre><pre>   token,</pre><pre>   skipEmailVerification: !!user.guest,</pre><pre>  };</pre><pre>},</pre><pre>sendMail: (input) =&gt; {</pre><pre><em>  if</em> (!input) <em>return</em> true;</pre><pre><em>  if</em> (input.skipEmailVerification &amp;&amp; input.action === &#39;verify-  email&#39;)</pre><pre><em>  return</em> true;</pre><pre><em>return</em> WorkerDirector.addWork({</pre><pre>  type: &#39;MESSAGE&#39;,</pre><pre>  retries: 0,</pre><pre>  input,</pre><pre> });</pre><pre>}</pre><h4>Phase Three (Operation Jenga):</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FPlnQNcQ4RYOhG%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FPlnQNcQ4RYOhG%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FPlnQNcQ4RYOhG%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/19ebd8af7d25409ef7ac49c0c69616a5/href">https://medium.com/media/19ebd8af7d25409ef7ac49c0c69616a5/href</a></iframe><p>This was the scariest by far where we removed the Meteor Accounts system and had to fix any broken tests.</p><p>Funnily enough, this was by far the easiest of the three phase, no damage was sustained during this part because we’ve taken extra care during each of the previous and made sure to account for future improvements. Integration tests helped us navigate this part safely.</p><p>Conclusion:</p><p>While the migration wasn’t a straight forward process and we to meditate multiple differences between the packages like authentication mechanism, hooks, social media logins and email management but we can proudly say that the migration was a success and we’d encourage other developers to try out <a href="https://github.com/accounts-js/accounts">Accounts-js</a> while it’s still under development but it’s surely production ready. You can view the pull request that contained all of our changes <a href="https://github.com/unchainedshop/unchained/pull/244">here</a> or if you’re feeling more adventurous you might as well tinker with our own <a href="https://github.com/unchainedshop/unchained/tree/master/packages/core-accountsjs">core-accountsjs</a> package.</p><p>This article is reposted from the <a href="https://unchained.shop/blog"><strong>Unchained Commerce Blog</strong></a><strong> </strong>and<strong> </strong>is licensed under a <a href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24481faa374d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/unchained-commerce/migrating-off-of-meteor-accounts-case-study-24481faa374d">Migrating off of Meteor Accounts — Case Study</a> was originally published in <a href="https://medium.com/unchained-commerce">Unchained Commerce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>