Use camelCase

This commit is contained in:
syuilo 2019-02-24 12:53:22 +09:00
parent 7874c4ed20
commit 0e5c9df3f5
16 changed files with 34 additions and 42 deletions

View File

@ -32,16 +32,12 @@ export default function load() {
mixin.host = url.host; mixin.host = url.host;
mixin.hostname = url.hostname; mixin.hostname = url.hostname;
mixin.scheme = url.protocol.replace(/:$/, ''); mixin.scheme = url.protocol.replace(/:$/, '');
mixin.ws_scheme = mixin.scheme.replace('http', 'ws'); mixin.wsScheme = mixin.scheme.replace('http', 'ws');
mixin.ws_url = `${mixin.ws_scheme}://${mixin.host}`; mixin.wsUrl = `${mixin.wsScheme}://${mixin.host}`;
mixin.api_url = `${mixin.scheme}://${mixin.host}/api`; mixin.apiUrl = `${mixin.scheme}://${mixin.host}/api`;
mixin.auth_url = `${mixin.scheme}://${mixin.host}/auth`; mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`;
mixin.dev_url = `${mixin.scheme}://${mixin.host}/dev`; mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`;
mixin.docs_url = `${mixin.scheme}://${mixin.host}/docs`; mixin.userAgent = `Misskey/${pkg.version} (${config.url})`;
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})`;
if (config.autoAdmin == null) config.autoAdmin = false; if (config.autoAdmin == null) config.autoAdmin = false;

View File

@ -49,16 +49,12 @@ export type Mixin = {
host: string; host: string;
hostname: string; hostname: string;
scheme: string; scheme: string;
ws_scheme: string; wsScheme: string;
api_url: string; apiUrl: string;
ws_url: string; wsUrl: string;
auth_url: string; authUrl: string;
docs_url: string; driveUrl: string;
stats_url: string; userAgent: string;
status_url: string;
dev_url: string;
drive_url: string;
user_agent: string;
}; };
export type Config = Source & Mixin; export type Config = Source & Mixin;

View File

@ -14,9 +14,9 @@ export default function(file: IDriveFile, thumbnail = false): string {
} }
} else { } else {
if (thumbnail) { if (thumbnail) {
return `${config.drive_url}/${file._id}?thumbnail`; return `${config.driveUrl}/${file._id}?thumbnail`;
} else { } 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; 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 : ''}`;
} }

View File

