vulpejs

0.1.39 • Public • Published

VulpeJS

VulpeJS

Open-Source Full-Stack solution to Node.js applications with Express.js, Pug, AngularJS and MongoDB.

Works on Linux (stable) & MacOSx (stable) & Windows (stable).

NPM version Gitter Build Status Inline docs Dependency Status

NPM

Examples

VulpeJS Heroku Apptest Example.

Install

Add VulpeJS dependency in your package.json

...
"vulpejs""~0.1.39",
...

And run install:

npm install

Enjoy!

Examples

Creating a Simple CRUD

Add Model models/city.js

  "use strict";
 
  /**
   * Create City Model
   * @return {Object} Model
   */
  module.exports = vulpejs.models.make({
    name: 'City',
    schema: {
      name: {
        type: String,
        required: true,
      },
      acronym: {
        type: String,
        required: true,
      },
      status: {
        type: String,
        required: true,
        'default': 'ACTIVE',
        enum: ['ACTIVE', 'INACTIVE'],
      },
      modified: {
        type: Date,
        'default': Date.now,
      },
      user: {
        type: vulpejs.mongoose.Schema.Types.ObjectId,
        ref: 'User',
      },
    },
  });

Add Route routes/city.js

"use strict";
 
/**
 * Create City Routes
 * @return {Object} Express Router
 */
module.exports = vulpejs.routes.make({
  name: 'city',
  save: {
    data: ['name', 'acronym'],
  },
  ui: {
    controller: {
      name: 'City',
      service: {
        predicate: 'name',
        focus: 'name',
        messages: {
          validate: {
            exists: 'City already exists.',
          },
        },
        model: {
          name: '',
          acronym: '',
          status: 'ACTIVE',
        },
      },
    },
    main: {
      title: 'City',
      inputs: [{
        type: 'text',
        name: 'name',
        label: 'Name',
        capitalize: 'first',
        required: true,
      }, {
        type: 'text',
        name: 'acronym',
        label: 'Acronym',
        case: 'upper',
        required: true,
      }, ],
    },
    select: {
      title: 'City List',
      filter: {
        search: {
          colspan: 2,
        },
        status: {
          colspan: 2,
          items: [{
            value: 'ACTIVE',
            label: 'Active',
          }, {
            value: 'INACTIVE',
            label: 'Inactive',
          }, ],
        },
      },
      items: [{
        name: 'name',
        label: 'Name',
        style: {
          width: '55%',
        },
      }, {
        name: 'acronym',
        label: 'Acronym',
        style: {
          width: '10%',
        },
      }, {
        name: 'status',
        style: {
          width: '10%',
        },
        css: {
          'class': 'text-center',
        },
        switch: [{
          when: 'ACTIVE',
          image: 'status-online.png',
          title: 'Active',
        }, {
          when: 'INACTIVE',
          image: 'status-offline.png',
          title: 'Inactive',
        }, ],
        label: 'Status',
      }, {
        label: 'Actions',
        style: {
          width: '10%',
        },
      }, ],
      actions: [],
    },
  },
});

Run it:

$ npm start

And access:

http://localhost:3000/city

Package Sidebar

Install

npm i vulpejs

Weekly Downloads

268

Version

0.1.39

License

ISC

Last publish

Collaborators

  • lordfelipe