0.1.2 • Published 12 years ago
wishbone v0.1.2
=======
Wishbone
A dead simple way to create RESTful APIs in Node.js. Built on top of MongoDB using Backbone.js.
Installation
npm install -g wishbone
Usage
- Fire up mongodb
sudo mongod
require('wishbone')
- Write your code
var express = require('express'),
http = require('http'),
path = require('path'),
_ = require('underscore'),
db = require('./db');
var app = express(),
BaseAPI = require('./api/base');
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
var scenariosAPI = new BaseAPI('scenarios', app, db);
var skusAPI = new BaseAPI('skus', app, db);
var promotionsAPI = new BaseAPI('promotions', app, db);
var historiesAPI = new BaseAPI('histories', app, db);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});