@ -76,8 +76,8 @@ export const pack = (
} }
_app.iconUrl = _app.icon != null _app.iconUrl = _app.icon != null
? `${config.drive_url}/${_app.icon}` ? `${config.driveUrl}/${_app.icon}`
: `${config.drive_url}/app-default.jpg`; : `${config.driveUrl}/app-default.jpg`;
if (me) { if (me) {
// 既に連携しているか // 既に連携しているか

View File

@ -350,7 +350,7 @@ export const pack = (
} }
if (_user.avatarUrl == null) { 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) { if (!meId || !meId.equals(_user.id) || !opts.detail) {

View File

@ -45,7 +45,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise(async
timeout, timeout,
headers: { headers: {
'Host': host, 'Host': host,
'User-Agent': config.user_agent, 'User-Agent': config.userAgent,
'Content-Type': 'application/activity+json', 'Content-Type': 'application/activity+json',
'Digest': `SHA-256=${hash}` 'Digest': `SHA-256=${hash}`
} }

View File

@ -60,7 +60,7 @@ export default class Resolver {
proxy: config.proxy, proxy: config.proxy,
timeout: this.timeout, timeout: this.timeout,
headers: { headers: {
'User-Agent': config.user_agent, 'User-Agent': config.userAgent,
Accept: 'application/activity+json, application/ld+json' Accept: 'application/activity+json, application/ld+json'
}, },
json: true json: true

View File

@ -52,6 +52,6 @@ export default define(meta, async (ps) => {
return { return {
token: doc.token, token: doc.token,
url: `${config.auth_url}/${doc.token}` url: `${config.authUrl}/${doc.token}`
}; };
}); });

View File

@ -73,12 +73,12 @@ export default define(meta, async (ps, user) => {
'metadata.deletedAt': { $exists: false } 'metadata.deletedAt': { $exists: false }
}); });
} else if (ps.url) { } else if (ps.url) {
const isInternalStorageUrl = ps.url.startsWith(config.drive_url); const isInternalStorageUrl = ps.url.startsWith(config.driveUrl);
if (isInternalStorageUrl) { if (isInternalStorageUrl) {
// Extract file ID from url // Extract file ID from url
// e.g. // e.g.
// http://misskey.local/files/foo?original=bar --> foo // 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({ file = await DriveFile.findOne({
_id: fileId, _id: fileId,
'metadata.deletedAt': { $exists: false } 'metadata.deletedAt': { $exists: false }

View File

@ -25,7 +25,7 @@ export const description = `
#### 2. #### 2.
使 使
[${config.api_url}/auth/session/generate](#operation/auth/session/generate) appSecret [${config.apiUrl}/auth/session/generate](#operation/auth/session/generate) appSecret
JSONでPOSTです JSONでPOSTです
URLが取得できるのでURLをブラウザで表示し URLが取得できるのでURLをブラウザで表示し
@ -35,7 +35,7 @@ export const description = `
URLを設定していない場合(()) URLを設定していない場合(())
#### 3. #### 3.
[${config.api_url}/auth/session/userkey](#operation/auth/session/userkey) [${config.apiUrl}/auth/session/userkey](#operation/auth/session/userkey)

View File

@ -23,7 +23,7 @@ export function genOpenapiSpec(lang = 'ja-JP') {
}, },
servers: [{ servers: [{
url: config.api_url url: config.apiUrl
}], }],
paths: {} as any, paths: {} as any,

View File

@ -179,7 +179,7 @@ router.get('/dc/cb', async ctx => {
url: 'https://discordapp.com/api/users/@me', url: 'https://discordapp.com/api/users/@me',
headers: { headers: {
'Authorization': `Bearer ${accessToken}`, 'Authorization': `Bearer ${accessToken}`,
'User-Agent': config.user_agent 'User-Agent': config.userAgent
} }
}, (err, response, body) => { }, (err, response, body) => {
if (err) if (err)
@ -263,7 +263,7 @@ router.get('/dc/cb', async ctx => {
url: 'https://discordapp.com/api/users/@me', url: 'https://discordapp.com/api/users/@me',
headers: { headers: {
'Authorization': `Bearer ${accessToken}`, 'Authorization': `Bearer ${accessToken}`,
'User-Agent': config.user_agent 'User-Agent': config.userAgent
} }
}, (err, response, body) => { }, (err, response, body) => {
if (err) if (err)

View File

@ -171,7 +171,7 @@ router.get('/gh/cb', async ctx => {
headers: { headers: {
'Accept': 'application/vnd.github.v3+json', 'Accept': 'application/vnd.github.v3+json',
'Authorization': `bearer ${accessToken}`, 'Authorization': `bearer ${accessToken}`,
'User-Agent': config.user_agent 'User-Agent': config.userAgent
} }
}, (err, response, body) => { }, (err, response, body) => {
if (err) if (err)
@ -234,7 +234,7 @@ router.get('/gh/cb', async ctx => {
headers: { headers: {
'Accept': 'application/vnd.github.v3+json', 'Accept': 'application/vnd.github.v3+json',
'Authorization': `bearer ${accessToken}`, 'Authorization': `bearer ${accessToken}`,
'User-Agent': config.user_agent 'User-Agent': config.userAgent
} }
}, (err, response, body) => { }, (err, response, body) => {
if (err) if (err)

View File

@ -72,7 +72,7 @@ async function fetch(url: string, path: string) {
proxy: config.proxy, proxy: config.proxy,
timeout: 10 * 1000, timeout: 10 * 1000,
headers: { headers: {
'User-Agent': config.user_agent 'User-Agent': config.userAgent
} }
}); });

View File

@ -79,13 +79,13 @@ router.get('/*/*', async ctx => {
showdown.extension('wsUrlExtension', () => ({ showdown.extension('wsUrlExtension', () => ({
type: 'output', type: 'output',
regex: /%WS_URL%/g, regex: /%WS_URL%/g,
replace: config.ws_url replace: config.wsUrl
})); }));
showdown.extension('apiUrlExtension', () => ({ showdown.extension('apiUrlExtension', () => ({
type: 'output', type: 'output',
regex: /%API_URL%/g, regex: /%API_URL%/g,
replace: config.api_url replace: config.apiUrl
})); }));
const conv = new showdown.Converter({ const conv = new showdown.Converter({

View File

@ -58,7 +58,7 @@ export default async (
proxy: config.proxy, proxy: config.proxy,
timeout: 10 * 1000, timeout: 10 * 1000,
headers: { headers: {
'User-Agent': config.user_agent 'User-Agent': config.userAgent
} }
}); });