Initialize the Backend Repo

Link to chapter - https://serverless-stack.com/chapters/initialize-the-backend-repo.html

Hi @jayair,

My question is regarding the size of the repo after running ā€˜npm installā€™ which created node_modules.

It seems to me the entire repo including the huge node_modules subdir is then pushed to the github.

bash-3.2$ npm install
...
bash-3.2$ cd ..
bash-3.2$ du -sh serverless-stack-2-api/
127M	serverless-stack-2-api/
bash-3.2$ 

I imagine a lot of whatā€™s in node_modules is only needed during development.

Is it necessary to push 127 MB of node_modules to github?
Thanks very much.

Oh yeah you shouldnā€™t commit the node_modules/ dir. It is generated every time you run npm install.

A recommendation - after doing

$ git remote add origin REPO_URL

If we do

npm init (-y)

again, the change (repo field) will be reflected in package.json.

Could be a useful addition to the tutorial.

1 Like

Ah good point. Iā€™ll look into adding it in.

When I run npm install, I get the following message: found 128 vulnerabilities (54 low, 55 moderate, 19 high)
Is this the case for everyone else? Is there anything that can be done to remedy these vulnerabilities?

1 Like

I think you need to run npm audit fix for that.

Wow, that fixed all of them. Thanks. (Unfortunately it created a few more, which donā€™t seem to be fixable with npm audit fix, but a few is certainly better than 128.)

1 Like

Great tutorial, I really, really learned a lot taking some time and doing this while going thru the AWS docsā€¦ Quick comment/question, though. I taking the repo here which looks like itā€™s branched after the ā€œDelete Noteā€ step in section 1ā€¦

per the serverless.yml code, itā€™s still looking for the resource/api-gateway-errors.yml file, but the branch actually comes from the step just before that. Obviously, itā€™s no problem to just grab that code and create a new file, but I wanted to point that out in case there was a reason Iā€™m not foreseeing that you chose that particular pointā€¦

My guess was that, for wahtever reason, the step adding the API-Gateway resource file was added later and thatā€™s the closest branch to the codebase we want to start withā€¦

Anything I should look out for?

1 Like

Thanks for the kind words.

Great catch! I should update the branch. It should be instead be the API Gateway CORS errors chapter - https://serverless-stack.com/chapters/handle-api-gateway-cors-errors.html.

So the command to clone the repo really should be:

$ git clone --branch handle-api-gateway-cors-errors --depth 1 https://github.com/AnomalyInnovations/serverless-stack-demo-api.git serverless-stack-2-api/

That branch should have the resource it is looking for.

Iā€™ll update the chapter with this as well.