Learn how to use generators to jumpstart your development projects.
Jennifer Bland
Any time you need to start a new development project from scratch you will find yourself writing the same basic set of code over and over. There is a better - and faster - way of overcoming that shortcoming by using generators.
Generators are pre-packed sets of code that give you the basic framework that you will need in your project. There are many different generators that are available for you to use.
Most of my projects run using the MEAN stack. The MEAN stack is an abbreviation for a project that uses MongoDB, Express, AngularJS and Node.js.
When writing projects I go through the same process of setting up the server, installing Angular and configuring authentication for my project. What if there is a way to start any MEAN stack project with all of this done for you?
There is a great generator that will provide the entire MEAN stack for you. The best one that I have used is the Angular Fullstack generator. This code provides the following functionality:
You can use the usual method of forking the project to your github account and then cloning it down to your computer to use. But there is a much easier way to install.
The simplest way to use this generator is to install generator-angular-fullstack using npm.
npm install -g generator-angular-fullstack
Once that has finished installing. Create a new directory on your computer and change into that directory. Then run the command to actually generate the MEAN stack for you. You can optionally pass in the name of your app that you are creating.
yo angular-fullstack [app-name]
If you are deploying to another platform then the generator utilizes grunt. Grunt allows you to build your final application. You can even use grunt to preview your application during the development cycle.
When it comes to writing new projects from scratch, there is no reason to reinvent the wheel. Using the Angular Fullstack generator can have you up and running with a fully functional project in less than five minutes.