# crudresources

> a simple crud resources generator using expressjs

Latest version **0.0.3** (published 2016-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install crudresources
pnpm add crudresources
yarn add crudresources
bun add crudresources
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2016-01-13 |
| First published | 2016-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rodney Sales Nogueira Jr |
| Maintainers | rodsnjr |
| Keywords | crud, expressjs, routes |

## Links

- npm: https://www.npmjs.com/package/crudresources
- npm.io page: https://npm.io/package/crudresources

## Recent versions

- 0.0.3 (latest) — 2016-01-13
- 0.0.2 — 2016-01-13
- 0.0.1 — 2016-01-13

## README

# Simple Crud Creation Library #
The routes are defined with expressjs.

# Routes #
The common routes:
* GET / for a query, you can use an json body as a filter, the json format will be restricted to the library you're using.
* POST / for the create
* PUT or PATCH /:id for updating an object
* DELETE /:id for deleting an object

# Create a Crud Route #
Creating a simple route for managing products. The default *Model engine* it's [SequelizeJS](http://docs.sequelizejs.com/en/latest/)
```javascript
var crudresource = require('crudresources');

var products = crudresource({
    model : Product,
    router : express.Router()
});

app.use('/products', products);
```
Managing events
```javascript
var products = crudresource({
    model : Product,
    router : express.Router(),
    onCreate : function(product){
        //if the name is empty
        if (!product.name){
            //ends the creation event
            return false;
        }
        //continue the creation event
        return true;
    }
});

app.use('/products', products);
```
Using other *Model engines*
```javascript
var products = crudresource({
    model : Product,
    router : express.Router(),
    engine : 'mongoose'
});
```

---
_Source: https://npm.io/package/crudresources · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
