cru

crudster

Express.js middleware to quickly create CRUD REST API for your Mongoose models

Showing:

Popularity

Downloads/wk

2

GitHub Stars

1

Maintenance

Last Commit

6yrs ago

Contributors

0

Package

Dependencies

1

Size (min+gzip)

1.0KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

crudster

Express.js middleware to quickly create CRUD REST API for your Mongoose models

Build Status

Installation

npm install crudster

Usage

Declare a Mongoose model

const PersonSchema = new mongoose.Schema({
  name: String,
  username: String,
  email: String
});

const Person  = mongoose.model('Person', PersonSchema);

Create a controller

import { BaseController } from 'crudster';
const personsController = new BaseController(Person, 'username');

Attach the controller as a middleware

import { Router } from 'express';
var api = Router();

api.use('/v1/persons', personsController.middleware());

This will result in the following API endpoints:

POST    /v1/persons             - creates a new person
GET     /v1/persons/:username    - returns a person by username
PUT     /v1/persons/:username    - updates a person with provided JSON
DELETE  /v1/persons/:username    - deletes a person

Testing

To run tests use the following command:

npm run test

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100