Ryan Chenkie: [0:00] To deploy our serverless functions to Netlify, we're going to need to keep our code in source control. We'll need to push our code out to a GitHub account or something similar and then, we'll need to link up with it from Netlify.
[0:11] Now, in my case, because I have folder here, this directory and everything above it in my own source control where I'm keeping all the code for this course, I'm actually going to extract part of this to a new folder, where I can reinitialization Git and then I can push out the code for just that folder.
[0:27] Because I have Git initialized on his whole directory, everything that goes into the advanced react security patterns course, it's not really going to work for me to deploy it as is. This will be an optional step for you, you won't have Git initialized in quite the same as I do, so you can either follow along or just go right into the Orbit API and initialize Git in there.
[0:48] For me, I'm going to say, I want to copy and I want to copy recursively all of the items in the Orbit API folder, so everything in Orbit API and I want to go with three levels up into my main directory and I'll put that into a new directory that I'll just call Orbit Funk. So then, I can see the three levels up into Orbit Funk and I can now open up that directory in my code editor.
[1:12] So this is just everything from the Orbit API directory, but now, it's isolated to its own spot so that I can reinitialize Git and I can put this on GitHub and then deploy it to Netlify. Here's what we would do to get this folder in the right shape to put on GitHub and then eventually Netlify.
[1:28] Let's open up a terminal window and let's make a new directory in here called Functions, so we'll do make directory, Functions. This directory here, will be the home for all of our Netlify functions and once we give some instructions to Netlify, it's going to be expecting this folder to be there, and we'll see that in just a second.
[1:47] Next, I'm going to come down and I will Git init, so I've now initialized an empty Git repository and next I'm going to set the origin for this repository to a remote location that I just created in GitHub. I'll paste in the remote location, I'm adding an origin of my GitHub/Orbit-Funk. Let's create a file called .gitignore, so we can touch .gitignore.
[2:13] Normally, this file is used to do things like ignore the node modules. Normally, we would put node modules in here, which would then substantially bring down the number of files that we're going to commit.
[2:24] We're actually going to want to send our node modules to our GitHub repo, and that's because when we deploy our server less functions, Netlify is going to need everything that goes into making those functions run, and that includes code that would be in our node modules.
[2:38] In other circumstances, for example, if we are deploying a React application, we might have the node modules be installed as the application is deployed. Then we might have our build artifacts get created through an NPM build command. However, since we're working in a surrealism environment now, we're going to our node modules in source control, so that we can pull from them directly.
[2:57] So let's get rid of node modules and instead, we can just do anything that we don't want to put up in source control, which is quite often this hidden file on Mac called ds_store. If you're on Windows or another operating system now, you don't have to worry about that. Let's commit this work here so we'll do first commit, then we can push that up to our GitHub repo, Git push origin master.