SlipCover
A framework for creating a data model web service layer on top CouchDB using Restify.
Features
- Integrates with Nano, Restify and SchemaJS
- Easily create CRUD web services for document types
- Familar Backbone like interface
- Extend and overide basic interaces with ease
Installing
npm install slipcover
Built In Routes
The SlipCover.App class comes with some built in routes based on the model type. For maximum compatability purposes all the collection names are plural and the create/update actions support both POST and PUT.
Method Route Function
-------------------------------------------------------
GET /<plural type> SlipCover.App.list()
GET /<plural type>/:id SlipCover.App.get()
PUT /<plural type> SlipCover.App.create()
POST /<plural type> SlipCover.App.create()
POST /<plural type>/:id SlipCover.App.update()
PUT /<plural type>/:id SlipCover.App.update()
DELETE /<plural type>/:id SlipCover.App.del()
The above using user
as the type
would look like this:
Method Route Function
-------------------------------------------------------
GET /users SlipCover.App.list()
GET /users/:id SlipCover.App.get()
PUT /users SlipCover.App.create()
POST /users SlipCover.App.create()
POST /users/:id SlipCover.App.update()
PUT /users/:id SlipCover.App.update()
DELETE /users/:id SlipCover.App.del()
Each SlipCover.App method has a coresponding SlipCover.model method that matches. So for SlipCover.App.get() there is a coresponding SlipCover.Model.get() that matches.
Example
var restify = ;var nano = 'http://localhost:5984'; var SlipCover = ;var _ = ; var ExampleModel = SlipCoverModel; var ExampleApp = SlipCoverApp; // Setup a connection to the databasevar exampleDb = nanodb; // When you initlaize your model you will need to pass// the database connectionvar model = conn: exampleDb ; // Pass your model to the app as an options upon initializationvar app = model: model ; // Create your Restify servervar server = restify; // Mount your application.app;
License
The MIT License (MIT) Copyright (c) 2012 Plus 3 Network
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.