Yeoman Angular Generator with REST API
Zweman is a generator that accepts Models with API links and generates an Angular project with basic CRUD features.
First, install Yeoman and generator-zweman using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-zwemanA new project must be created before creating models.
Starting a project will install the angular-cli if you don't have one and generate a new angular project.
yo zweman MyNewProjectThis will create a new model with specified data types.
yo zweman:model ModelName var1:var_type var2:vartype
Each model must provide an API URL for the CRUD processes of that model.
Model name must start with a capital letter. Model name must not contain spaces.
numberfor numbers and floating points.stringfor strings and texts.booleanfor boolean.Datefor DateTime.- Objects can also be used as a data type but the object must be created as a model first. (i.e. If you want a
Bookobject that has anAuthorobject as a data type, anAuthorobject must be created first. )
yo zweman:model Author id:number name:string email:string
yo zweman:model Book id:number title:string author:Author publication_date:Date stock:booleanYou only need to provide one URL for all CRUD processes like http://192.168.0.112:4000/api/v1
After creating all necessary models, you can scaffold the project.
Scaffolding will generate angular components and services or the respective models.
yo zweman:scaffoldTo run the project change directory to the project folder
cd MyNewProject and run this command
ng serveTo build your project for production run this command inside the project folder.
ng build --aot --prodA new folder named dist will appear inside your project folder. That is the production build of your project.
MIT © zwenex