From 9b79a411e0d0ecd57c52f0878d2873f925eebc4f Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 24 Feb 2019 12:53:22 +0900 Subject: [PATCH] Use camelCase --- src/config/load.ts | 16 ++++++---------- src/config/types.ts | 16 ++++++---------- src/misc/get-drive-file-url.ts | 6 +++--- src/models/app.ts | 4 ++-- src/models/user.ts | 2 +- src/remote/activitypub/request.ts | 2 +- src/remote/activitypub/resolver.ts | 2 +- .../api/endpoints/auth/session/generate.ts | 2 +- src/server/api/endpoints/drive/files/show.ts | 4 ++-- src/server/api/openapi/description.ts | 4 ++-- src/server/api/openapi/gen-spec.ts | 2 +- src/server/api/service/discord.ts | 4 ++-- src/server/api/service/github.ts | 4 ++-- src/server/proxy/proxy-media.ts | 2 +- src/server/web/docs.ts | 4 ++-- src/services/drive/upload-from-url.ts | 2 +- 16 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/config/load.ts b/src/config/load.ts index 3a82d45b4..7a4323817 100644 --- a/src/config/load.ts +++ b/src/config/load.ts @@ -32,16 +32,12 @@ export default function load() { mixin.host = url.host; mixin.hostname = url.hostname; mixin.scheme = url.protocol.replace(/:$/, ''); - mixin.ws_scheme = mixin.scheme.replace('http', 'ws'); - mixin.ws_url = `${mixin.ws_scheme}://${mixin.host}`; - mixin.api_url = `${mixin.scheme}://${mixin.host}/api`; - mixin.auth_url = `${mixin.scheme}://${mixin.host}/auth`; - mixin.dev_url = `${mixin.scheme}://${mixin.host}/dev`; - mixin.docs_url = `${mixin.scheme}://${mixin.host}/docs`; - mixin.stats_url = `${mixin.scheme}://${mixin.host}/stats`; - mixin.status_url = `${mixin.scheme}://${mixin.host}/status`; - mixin.drive_url = `${mixin.scheme}://${mixin.host}/files`; - mixin.user_agent = `Misskey/${pkg.version} (${config.url})`; + mixin.wsScheme = mixin.scheme.replace('http', 'ws'); + mixin.wsUrl = `${mixin.wsScheme}://${mixin.host}`; + mixin.apiUrl = `${mixin.scheme}://${mixin.host}/api`; + mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`; + mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`; + mixin.userAgent = `Misskey/${pkg.version} (${config.url})`; if (config.autoAdmin == null) config.autoAdmin = false; diff --git a/src/config/types.ts b/src/config/types.ts index 2ce9c0c80..51b76262a 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -49,16 +49,12 @@ export type Mixin = { host: string; hostname: string; scheme: string; - ws_scheme: string; - api_url: string; - ws_url: string; - auth_url: string; - docs_url: string; - stats_url: string; - status_url: string; - dev_url: string; - drive_url: string; - user_agent: string; + wsScheme: string; + apiUrl: string; + wsUrl: string; + authUrl: string; + driveUrl: string; + userAgent: string; }; export type Config = Source & Mixin; diff --git a/src/misc/get-drive-file-url.ts b/src/misc/get-drive-file-url.ts index c52659522..067db8a5d 100644 --- a/src/misc/get-drive-file-url.ts +++ b/src/misc/get-drive-file-url.ts @@ -14,9 +14,9 @@ export default function(file: IDriveFile, thumbnail = false): string { } } else { if (thumbnail) { - return `${config.drive_url}/${file._id}?thumbnail`; + return `${config.driveUrl}/${file._id}?thumbnail`; } else { - return `${config.drive_url}/${file._id}?web`; + return `${config.driveUrl}/${file._id}?web`; } } } @@ -27,5 +27,5 @@ export function getOriginalUrl(file: IDriveFile) { } const accessKey = file.metadata ? file.metadata.accessKey : null; - return `${config.drive_url}/${file._id}${accessKey ? '?original=' + accessKey : ''}`; + return `${config.driveUrl}/${file._id}${accessKey ? '?original=' + accessKey : ''}`; } diff --git a/src/models/app.ts b/src/models/app.ts index 14642e731..5c8d2cbd5 100644 --- a/src/models/app.ts +++ b/src/models/app.ts @@ -76,8 +76,8 @@ export const pack = ( } _app.iconUrl = _app.icon != null - ? `${config.drive_url}/${_app.icon}` - : `${config.drive_url}/app-default.jpg`; + ? `${config.driveUrl}/${_app.icon}` + : `${config.driveUrl}/app-default.jpg`; if (me) { // 既に連携しているか diff --git a/src/models/user.ts b/src/models/user.ts index c8ec7e511..97c703793 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -350,7 +350,7 @@ export const pack = ( } if (_user.avatarUrl == null) { - _user.avatarUrl = `${config.drive_url}/default-avatar.jpg`; + _user.avatarUrl = `${config.driveUrl}/default-avatar.jpg`; } if (!meId || !meId.equals(_user.id) || !opts.detail) { diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index df8eced13..a92197239 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -45,7 +45,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise(async timeout, headers: { 'Host': host, - 'User-Agent': config.user_agent, + 'User-Agent': config.userAgent, 'Content-Type': 'application/activity+json', 'Digest': `SHA-256=${hash}` } diff --git a/src/remote/activitypub/resolver.ts b/src/remote/activitypub/resolver.ts index 049e645e4..113b2c4e4 100644 --- a/src/remote/activitypub/resolver.ts +++ b/src/remote/activitypub/resolver.ts @@ -60,7 +60,7 @@ export default class Resolver { proxy: config.proxy, timeout: this.timeout, headers: { - 'User-Agent': config.user_agent, + 'User-Agent': config.userAgent, Accept: 'application/activity+json, application/ld+json' }, json: true diff --git a/src/server/api/endpoints/auth/session/generate.ts b/src/server/api/endpoints/auth/session/generate.ts index 9473aa943..ddbd7209c 100644 --- a/src/server/api/endpoints/auth/session/generate.ts +++ b/src/server/api/endpoints/auth/session/generate.ts @@ -52,6 +52,6 @@ export default define(meta, async (ps) => { return { token: doc.token, - url: `${config.auth_url}/${doc.token}` + url: `${config.authUrl}/${doc.token}` }; }); diff --git a/src/server/api/endpoints/drive/files/show.ts b/src/server/api/endpoints/drive/files/show.ts index c2442c65c..6d63a8605 100644 --- a/src/server/api/endpoints/drive/files/show.ts +++ b/src/server/api/endpoints/drive/files/show.ts @@ -73,12 +73,12 @@ export default define(meta, async (ps, user) => { 'metadata.deletedAt': { $exists: false } }); } else if (ps.url) { - const isInternalStorageUrl = ps.url.startsWith(config.drive_url); + const isInternalStorageUrl = ps.url.startsWith(config.driveUrl); if (isInternalStorageUrl) { // Extract file ID from url // e.g. // http://misskey.local/files/foo?original=bar --> foo - const fileId = new mongo.ObjectID(ps.url.replace(config.drive_url, '').replace(/\?(.*)$/, '').replace(/\//g, '')); + const fileId = new mongo.ObjectID(ps.url.replace(config.driveUrl, '').replace(/\?(.*)$/, '').replace(/\//g, '')); file = await DriveFile.findOne({ _id: fileId, 'metadata.deletedAt': { $exists: false } diff --git a/src/server/api/openapi/description.ts b/src/server/api/openapi/description.ts index 83250c341..cc5f233c5 100644 --- a/src/server/api/openapi/description.ts +++ b/src/server/api/openapi/description.ts @@ -25,7 +25,7 @@ export const description = ` #### 2.ユーザーに認証させる アプリを使ってもらうには、ユーザーにアカウントへのアクセスの許可をもらう必要があります。 -認証セッションを開始するには、[${config.api_url}/auth/session/generate](#operation/auth/session/generate) へパラメータに appSecret としてシークレットキーを含めたリクエストを送信します。 +認証セッションを開始するには、[${config.apiUrl}/auth/session/generate](#operation/auth/session/generate) へパラメータに appSecret としてシークレットキーを含めたリクエストを送信します。 リクエスト形式はJSONで、メソッドはPOSTです。 レスポンスとして認証セッションのトークンや認証フォームのURLが取得できるので、認証フォームのURLをブラウザで表示し、ユーザーにフォームを提示してください。 @@ -35,7 +35,7 @@ export const description = ` あなたのアプリがコールバックURLを設定していない場合、ユーザーがあなたのアプリの連携を許可したことを(何らかの方法で(たとえばボタンを押させるなど))確認出来るようにしてください。 #### 3.ユーザートークンを取得する -ユーザーが連携を許可したら、[${config.api_url}/auth/session/userkey](#operation/auth/session/userkey) へリクエストを送信します。 +ユーザーが連携を許可したら、[${config.apiUrl}/auth/session/userkey](#operation/auth/session/userkey) へリクエストを送信します。 上手くいけば、認証したユーザーのユーザートークンがレスポンスとして取得できます。おめでとうございます! diff --git a/src/server/api/openapi/gen-spec.ts b/src/server/api/openapi/gen-spec.ts index 748791823..fd69569e6 100644 --- a/src/server/api/openapi/gen-spec.ts +++ b/src/server/api/openapi/gen-spec.ts @@ -23,7 +23,7 @@ export function genOpenapiSpec(lang = 'ja-JP') { }, servers: [{ - url: config.api_url + url: config.apiUrl }], paths: {} as any, diff --git a/src/server/api/service/discord.ts b/src/server/api/service/discord.ts index af0c43b48..92f5bbf72 100644 --- a/src/server/api/service/discord.ts +++ b/src/server/api/service/discord.ts @@ -179,7 +179,7 @@ router.get('/dc/cb', async ctx => { url: 'https://discordapp.com/api/users/@me', headers: { 'Authorization': `Bearer ${accessToken}`, - 'User-Agent': config.user_agent + 'User-Agent': config.userAgent } }, (err, response, body) => { if (err) @@ -263,7 +263,7 @@ router.get('/dc/cb', async ctx => { url: 'https://discordapp.com/api/users/@me', headers: { 'Authorization': `Bearer ${accessToken}`, - 'User-Agent': config.user_agent + 'User-Agent': config.userAgent } }, (err, response, body) => { if (err) diff --git a/src/server/api/service/github.ts b/src/server/api/service/github.ts index d6d5d1ecc..cf3589a4b 100644 --- a/src/server/api/service/github.ts +++ b/src/server/api/service/github.ts @@ -171,7 +171,7 @@ router.get('/gh/cb', async ctx => { headers: { 'Accept': 'application/vnd.github.v3+json', 'Authorization': `bearer ${accessToken}`, - 'User-Agent': config.user_agent + 'User-Agent': config.userAgent } }, (err, response, body) => { if (err) @@ -234,7 +234,7 @@ router.get('/gh/cb', async ctx => { headers: { 'Accept': 'application/vnd.github.v3+json', 'Authorization': `bearer ${accessToken}`, - 'User-Agent': config.user_agent + 'User-Agent': config.userAgent } }, (err, response, body) => { if (err) diff --git a/src/server/proxy/proxy-media.ts b/src/server/proxy/proxy-media.ts index 3f234a727..c679086d3 100644 --- a/src/server/proxy/proxy-media.ts +++ b/src/server/proxy/proxy-media.ts @@ -72,7 +72,7 @@ async function fetch(url: string, path: string) { proxy: config.proxy, timeout: 10 * 1000, headers: { - 'User-Agent': config.user_agent + 'User-Agent': config.userAgent } }); diff --git a/src/server/web/docs.ts b/src/server/web/docs.ts index 414aac02c..d9ba14a8e 100644 --- a/src/server/web/docs.ts +++ b/src/server/web/docs.ts @@ -79,13 +79,13 @@ router.get('/*/*', async ctx => { showdown.extension('wsUrlExtension', () => ({ type: 'output', regex: /%WS_URL%/g, - replace: config.ws_url + replace: config.wsUrl })); showdown.extension('apiUrlExtension', () => ({ type: 'output', regex: /%API_URL%/g, - replace: config.api_url + replace: config.apiUrl })); const conv = new showdown.Converter({ diff --git a/src/services/drive/upload-from-url.ts b/src/services/drive/upload-from-url.ts index 8daecbadb..1651afa27 100644 --- a/src/services/drive/upload-from-url.ts +++ b/src/services/drive/upload-from-url.ts @@ -58,7 +58,7 @@ export default async ( proxy: config.proxy, timeout: 10 * 1000, headers: { - 'User-Agent': config.user_agent + 'User-Agent': config.userAgent } });