This tutorial is now outdated. If you want to stay up to date with the MEAN Stack you will want to check out this Complete Guide instead.
Refactoring code from the MEAN boiler plate
We are going to be needing to clean up the project before we can start adding any code to the application, in the ideal world this would be as simple as running the following command.
Since the project has a very tight coupling dependent modules we can not just run this command and start cleaning up the boiler plate code so we have to slowly start to refactor in this case delete components that are not needed in the project. Make sure if you are following along with the git repo that you check out the right commit.
Let’s go ahead and remove the mean-admin module that comes by default with the project.
Did you catch that? the following command did work although I mentioned that it would not. Don’t worry this is because the module was install in the following directory.
Now let’s remove the following directory we will no longer be needing. Don’t worry it’s just an empty directory.
Let’s go ahead and clean up this project, even more, the following two commands are going to be deleting the themes folder and the articles module, our requirements don’t call for this features so let’s get rid of them.
As previously mentioned the themes package is coupled with other modules so if you try to compile and run the application your console will log out a nasty error like the following one.
No problem! Let’s refactor this controller out of the project.
delete the following line
Now that we have all of this out of the way the project should be somewhat of a workable project to start developing some of the features for the goal’s application. Let’s create a package for the application
This will create a directory in the packages parent directory
knowRick/packages/custom/knowrick, Now I don’t necessarily like having my project with in other folder so let’s go ahead and move it up to the parent folder
Now what I did is not necessarily the MEAN.IO way of doing things, and this is frankly frowned upon. But hey we forked off the project no looking back now.
That’s it for part 3! Congratulations give your self-pat on the back and get ready for part 4!
Till next time,
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More