generator-mvp

1.5.2 • Public • Published

generator-mvp Build Status

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

Usage

  • Install yo, grunt-cli, and generator-mvp
$ npm install -g grunt-cli yo generator-mvp
  • Make a new directory, and cd into it:
$ mkdir mvp && cd $_
  • Run yo mvp to generate application skeleton
$ yo mvp
  • Run grunt dev to launch your application and watch for codes changes

Workflow Tasks

generator-mvp provide a set of grunt tasks for use during development and testing.

grunt dev

To run in development mode use

$ grunt dev

grunt test

To run in test mode use

$ grunt test

grunt prod

To run in production mode use

$ grunt prod

grunt spec

To run all tests or specifications use

$ grunt spec

For targeted spec or test runner see project Gruntfile

Generators

Available generators:

And more to come based on what we daily need in our expressjs an mongoose development workflows.

App

Sets up a new expressjs and mongoose app, generating all the boilerplate you need to get started.

Example of generating an application:

$ yo mvp

Api

Set 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:Date

Example of generating api with multi name

$ yo mvp:api item_category name:String dob:Date

Model

Set 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:Date

Example of generating model with multi name

$ yo mvp:model item_category name:String dob:Date

Example of generating model including refs to other model

$ yo mvp:model post content:String author:ObjectId:User 

Controller

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 edit

Middleware

Set 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 guard

Library

Set 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 scanner

Angular

Set up angular frontend for the provided model definition.

It will generate the following:

  • model angular factory
  • angular controllers required to manage model
  • ui-router states configuration to manage model
  • html crud views to manage model

To use yo mvp:angular sub-generator make sure:

$ 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 apiEndpoint angular constant into your application main module that will point to the root url of your api.
...
    .constant('apiEndpoint', '/')
...

Then, you can continue using it as bellow:

$ yo mvp:angular User name:String dob:Date

Contributing

Fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.

Testing

  • Clone this repository

  • Install dependencies

$ npm install
  • Then run test
$ npm test

References

License

The 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.

Package Sidebar

Install

npm i generator-mvp

Weekly Downloads

11

Version

1.5.2

License

MIT

Last publish

Collaborators

  • lykmapipo