dresscode
v1.0.1
Published
Advanced RESTful extension for Express+Mongoose
Downloads
5
Maintainers
Readme
DressCode
Advanced RESTful extension for Node.js + Express + Mongoose
var express = require('express');
var app = express();
app.set('views', __dirname);
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var Data = mongoose.model('Data', { name: String });
var dc = require('dresscode');
new dc.Add().reg(app, '/data', 'post', null, Data);
new dc.Upd().reg(app, '/data/:id', 'put', null, Data);
new dc.Del().reg(app, '/data/:id', 'delete', null, Data);
new dc.Get().reg(app, '/data/:id', 'get', null, Data, 'obj.ejs');
new dc.List().reg(app, '/data', 'get', null, Data, 'list.ejs');
app.use(function(err, req, res, next) {
res.render('err.ejs', { message: err.message });
});
app.listen(3000);
Installation
Install Express + Mongoose:
$ npm install express
$ npm install mongoose
Install Dresscode:
$ npm install dresscode
About
DressCode is not a standalone library, it is the advanced RESTful extension for Node.js + Express + Mongoose.
The most common tasks of RESTful API development have been implemented and available as a set of customizable templates. You can use these templates as is, tailor them for your needs or create your own templates.
The library is designed to make your life better without any unnecessary requirements and restrictions. It can be used partly, for example for scheduling only, and it will not conflict with your other Express-based functionality.
The library is also compatible with Passport - based authentication middleware.
Features
- Customizable templates for basic REST operations (GET, PUT, POST, DELETE)
- Customizable templates for list operations (list, find) with paging and advanced query syntax for sorting and filtering
- Customizable "fuse" templates for update and delete operations
- Customizable templates for file download/upload/remove
- Customizable templates for user data processing
- Customizable template for server jobs
- Advanced scheduler for server jobs
- Reference-resolving functionality (alternative to Mongoose "populate" feature)
- Reference-removing functionality (can also be used for cascade remove)
- Tags-based text search support (a simple alternative to MongoDB text search)
- Role-based and ownership-based security for all available templates
- Manual API calls on the server side for all dresscode-based REST operations with "promise" chaining syntax
- Customizable "load balancer" for all dresscode-based REST operations (with configurable "weights")
- Hooks and stats for all dresscode-based REST operations
- "Asynchronous" client-to-server calls feature
- Subdocuments processing with ownership-based security
- Operation "freezing" feature for additional code safety
- Support for Passport-based authentication middleware
Examples
Clone the DressCode repository, then install all the example suite dependencies:
$ git clone git://github.com/mileait/dresscode.git --depth 1
$ cd dresscode
$ npm install
Contributors
Author: MileAit
License
Public Domain - Unlicense
All the code is original, written from the scratch to avoid any possible license conflicts.