Permalink
Browse files

Initial work in progress

  • Loading branch information...
0 parents commit 477c3419f411ac35cd40625170e9ccf51640f590 @jamesallardice committed Jan 30, 2013
Showing with 110 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +9 −0 bin/tweetserver
  3. +43 −0 lib/app.js
  4. +22 −0 lib/cli.js
  5. +8 −0 lib/routes/index.js
  6. +8 −0 lib/routes/user.js
  7. +15 −0 package.json
@@ -0,0 +1,5 @@
+# Ignore third-party node modules
+node_modules
+
+# Ignore OS X specifc files
+.DS_Store
@@ -0,0 +1,9 @@
+#!/usr/bin/env node
+
+(function () {
+
+ "use strict";
+
+ require("../lib/cli")();
+
+}());
@@ -0,0 +1,43 @@
+module.exports = function (data) {
+
+ "use strict";
+
+ var express = require("express"),
+ OAuth = require("oauth").OAuth,
+ http = require("http"),
+ path = require("path"),
+ app = express(),
+ oauth;
+
+ app.configure(function() {
+ app.set("port", process.env.PORT || 3000);
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(app.router);
+ });
+
+ oauth = new OAuth(
+ "https://api.twitter.com/oauth/request_token",
+ "https://api.twitter.com/oauth/access_token",
+ consumerKey,
+ consumerSecret,
+ "1.0A",
+ null,
+ "HMAC-SHA1",
+ null,
+ {
+ Accept: "*/*",
+ Connection: "close",
+ "User-Agent": "node-tweetserver"
+ }
+ );
+
+ app.get("/", function (req, res) {
+ oauth.get()
+ });
+
+ http.createServer(app).listen(app.get("port"), function() {
+ console.log("Express server listening on port " + app.get("port"));
+ });
+
+};
@@ -0,0 +1,22 @@
+module.exports = function () {
+
+ "use strict";
+
+ var program = require("commander");
+
+ program
+ .version("0.0.1")
+ .option("-k, --key <key>", "your Twitter API access token")
+ .option("-p, --private <secret>", "your Twitter API access token secret"),
+ .option("-c, --consumer <key>", "your Twitter application consumer token"),
+ .option("-s, --secret <secret>", "your Twitter application consumer secret");
+
+ program.parse(process.argv);
+
+ if (!program.key || !program.secret || !program.consumer || !program.private) {
+ program.help();
+ }
+
+ require("./app")(program.key, program.secret);
+
+};
@@ -0,0 +1,8 @@
+
+/*
+ * GET home page.
+ */
+
+exports.index = function(req, res){
+ res.render('index', { title: 'Express' });
+};
@@ -0,0 +1,8 @@
+
+/*
+ * GET users listing.
+ */
+
+exports.list = function(req, res){
+ res.send("respond with a resource");
+};
@@ -0,0 +1,15 @@
+{
+ "name": "tweetserver",
+ "description": "A server to proxy and cache requests to the Twitter v1.1 REST API",
+ "preferGlobal": true,
+ "author": "James Allardice <admin@jamesallardice.com>",
+ "version": "0.0.1",
+ "bin": {
+ "tweetserver": "./bin/tweetserver"
+ },
+ "dependencies": {
+ "express": "3.0.6",
+ "commander": "1.1.1",
+ "oauth": "0.9.8"
+ }
+}

0 comments on commit 477c341

Please sign in to comment.