summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2017-04-14 20:45:37 +0900
committerAya Morisawa <AyaMorisawa4869@gmail.com>2017-04-14 20:45:37 +0900
commitb095efaee59572800244b34564692fd999cc4ded (patch)
tree89a2a1401b2af797bb687d0d79cfb5e9e52d987e /src/api
parentFix tslint.json (diff)
downloadsharkey-b095efaee59572800244b34564692fd999cc4ded.tar.gz
sharkey-b095efaee59572800244b34564692fd999cc4ded.tar.bz2
sharkey-b095efaee59572800244b34564692fd999cc4ded.zip
Migrate to tslint 5.1.0
Diffstat (limited to 'src/api')
-rw-r--r--src/api/endpoints/aggregation/posts/likes.ts2
-rw-r--r--src/api/endpoints/i/appdata/get.ts6
-rw-r--r--src/api/endpoints/i/appdata/set.ts12
-rw-r--r--src/api/endpoints/posts/create.ts54
-rw-r--r--src/api/endpoints/posts/reactions/create.ts2
-rw-r--r--src/api/endpoints/posts/reactions/delete.ts10
-rw-r--r--src/api/private/signup.ts2
-rw-r--r--src/api/server.ts4
-rw-r--r--src/api/service/github.ts4
-rw-r--r--src/api/service/twitter.ts30
10 files changed, 63 insertions, 63 deletions
diff --git a/src/api/endpoints/aggregation/posts/likes.ts b/src/api/endpoints/aggregation/posts/likes.ts
index 454368eded..5031edbffb 100644
--- a/src/api/endpoints/aggregation/posts/likes.ts
+++ b/src/api/endpoints/aggregation/posts/likes.ts
@@ -49,7 +49,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
day = new Date(day.setSeconds(59));
day = new Date(day.setMinutes(59));
day = new Date(day.setHours(23));
- //day = day.getTime();
+ // day = day.getTime();
const count = likes.filter(l =>
l.created_at < day && (l.deleted_at == null || l.deleted_at > day)
diff --git a/src/api/endpoints/i/appdata/get.ts b/src/api/endpoints/i/appdata/get.ts
index 47e1b8d202..a1a57fa13a 100644
--- a/src/api/endpoints/i/appdata/get.ts
+++ b/src/api/endpoints/i/appdata/get.ts
@@ -32,14 +32,14 @@ module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) =
} else {
const select = {};
if (key !== null) {
- select['data.' + key] = true;
+ select[`data.${key}`] = true;
}
const appdata = await Appdata.findOne({
app_id: app._id,
user_id: user._id
}, {
- fields: select
- });
+ fields: select
+ });
if (appdata) {
res(appdata.data);
diff --git a/src/api/endpoints/i/appdata/set.ts b/src/api/endpoints/i/appdata/set.ts
index eea17fd0d8..07178d6507 100644
--- a/src/api/endpoints/i/appdata/set.ts
+++ b/src/api/endpoints/i/appdata/set.ts
@@ -37,10 +37,10 @@ module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) =
let set = {};
if (data) {
Object.entries(data).forEach(([k, v]) => {
- set['data.' + k] = v;
+ set[`data.${k}`] = v;
});
} else {
- set['data.' + key] = value;
+ set[`data.${key}`] = value;
}
if (isSecure) {
@@ -63,10 +63,10 @@ module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) =
app_id: app._id,
user_id: user._id
}, {
- $set: set
- }), {
- upsert: true
- });
+ $set: set
+ }), {
+ upsert: true
+ });
res(204);
}
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts
index 9a86318d7d..9f313bc208 100644
--- a/src/api/endpoints/posts/create.ts
+++ b/src/api/endpoints/posts/create.ts
@@ -45,8 +45,8 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
_id: mediaId,
user_id: user._id
}, {
- _id: true
- });
+ _id: true
+ });
if (entity === null) {
return rej('file not found');
@@ -79,23 +79,23 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
const latestPost = await Post.findOne({
user_id: user._id
}, {
- sort: {
- _id: -1
- }
- });
+ sort: {
+ _id: -1
+ }
+ });
// 直近と同じRepost対象かつ引用じゃなかったらエラー
if (latestPost &&
- latestPost.repost_id &&
- latestPost.repost_id.equals(repost._id) &&
- text === undefined && files === null) {
+ latestPost.repost_id &&
+ latestPost.repost_id.equals(repost._id) &&
+ text === undefined && files === null) {
return rej('二重Repostです(NEED TRANSLATE)');
}
// 直近がRepost対象かつ引用じゃなかったらエラー
if (latestPost &&
- latestPost._id.equals(repost._id) &&
- text === undefined && files === null) {
+ latestPost._id.equals(repost._id) &&
+ text === undefined && files === null) {
return rej('二重Repostです(NEED TRANSLATE)');
}
}
@@ -152,11 +152,11 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
repost: user.latest_post.repost_id ? user.latest_post.repost_id.toString() : null,
media_ids: (user.latest_post.media_ids || []).map(id => id.toString())
}, {
- text: text,
- reply: inReplyToPost ? inReplyToPost._id.toString() : null,
- repost: repost ? repost._id.toString() : null,
- media_ids: (files || []).map(file => file._id.toString())
- })) {
+ text: text,
+ reply: inReplyToPost ? inReplyToPost._id.toString() : null,
+ repost: repost ? repost._id.toString() : null,
+ media_ids: (files || []).map(file => file._id.toString())
+ })) {
return rej('duplicate');
}
}
@@ -179,7 +179,7 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
// Reponse
res(postObj);
- //--------------------------------
+ // --------------------------------
// Post processes
User.update({ _id: user._id }, {
@@ -288,17 +288,17 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
if (text) {
// Analyze
const tokens = parse(text);
-/*
- // Extract a hashtags
- const hashtags = tokens
- .filter(t => t.type == 'hashtag')
- .map(t => t.hashtag)
- // Drop dupulicates
- .filter((v, i, s) => s.indexOf(v) == i);
+ /*
+ // Extract a hashtags
+ const hashtags = tokens
+ .filter(t => t.type == 'hashtag')
+ .map(t => t.hashtag)
+ // Drop dupulicates
+ .filter((v, i, s) => s.indexOf(v) == i);
- // ハッシュタグをデータベースに登録
- registerHashtags(user, hashtags);
-*/
+ // ハッシュタグをデータベースに登録
+ registerHashtags(user, hashtags);
+ */
// Extract an '@' mentions
const atMentions = tokens
.filter(t => t.type == 'mention')
diff --git a/src/api/endpoints/posts/reactions/create.ts b/src/api/endpoints/posts/reactions/create.ts
index 5425eaea02..a3b25baa6a 100644
--- a/src/api/endpoints/posts/reactions/create.ts
+++ b/src/api/endpoints/posts/reactions/create.ts
@@ -67,7 +67,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
res();
const inc = {};
- inc['reaction_counts.' + reaction] = 1;
+ inc[`reaction_counts.${reaction}`] = 1;
// Increment reactions count
await Post.update({ _id: post._id }, {
diff --git a/src/api/endpoints/posts/reactions/delete.ts b/src/api/endpoints/posts/reactions/delete.ts
index 89f6beb103..922c57ab18 100644
--- a/src/api/endpoints/posts/reactions/delete.ts
+++ b/src/api/endpoints/posts/reactions/delete.ts
@@ -42,16 +42,16 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
await Reaction.update({
_id: exist._id
}, {
- $set: {
- deleted_at: new Date()
- }
- });
+ $set: {
+ deleted_at: new Date()
+ }
+ });
// Send response
res();
const dec = {};
- dec['reaction_counts.' + exist.reaction] = -1;
+ dec[`reaction_counts.${exist.reaction}`] = -1;
// Decrement reactions count
Post.update({ _id: post._id }, {
diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts
index bd2a7ef02a..2375c22845 100644
--- a/src/api/private/signup.ts
+++ b/src/api/private/signup.ts
@@ -58,7 +58,7 @@ export default async (req: express.Request, res: express.Response) => {
const hash = bcrypt.hashSync(password, salt);
// Generate secret
- const secret = '!' + rndstr('a-zA-Z0-9', 32);
+ const secret = `!${rndstr('a-zA-Z0-9', 32)}`;
// Create account
const account = await User.insert({
diff --git a/src/api/server.ts b/src/api/server.ts
index 0b30222d38..0e059f5d2e 100644
--- a/src/api/server.ts
+++ b/src/api/server.ts
@@ -34,10 +34,10 @@ app.get('/', (req, res) => {
*/
endpoints.forEach(endpoint =>
endpoint.withFile ?
- app.post('/' + endpoint.name,
+ app.post(`/${endpoint.name}`,
endpoint.withFile ? multer({ dest: 'uploads/' }).single('file') : null,
require('./api-handler').default.bind(null, endpoint)) :
- app.post('/' + endpoint.name,
+ app.post(`/${endpoint.name}`,
require('./api-handler').default.bind(null, endpoint))
);
diff --git a/src/api/service/github.ts b/src/api/service/github.ts
index 68bc03bd5f..0d6e663419 100644
--- a/src/api/service/github.ts
+++ b/src/api/service/github.ts
@@ -22,7 +22,7 @@ module.exports = async (app: express.Application) => {
const handler = new EventEmitter();
app.post('/hooks/github', (req, res, next) => {
- if ((new Buffer(req.headers['x-hub-signature'])).equals(new Buffer('sha1=' + crypto.createHmac('sha1', config.github_bot.hook_secret).update(JSON.stringify(req.body)).digest('hex')))) {
+ if ((new Buffer(req.headers['x-hub-signature'])).equals(new Buffer(`sha1=${crypto.createHmac('sha1', config.github_bot.hook_secret).update(JSON.stringify(req.body)).digest('hex')}`))) {
handler.emit(req.headers['x-github-event'], req.body);
res.sendStatus(200);
} else {
@@ -40,7 +40,7 @@ module.exports = async (app: express.Application) => {
// Fetch parent status
request({
- url: parent.url + '/statuses',
+ url: `${parent.url}/statuses`,
headers: {
'User-Agent': 'misskey'
}
diff --git a/src/api/service/twitter.ts b/src/api/service/twitter.ts
index 160956cf92..9fb274aacb 100644
--- a/src/api/service/twitter.ts
+++ b/src/api/service/twitter.ts
@@ -1,6 +1,6 @@
import * as express from 'express';
-//import * as Twitter from 'twitter';
-//const Twitter = require('twitter');
+// import * as Twitter from 'twitter';
+// const Twitter = require('twitter');
import autwh from 'autwh';
import redis from '../../db/redis';
import User from '../models/user';
@@ -14,10 +14,10 @@ module.exports = (app: express.Application) => {
const user = await User.findOneAndUpdate({
token: res.locals.user
}, {
- $set: {
- twitter: null
- }
- });
+ $set: {
+ twitter: null
+ }
+ });
res.send(`Twitterの連携を解除しました :v:`);
@@ -38,7 +38,7 @@ module.exports = (app: express.Application) => {
const twAuth = autwh({
consumerKey: config.twitter.consumer_key,
consumerSecret: config.twitter.consumer_secret,
- callbackUrl: config.api_url + '/tw/cb'
+ callbackUrl: `${config.api_url}/tw/cb`
});
app.get('/connect/twitter', async (req, res): Promise<any> => {
@@ -56,15 +56,15 @@ module.exports = (app: express.Application) => {
const user = await User.findOneAndUpdate({
token: res.locals.user
}, {
- $set: {
- twitter: {
- access_token: result.accessToken,
- access_token_secret: result.accessTokenSecret,
- user_id: result.userId,
- screen_name: result.screenName
+ $set: {
+ twitter: {
+ access_token: result.accessToken,
+ access_token_secret: result.accessTokenSecret,
+ user_id: result.userId,
+ screen_name: result.screenName
+ }
}
- }
- });
+ });
res.send(`Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`);