Set of generators to kick start nodejs API based application with pm2, mongoose, expressjs, angular and others. Based on yeoman and highly inspired by rails and other famous generators.
Warning!: yo mvp:angular sub-generator have to be used with generator-angular not otherwise and it works only with ui-router
Warning!: There are major changes to v1.0.0+, before using it please backup or commit your application changes
- Install
yo,grunt-cli, andgenerator-mvp
$ npm install -g grunt-cli yo generator-mvp- Make a new directory, and
cdinto it:
$ mkdir mvp && cd $_- Run
yo mvpto generate application skeleton
$ yo mvp- Run
grunt devto launch your application and watch for codes changes
generator-mvp provide a set of grunt tasks for use during development and testing.
To run in development mode use
$ grunt devTo run in test mode use
$ grunt testTo run in production mode use
$ grunt prodTo run all tests or specifications use
$ grunt specFor targeted spec or test runner see project Gruntfile
Available generators:
And more to come based on what we daily need in our expressjs an mongoose development workflows.
Sets up a new expressjs and mongoose app, generating all the boilerplate you need to get started.
Example of generating an application:
$ yo mvpSet up new mongoose model, controller, router and their spec/test boilerplates. To generate a new api invoke yo mvp:api followed with model definition
Example of generating simple api
$ yo mvp:api user name:String dob:DateExample of generating api with multi name
$ yo mvp:api item_category name:String dob:DateSet up new mongoose Schema with its spec/test boilerplate and register it to mongoose. To generate new model invoke yo mvp:model with model name and its attributes separated by space.
Note!: Only mongoose schema types are supported as attributes
Example of generating simple model
$ yo mvp:model user name:String dob:DateExample of generating model with multi name
$ yo mvp:model item_category name:String dob:DateExample of generating model including refs to other model
$ yo mvp:model post content:String author:ObjectId:User Set up new controller, its actions and an express router. To generate a new controller invoke yo mvp:controller giving its name and actions separated by space.
Example of generating controller including frontend
$ yo mvp:controller index create editSet up new express middleware with it test/spec boilerplate. To generate a new express middleware invoke yo mvp:middleware and giving its name.
Example of generating middleware
$ yo mvp:middleware guardSet up new nodejs module with it test/spec boilerplate. To generate a new nodejs module invoke yo mvp:lib and giving its name.
Example of generating library
$ yo mvp:lib scannerSet up angular frontend for the provided model definition.
It will generate the following:
- model
angular factory angular controllersrequired to manage modelui-routerstates configuration to manage model- html
crud viewsto manage model
To use yo mvp:angular sub-generator make sure:
- You have generate your front-end application using generator-angular
$ yo angular- Install all required dependencies to your application:
$ bower install --save angular-ui-router angular-resource angular-bootstrap- Add all required dependencies to your application
angular
.module('<moduleName>', [
...
'ui.router',
'ngResource',
'ui.bootstrap'
...
])- Add
apiEndpointangular constant into your application main module that will point to theroot urlof your api.
...
.constant('apiEndpoint', '/')
...Then, you can continue using it as bellow:
$ yo mvp:angular User name:String dob:DateFork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.
-
Clone this repository
-
Install dependencies
$ npm install- Then run test
$ npm testThe MIT License (MIT)
Copyright (c) 2015 lykmapipo & Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
