diff options
Diffstat (limited to 'app/node_modules/okservices')
| -rw-r--r-- | app/node_modules/okservices/oks3/index.js (renamed from app/node_modules/okservices/index.js) | 17 | ||||
| -rw-r--r-- | app/node_modules/okservices/oks3/package.json | 15 | ||||
| -rw-r--r-- | app/node_modules/okservices/oktwitter/Readme.md | 6 | ||||
| -rw-r--r-- | app/node_modules/okservices/oktwitter/index.js | 48 | ||||
| -rw-r--r-- | app/node_modules/okservices/oktwitter/package.json | 13 | ||||
| -rw-r--r-- | app/node_modules/okservices/package.json | 7 |
6 files changed, 91 insertions, 15 deletions
diff --git a/app/node_modules/okservices/index.js b/app/node_modules/okservices/oks3/index.js index fbbdbfd..bd0915e 100644 --- a/app/node_modules/okservices/index.js +++ b/app/node_modules/okservices/oks3/index.js @@ -1,12 +1,13 @@ var skipper = require('skipper'); +var skipperS3 = require('skipper-s3') -function OKImageService(options) { - if (!(this instanceof OKImageService)) return new OKImageService(options); +function OKS3(options) { + if (!(this instanceof OKS3)) return new OKS3(options); options = options || {}; if (!options.express) - throw new Error('Express not provided to OKImageService'); + throw new Error('Express not provided to OKS3'); if (!options.s3) - throw new Error('S3 configuration not provided to OKImageService'); + throw new Error('S3 configuration not provided to OKS3'); var express = options.express; var router = express.Router(); @@ -17,7 +18,7 @@ function OKImageService(options) { // req should have a method `file` on it which is // provided by skipper. Use that to do AWS stuff req.file('image').upload({ - adapter: require('skipper-s3'), + adapter: skipperS3, key: options.s3.key, secret: options.s3.secret, bucket: options.s3.bucket, @@ -34,10 +35,8 @@ function OKImageService(options) { this._middleware = router; } -OKImageService.prototype.middleware = function() { +OKS3.prototype.middleware = function() { return this._middleware; }; -module.exports = { - OKImageService: OKImageService -}; +module.exports = OKS3 diff --git a/app/node_modules/okservices/oks3/package.json b/app/node_modules/okservices/oks3/package.json new file mode 100644 index 0000000..982fbfe --- /dev/null +++ b/app/node_modules/okservices/oks3/package.json @@ -0,0 +1,15 @@ +{ + "name": "oks3", + "version": "1.0.0", + "description": "s3 wassup", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "OKFocus", + "license": "None", + "dependencies": { + "skipper": "^0.5.7", + "skipper-s3": "^0.5.5" + } +} diff --git a/app/node_modules/okservices/oktwitter/Readme.md b/app/node_modules/okservices/oktwitter/Readme.md new file mode 100644 index 0000000..def73db --- /dev/null +++ b/app/node_modules/okservices/oktwitter/Readme.md @@ -0,0 +1,6 @@ +# oktwitter + +## Service to allow auth with Twitter API + +Requests to this service proxy to the twitter API, adding proper auth +credentials along the way diff --git a/app/node_modules/okservices/oktwitter/index.js b/app/node_modules/okservices/oktwitter/index.js new file mode 100644 index 0000000..ec4945d --- /dev/null +++ b/app/node_modules/okservices/oktwitter/index.js @@ -0,0 +1,48 @@ +var Twit = require('twit') + +/** + * Proxy to Twitter API adding auth creds + * TODO Technically can be abused by anyone right now. + * Should add some sort of same origin policy. + */ +function OKTwitter (options) { + if (!(this instanceof OKTwitter)) return new OKTwitter(options) + options = options || {} + if (!options.express) + throw new Error('Express not provided to OKTwitter'); + if (!options.credentials) + throw new Error('Twitter credentials not provided to OKTwitter'); + + var express = options.express + var router = express.Router() + var creds = options.credentials + var twitter = new Twit({ + consumer_key: creds.consumerKey, + consumer_secret: creds.consumerSecret, + access_token: creds.accessToken, + access_token_secret: creds.accessTokenSecret, + }) + + router.get('*', function (req, res) { + twitter.get(req.path.slice(1), req.query, function (err, data) { + if (err) { + res.status(err.statusCode) + res.send(err.twitterReply) + } else { + res.json(data) + } + }) + }) + + router.post('*', function (req, res) { + throw new Error('Twitter POST requests not implemented') + }) + + this._router = router +} + +OKTwitter.prototype.middleware = function () { + return this._router +} + +module.exports = OKTwitter diff --git a/app/node_modules/okservices/oktwitter/package.json b/app/node_modules/okservices/oktwitter/package.json new file mode 100644 index 0000000..ddee2f9 --- /dev/null +++ b/app/node_modules/okservices/oktwitter/package.json @@ -0,0 +1,13 @@ +{ + "name": "oktwitter", + "version": "1.0.0", + "description": "Allows auth to Twitter API", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "OKFocus", + "dependencies": { + "twit": "^2.1.1" + } +} diff --git a/app/node_modules/okservices/package.json b/app/node_modules/okservices/package.json index 2c95325..2669a49 100644 --- a/app/node_modules/okservices/package.json +++ b/app/node_modules/okservices/package.json @@ -6,10 +6,5 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "author": "OKFocus", - "license": "None", - "dependencies": { - "skipper": "^0.5.7", - "skipper-s3": "^0.5.5" - } + "author": "OKFocus" } |
