Home
Jamstack Explorers
Menu

Up and Running with Serverless Functions with Ben Hong

The Power of Atomic Serverless Functions

📝 Transcript

Now that we have our newly enhanced Pokedex API. I want to show you the power of atomic serverless functions. Let's start by checking out a new brand called add region to API, and I'll go ahead and commit all this code inside of it. And once we've done that, let's go ahead and push this branch up. I'll go and use the link right here inside of my terminal to create a pull request.

And once we've done that, you'll see that because this repo is already tied with the Netlify site, it automatically kicks off a deploy preview. What that means is that it's going to build an entirely separate URL for our specific branch. Here. We can see the deployed logs and now that everything has been built, we can open our deploy preview by clicking on this button.

As we see here, we can see our newly enhanced Pokedex API, where we can click on Canto and Hogan and everything works as expected. But what's amazing about this is that if we go back and open our production, you are out here. You'll see that it actually has our original API still deployed to the public.

In other words, these two deploys are completely separate from one another. Jumping back into the PR let's assume everything's great, and the teams approved it. So let's go ahead and merge this branch. Once it's done that notify knows that it's time to rebuild Maine cause new code has been introduced.

And you'll see, now that once we've gone ahead and built everything, we can go ahead and open the deploy and you can see our new Pokedex API is now live on production, but a situation that can come up is that what happens when you need to roll back to a previous deploy? Let's say we need to jump back to the original API.

Well, to roll back. All we need to do is open the deploy tab inside of our Netlify dashboard and select which deploy we want to revert back to. In this case, we want to revert back to this one at 10:09 PM. When we click on it. We can see that when we preview it, we still have the original API. So this is the one we want.

And to switch out, deploy, all we need to do is click, publish, deploy. Once we've done that when we refresh the page, you'll see that in just a few clicks, we managed to revert back to a past deploy. And in the event we want to switch back. It's just as easy as going back, clicking the latest deploy, and then clicking, publish, deploy.

And when we refresh boom, right back to where we want to be. And just like that, you're now able to switch between different deploys of your serverless functions. And though this might seem simple at first, the ability to be able to confidently switch between different deploys of your serverless functions as needed to be incredibly powerful when it comes to shipping code for your application.

Explorers

your progress

78