3.4.0 • Published 7 years ago

curdy v3.4.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

curdy

Generate CRUD controllers for your express application!

NPM Version Travis Build Status Coveralls NPM Downloads

Install

npm install curdy --save

Usage

Checkout the example curdy app.

Model simple.model.js

const mongoose = require('mongoose');

module.exports = mongoose.model('SimpleModel', new mongoose.Schema({
  string: String,
  number: Number,
  date: Date,
  boolean: Boolean
}, {
  timestamps: true,
}));

Controller simpleModel.controller.js

const curdy = require('curdy');
const SimpleModel = require('./simpleModel.model');

module.exports = curdy.generateController(
  SimpleModel, // Model
  'simpleModel', // Model name
  {
    find: { // Find Template
      _id: 'params._id'
    },
    operation: { // Operation Template
      string: 'body.string',
      number: 'body.number',
      boolean: 'body.boolean'
    },
    render: { // Render Template
      _id: '_id',
      string: 'string',
      number: 'number',
      boolean: 'boolean'
    }
  }
);

Routes index.js

const express = require('express');
const Controller = require('./simpleModel.controller');
const router = express.Router();

const curdy = require('curdy');

router.use('/', curdy.generateRoutes(Controller));
// This creates the following routes
// GET    /       This is the showAll route, returning all models
// GET    /:_id   This is the show route, returning the model matched by the find
// POST   /       This is the create route, allowing the user to create a new model
// PUT    /:_id   This is the update route, allowing the user update a model
// DELETE /:_id   This is the delete route, allowing the user delete a model

module.exports = router;

Goals

  • Easy to install
  • Easy to override and extend
  • Make working with CRUD simpler and faster.

    Contributing

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.


Built with ❤️ at Hubba.

3.4.0

7 years ago

3.3.3

7 years ago

3.3.2

7 years ago

3.3.1

7 years ago

3.3.0

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago