Skip to content

Instantly share code, notes, and snippets.

@motiooon
Created April 23, 2012 01:40
Show Gist options
  • Save motiooon/2468136 to your computer and use it in GitHub Desktop.
Save motiooon/2468136 to your computer and use it in GitHub Desktop.
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http'),
mongoose= require('mongoose');
var app = express();
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.static(__dirname + '/public'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', routes.index);
var connection = mongoose.connect('mongodb://127.0.0.1/tweetsdb');
var Schema = mongoose.Schema;
var Tweet = new Schema({
screen_name:String,
user_id:Number,
in_reply_to_status_id:Number,
in_reply_to_user_id:Number,
tweet_id:{ type:Number, index:{ unique:true}},
created_at:Date,
text:String
});
var TweetModel = mongoose.model("Tweet", Tweet);
var tweet = new TweetModel();
tweet.text = "works";
tweet.save(function(err){
console.log("it works!")
})
http.createServer(app).listen(3000);
console.log("Express server listening on port 3000");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment