Up and Running with Serverless Functions with Ben Hong
Project Setup with Serverless Functions
And finally you'll need a basic understanding of NPM. With that, let's dive right in. To get started. Let's clone the repo. We'll go to github.com/netlify. And then we'll go ahead and search for the repo in the, find the repository. If you look for explorers, you'll see the repo explorers up and running with serverless functions.
In order to ensure that you can deploy this to your own site, go ahead and use the use this template button in order to create this repo inside of your own account. I'm going to go ahead and call mine my first serverless project. I'll go ahead and click create repository. And now we're ready to go. Let's go ahead and clone this repo. I'll go ahead and copy the SSH address.
We'll run git clone on the address and I'll go ahead and copy it down onto our local machine. We'll change directories into the project. I'll go ahead and clear the terminal so that it's easier to follow. I'll go ahead and list out the files in the folder by using the command LS. And we'll see here that all we have is a read me that MD and a public directory.
Next let's go ahead and make sure that we have NPM installed. You can do that by running NPM --version. You'll see that I'm running 6.14.13. Once you've done that, we'll need to install the Netlify CLI package, which we'll do by running npm install netlify-cli -g.
Once we do that, we can verify that we've successfully installed the package by running Netlify dash dash version. As you can see here, I have version three, that 31 that 14 throughout this lesson, I'm actually gonna be using the shorthand in order to make it a little easier to type. And that is NTL, which is just a shorthand for Netlify.
So you'll see that when I've run ntl --version, we get the same exact output. If you don't have a Netlify account yet you can go ahead and go to netlify.com and click on the signup link in the upper, right. In order to sign up for an account, I already have an account, so I won't be doing this step back in our terminal.
We'll need to log into our account inside of our CLI and we'll do this preventing Netlify login. You'll see that it prompts me to login using the browser. I don't go ahead and log in using my GitHub credentials. Go ahead and authorize it. And now when I go back into the terminal, you'll see that I have a successful, you are now logged into your Netlify account.
Final step is for us to initialize the project so that we can actually work with serverless functions. And we do that by running NTL in it. Since this is a new site I'll select create and configure a new site. If you have multiple teams, make sure to select the correct one. If it's a new account, you should only have one for the team.
I'm going to select BenCodeZen's team. And for the site name, I'll call it my first serverless site. When prompted with the bill command, we don't have one, so we can just hit enter. And as you can see it automatically fills out no bill come in. The directory we want to deploy is actually going to be our public directory.
So we'll type public. We'll leave the default Netlify functions folder to be Netlify slash functions. And since we don't have our Netlify dot Tommo file yet, which would contain our configuration, we're going to go ahead and say yes. And once you see the message success, Netlify see ICD configured. You're ready to go.