From 26a4d415b2573248eda086d5eb1fad90f4e2b06c Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 20 Jan 2017 11:09:54 +0900 Subject: [PATCH] [WIP] Twitter support --- package.json | 2 ++ src/api/serializers/user.ts | 1 + src/config.ts | 4 ++++ src/web/server.ts | 2 ++ src/web/service/twitter/begin.ts | 16 ++++++++++++++++ 5 files changed, 25 insertions(+) create mode 100644 src/web/service/twitter/begin.ts diff --git a/package.json b/package.json index cab0b2e7d..c01d3e113 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@types/rimraf": "0.0.28", "@types/serve-favicon": "2.2.28", "@types/shelljs": "0.3.33", + "@types/twitter": "0.0.28", "@types/uuid": "2.0.29", "@types/vinyl-buffer": "0.0.28", "@types/vinyl-source-stream": "0.0.28", @@ -143,6 +144,7 @@ "tcp-port-used": "0.1.2", "textarea-caret": "3.0.2", "tslint": "4.3.1", + "twitter": "1.7.0", "typescript": "2.1.5", "uuid": "3.0.1", "velocity-animate": "1.4.0", diff --git a/src/api/serializers/user.ts b/src/api/serializers/user.ts index cb698203b..9002285da 100644 --- a/src/api/serializers/user.ts +++ b/src/api/serializers/user.ts @@ -64,6 +64,7 @@ export default ( delete _user.password; delete _user.token; delete _user.username_lower; + delete _user.twitter; // Visible via only the official client if (!opts.includeSecrets) { diff --git a/src/config.ts b/src/config.ts index 8a6a68370..2b61bb89a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -57,6 +57,10 @@ interface ISource { secretKey: string; }; accesslog: string; + twitter: { + consumer_key: string; + consumer_secret: string; + }; } /** diff --git a/src/web/server.ts b/src/web/server.ts index 5bff450aa..6bbc66252 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -48,6 +48,8 @@ app.get(/\/api:meta/, require('./meta')); app.get(/\/api:url/, require('./service/url-preview')); app.post(/\/api:rss/, require('./service/rss-proxy')); +app.get(/\/connect:twitter/, require('./service/twitter/begin')); + /** * Subdomain */ diff --git a/src/web/service/twitter/begin.ts b/src/web/service/twitter/begin.ts new file mode 100644 index 000000000..f100913d3 --- /dev/null +++ b/src/web/service/twitter/begin.ts @@ -0,0 +1,16 @@ +import * as express from 'express'; +//import * as Twitter from 'twitter'; +import Twitter = require('twitter'); + +const client = new Twitter({ + consumer_key: process.env.TWITTER_CONSUMER_KEY, + consumer_secret: process.env.TWITTER_CONSUMER_SECRET +}); + +module.exports = (req: express.Request, res: express.Response) => { + client.get('oauth/request_token', (x, y, z) => { + console.log(x); + console.log(y); + console.log(z); + }); +};