Twitfinder with Express and Mongoose
Sometimes the challenges of creating new code result in a fairly loose description of what "creating" something each day means. I decided that I am going to continue working on my Twitfinder app, and want to make it into something that others can use. I am fairly new to nodejs as well as web development in general, so I want to create something fairly simple to get going.
I used the express framework in order to produce a quick form where a user could enter in a search term.
app.post('/', function(req, res) {
var searchTerm = req.body.searchTerm;
twitgrabber.startStream(searchTerm);
var twitlist = twitgrabber.getStream(searchTerm);
var html = 'We have started capturing data on the term(s) ' + searchTerm +
' and the top results (so far) are ' + twitlist;
res.send(html);
});
I also spent some time setting up a database for collecting search terms, tweets, and times.
var twitSchema = mongoose.Schema({
searchTerm: String,
username: String,
tweet: String,
date: Date
});
var Twitusers = mongoose.model('Twit', twitSchema);
As of now, today's creation is essentially a webform which has a single entry box which starts a database connection to stream in usernames, tweets, and dates. Unfortunately, the application currently only supports one connection at a time, so it isn't quite practical for primetime...yet.