This commit is contained in:
syuilo 2018-07-06 02:58:29 +09:00
parent fcfd9239c1
commit 9b41023c43
109 changed files with 212 additions and 130 deletions

View File

@ -89,7 +89,7 @@
"autwh": "0.1.0",
"bcryptjs": "2.4.3",
"bootstrap-vue": "2.0.0-rc.11",
"cafy": "11.0.0",
"cafy": "11.1.0",
"chalk": "2.4.1",
"crc-32": "1.2.0",
"css-loader": "0.28.11",

View File

@ -16,12 +16,13 @@ import fa from '../../../build/fa';
import config from './../../../config';
import generateVars from '../vars';
import { Context } from 'cafy';
import ObjectContext from 'cafy/built/types/object';
const langs = Object.keys(locales);
const kebab = (string: string) => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
// WIP type
const parseParam = (param: any) => {
const id = param.type.match(/^id\((.+?)\)|^id/);
const entity = param.type.match(/^entity\((.+?)\)/);
@ -58,6 +59,14 @@ const parseParam = (param: any) => {
return param;
};
// WIP type
const parseEPDefParam = (key: string, param: Context) => {
return Object.assign({
name: key,
type: param.getType()
}, param.data);
};
const sortParams = (params: Array<{name: string}>) => {
params.sort((a, b) => {
if (a.name < b.name)
@ -70,17 +79,18 @@ const sortParams = (params: Array<{name: string}>) => {
};
// WIP type
const extractDefs = (params: any[]) => {
const extractDefs = (params: Context[]) => {
let defs: any[] = [];
params.forEach(param => {
if (param.def) {
if (param.data && param.data.ref) {
const props = (param as ObjectContext<any>).props;
defs.push({
name: param.defName,
params: sortParams(param.def.map((p: any) => parseParam(p)))
name: param.data.ref,
params: sortParams(Object.keys(props).map(k => parseEPDefParam(k, props[k])))
});
const childDefs = extractDefs(param.def);
const childDefs = extractDefs(Object.keys(props).map(k => props[k]));
defs = defs.concat(childDefs);
}
@ -94,35 +104,33 @@ gulp.task('doc:api', [
'doc:api:entities'
]);
gulp.task('doc:api:endpoints', async () => {
gulp.task('doc:api:endpoints', ['build:ts'], async () => {
const commonVars = await generateVars();
glob('./src/client/docs/api/endpoints/**/*.yaml', (globErr, files) => {
glob('./built/server/api/endpoints/**/*.js', (globErr, files) => {
if (globErr) {
console.error(globErr);
return;
}
//console.log(files);
files.forEach(file => {
const ep: any = yaml.safeLoad(fs.readFileSync(file, 'utf-8'));
console.log(files.map(file => require('../../../../' + file)));
files.map(file => require('../../../../' + file)).filter(x => x.meta).map(x => x.meta).forEach(ep => {
console.log(ep);
const vars = {
endpoint: ep.endpoint,
endpoint: ep.name,
url: {
host: config.api_url,
path: ep.endpoint
path: ep.name
},
desc: ep.desc,
// @ts-ignore
params: sortParams(ep.params.map(p => parseParam(p))),
params: sortParams(ep.params.map(p => parseEPDefParam(p))),
paramDefs: extractDefs(ep.params),
// @ts-ignore
res: ep.res ? sortParams(ep.res.map(p => parseParam(p))) : null,
resDefs: ep.res ? extractDefs(ep.res) : null,
};
langs.forEach(lang => {
pug.renderFile('./src/client/docs/api/endpoints/view.pug', Object.assign({}, vars, {
lang,
title: ep.endpoint,
src: `https://github.com/syuilo/misskey/tree/master/src/client/docs/api/endpoints/${ep.endpoint}.yaml`,
title: ep.name,
src: `https://github.com/syuilo/misskey/tree/master/src/client/docs/api/endpoints/${ep.name}.yaml`,
kebab,
common: commonVars
}), (renderErr, html) => {
@ -133,7 +141,7 @@ gulp.task('doc:api:endpoints', async () => {
const i18n = new I18nReplacer(lang);
html = html.replace(i18n.pattern, i18n.replacement);
html = fa(html);
const htmlPath = `./built/client/docs/${lang}/api/endpoints/${ep.endpoint}.html`;
const htmlPath = `./built/client/docs/${lang}/api/endpoints/${ep.name}.html`;
mkdirp(path.dirname(htmlPath), (mkdirErr) => {
if (mkdirErr) {
console.error(mkdirErr);

View File

@ -15,11 +15,11 @@ import I18nReplacer from '../../build/i18n';
import fa from '../../build/fa';
import generateVars from './vars';
require('./api/gulpfile.ts');
//require('./api/gulpfile.ts');
gulp.task('doc', [
'doc:docs',
'doc:api',
//'doc:api',
'doc:styles'
]);

View File

@ -4,7 +4,7 @@ import Note from '../../../../models/note';
/**
* Aggregate notes
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -4,7 +4,7 @@ import User from '../../../../models/user';
/**
* Aggregate users
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -7,7 +7,7 @@ import Note from '../../../../../models/note';
/**
* Aggregate activity of a user
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -8,7 +8,7 @@ import FollowedLog from '../../../../../models/followed-log';
/**
* Aggregate followers of a user
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -8,7 +8,7 @@ import FollowingLog from '../../../../../models/following-log';
/**
* Aggregate following of a user
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -5,7 +5,7 @@ import Note from '../../../../../models/note';
/**
* Aggregate note of a user
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -5,7 +5,7 @@ import Reaction from '../../../../../models/note-reaction';
/**
* Aggregate reaction of a user
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -59,7 +59,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Create an app
*/
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'nameId' parameter
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
if (nameIdErr) return rej('invalid nameId param');

View File

@ -40,7 +40,7 @@ import { isValidNameId } from '../../../../../models/app';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = async (params: any) => new Promise(async (res, rej) => {
export default async (params: any) => new Promise(async (res, rej) => {
// Get 'nameId' parameter
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
if (nameIdErr) return rej('invalid nameId param');

View File

@ -35,7 +35,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Show an app
*/
module.exports = (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
const isSecure = user != null && app == null;
// Get 'appId' parameter

View File

@ -32,7 +32,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Accept
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'token' parameter
const [token, tokenErr] = $.str.get(params.token);
if (tokenErr) return rej('invalid token param');

View File

@ -44,7 +44,7 @@ import config from '../../../../../config';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'appSecret' parameter
const [appSecret, appSecretErr] = $.str.get(params.appSecret);
if (appSecretErr) return rej('invalid appSecret param');

View File

@ -45,7 +45,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Show a session
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'token' parameter
const [token, tokenErr] = $.str.get(params.token);
if (tokenErr) return rej('invalid token param');

View File

@ -49,7 +49,7 @@ import { pack } from '../../../../../models/user';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'appSecret' parameter
const [appSecret, appSecretErr] = $.str.get(params.appSecret);
if (appSecretErr) return rej('invalid appSecret param');

View File

@ -4,7 +4,7 @@ import { ILocalUser } from '../../../models/user';
/**
* Get drive information
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Calculate drive usage
const usage = await DriveFile
.aggregate([{

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get drive files
*/
module.exports = async (params: any, user: ILocalUser) => {
export default async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Create a file
*/
module.exports = async (file: any, params: any, user: ILocalUser): Promise<any> => {
export default async (file: any, params: any, user: ILocalUser): Promise<any> => {
if (file == null) {
throw 'file is required';
}

View File

@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Delete a file
*/
module.exports = async (params: any, user: ILocalUser) => {
export default async (params: any, user: ILocalUser) => {
// Get 'fileId' parameter
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
if (fileIdErr) throw 'invalid fileId param';

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Find a file(s)
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = $.str.get(params.name);
if (nameErr) return rej('invalid name param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Show a file
*/
module.exports = async (params: any, user: ILocalUser) => {
export default async (params: any, user: ILocalUser) => {
// Get 'fileId' parameter
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
if (fileIdErr) throw 'invalid fileId param';

View File

@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Update a file
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'fileId' parameter
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
if (fileIdErr) return rej('invalid fileId param');

View File

@ -9,7 +9,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Create a file from a URL
*/
module.exports = async (params: any, user: ILocalUser): Promise<any> => {
export default async (params: any, user: ILocalUser): Promise<any> => {
// Get 'url' parameter
// TODO: Validate this url
const [url, urlErr] = $.str.get(params.url);

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get drive folders
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Create drive folder
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name = '無題のフォルダー', nameErr] = $.str.optional.pipe(isValidFolderName).get(params.name);
if (nameErr) return rej('invalid name param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Find a folder(s)
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = $.str.get(params.name);
if (nameErr) return rej('invalid name param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Show a folder
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'folderId' parameter
const [folderId, folderIdErr] = $.type(ID).get(params.folderId);
if (folderIdErr) return rej('invalid folderId param');

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Update a folder
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'folderId' parameter
const [folderId, folderIdErr] = $.type(ID).get(params.folderId);
if (folderIdErr) return rej('invalid folderId param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get drive stream
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -6,7 +6,7 @@ import create from '../../../../services/following/create';
/**
* Follow a user
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter

View File

@ -6,7 +6,7 @@ import deleteFollowing from '../../../../services/following/delete';
/**
* Unfollow a user
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter

View File

@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../../models/user';
/**
* Accept a follow request
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [followerId, followerIdErr] = $.type(ID).get(params.userId);
if (followerIdErr) return rej('invalid userId param');

View File

@ -5,7 +5,7 @@ import User, { pack, ILocalUser } from '../../../../../models/user';
/**
* Cancel a follow request
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [followeeId, followeeIdErr] = $.type(ID).get(params.userId);
if (followeeIdErr) return rej('invalid userId param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Get all pending received follow requests
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const reqs = await FollowRequest.find({
followeeId: user._id
});

View File

@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../../models/user';
/**
* Reject a follow request
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [followerId, followerIdErr] = $.type(ID).get(params.userId);
if (followerIdErr) return rej('invalid userId param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Stalk a user
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Unstalk a user
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter

View File

@ -15,7 +15,7 @@ const max = 5;
/**
* Get trends of hashtags
*/
module.exports = () => new Promise(async (res, rej) => {
export default () => new Promise(async (res, rej) => {
//#region 1. 直近Aの内に投稿されたハッシュタグ(とユーザーのペア)を集計
const data = await Note.aggregate([{
$match: {

View File

@ -4,7 +4,7 @@ import { IApp } from '../../../models/app';
/**
* Show myself
*/
module.exports = (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
const isSecure = user != null && app == null;
// Serialize

View File

@ -2,7 +2,7 @@ import $ from 'cafy';
import * as speakeasy from 'speakeasy';
import User, { ILocalUser } from '../../../../../models/user';
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'token' parameter
const [token, tokenErr] = $.str.get(params.token);
if (tokenErr) return rej('invalid token param');

View File

@ -5,7 +5,7 @@ import * as QRCode from 'qrcode';
import User, { ILocalUser } from '../../../../../models/user';
import config from '../../../../../config';
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'password' parameter
const [password, passwordErr] = $.str.get(params.password);
if (passwordErr) return rej('invalid password param');

View File

@ -2,7 +2,7 @@ import $ from 'cafy';
import * as bcrypt from 'bcryptjs';
import User, { ILocalUser } from '../../../../../models/user';
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'password' parameter
const [password, passwordErr] = $.str.get(params.password);
if (passwordErr) return rej('invalid password param');

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get authorized apps of my account
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../models/user';
/**
* Change password
*/
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'currentPasword' parameter
const [currentPassword, currentPasswordErr] = $.str.get(params.currentPasword);
if (currentPasswordErr) return rej('invalid currentPasword param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get favorited notes
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -9,7 +9,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get notifications
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'following' parameter
const [following = false, followingError] =
$.bool.optional.get(params.following);

View File

@ -6,7 +6,7 @@ import { pack } from '../../../../models/user';
/**
* Pin note
*/
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -7,7 +7,7 @@ import generateUserToken from '../../common/generate-native-user-token';
/**
* Regenerate native token
*/
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'password' parameter
const [password, passwordErr] = $.str.get(params.password);
if (passwordErr) return rej('invalid password param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get signin history of my account
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -8,7 +8,7 @@ import { IApp } from '../../../../models/app';
/**
* Update myself
*/
module.exports = async (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
const isSecure = user != null && app == null;
const updates = {} as any;

View File

@ -5,7 +5,7 @@ import event from '../../../../publishers/stream';
/**
* Update myself
*/
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = $.str.get(params.name);
if (nameErr) return rej('invalid name param');

View File

@ -2,7 +2,7 @@ import $ from 'cafy';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'home' parameter
const [home, homeErr] = $.arr(
$.obj.strict()

View File

@ -2,7 +2,7 @@ import $ from 'cafy';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'home' parameter
const [home, homeErr] = $.arr(
$.obj.strict()

View File

@ -2,7 +2,7 @@ import $ from 'cafy';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'id' parameter
const [id, idErr] = $.str.get(params.id);
if (idErr) return rej('invalid id param');

View File

@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Show messaging history
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -7,7 +7,7 @@ import read from '../../common/read-messaging-message';
/**
* Get messages
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
if (recipientIdErr) return rej('invalid userId param');

View File

@ -14,7 +14,7 @@ import config from '../../../../../config';
/**
* Create a message
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
if (recipientIdErr) return rej('invalid userId param');

View File

@ -38,7 +38,7 @@ const client = require('../../../../built/client/meta.json');
/**
* Show core info
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
const meta: any = (await Meta.findOne()) || {};
res({

View File

@ -5,7 +5,7 @@ import Mute from '../../../../models/mute';
/**
* Mute a user
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const muter = user;
// Get 'userId' parameter

View File

@ -5,7 +5,7 @@ import Mute from '../../../../models/mute';
/**
* Unmute a user
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const muter = user;
// Get 'userId' parameter

View File

@ -6,7 +6,7 @@ import { getFriendIds } from '../../common/get-friends';
/**
* Get muted users of a user
*/
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'iknow' parameter
const [iknow = false, iknowErr] = $.bool.optional.get(params.iknow);
if (iknowErr) return rej('invalid iknow param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get my apps
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -7,7 +7,7 @@ import Note, { pack } from '../../../models/note';
/**
* Get all notes
*/
module.exports = (params: any) => new Promise(async (res, rej) => {
export default (params: any) => new Promise(async (res, rej) => {
// Get 'local' parameter
const [local, localErr] = $.bool.optional.get(params.local);
if (localErr) return rej('invalid local param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Show conversation of a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -7,6 +7,8 @@ import { IApp } from '../../../../models/app';
import getParams from '../../get-params';
export const meta = {
name: 'notes/create',
desc: {
ja: '投稿します。'
},
@ -57,7 +59,8 @@ export const meta = {
}).optional.nullable.strict().note({
desc: {
ja: '位置情報'
}
},
ref: 'geo'
}),
mediaIds: $.arr($.type(ID)).optional.unique().range(1, 4).note({
@ -80,7 +83,8 @@ export const meta = {
}).optional.strict().note({
desc: {
ja: 'アンケート'
}
},
ref: 'poll'
})
},
@ -100,7 +104,7 @@ export const meta = {
/**
* Create a note
*/
module.exports = (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
const [ps, psErr] = getParams(meta, params);
if (psErr) return rej(psErr);

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Delete a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Favorite a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Unfavorite a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get timeline of global
*/
module.exports = async (params: any, user: ILocalUser) => {
export default async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get timeline of local
*/
module.exports = async (params: any, user: ILocalUser) => {
export default async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get mentions of myself
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'following' parameter
const [following = false, followingError] =
$.bool.optional.get(params.following);

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Get recommended polls
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -10,7 +10,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Vote poll of a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Show reactions of a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* React to a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Unreact to a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get replies of a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Show a renotes of a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
import { pack } from '../../../../models/note';
import es from '../../../../db/elasticsearch';
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'query' parameter
const [query, queryError] = $.str.get(params.query);
if (queryError) return rej('invalid query param');

View File

@ -8,7 +8,7 @@ import { pack } from '../../../../models/note';
/**
* Search notes by tag
*/
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'tag' parameter
const [tag, tagError] = $.str.get(params.tag);
if (tagError) return rej('invalid tag param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Show a note
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -8,7 +8,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get timeline of myself
*/
module.exports = async (params: any, user: ILocalUser) => {
export default async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get trend notes
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -8,7 +8,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* Get timeline of a user list
*/
module.exports = async (params: any, user: ILocalUser) => {
export default async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../models/user';
/**
* Mark as read all notifications
*/
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Update documents
await Notification.update({
notifieeId: user._id,

View File

@ -2,7 +2,7 @@ import $ from 'cafy'; import ID from '../../../../cafy-id';
import ReversiGame, { pack } from '../../../../models/reversi-game';
import { ILocalUser } from '../../../../models/user';
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'my' parameter
const [my = false, myErr] = $.bool.optional.get(params.my);
if (myErr) return rej('invalid my param');

View File

@ -3,7 +3,7 @@ import ReversiGame, { pack } from '../../../../../models/reversi-game';
import Reversi from '../../../../../reversi/core';
import { ILocalUser } from '../../../../../models/user';
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'gameId' parameter
const [gameId, gameIdErr] = $.type(ID).get(params.gameId);
if (gameIdErr) return rej('invalid gameId param');

View File

@ -1,7 +1,7 @@
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
import { ILocalUser } from '../../../../models/user';
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Find session
const invitations = await Matching.find({
childId: user._id

View File

@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../models/user';
import publishUserStream, { publishReversiStream } from '../../../../publishers/stream';
import { eighteight } from '../../../../reversi/maps';
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [childId, childIdErr] = $.type(ID).get(params.userId);
if (childIdErr) return rej('invalid userId param');

View File

@ -1,7 +1,7 @@
import Matching from '../../../../../models/reversi-matching';
import { ILocalUser } from '../../../../../models/user';
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
await Matching.remove({
parentId: user._id
});

View File

@ -3,7 +3,7 @@ import Meta from '../../../models/meta';
/**
* Get the misskey's statistics
*/
module.exports = () => new Promise(async (res, rej) => {
export default () => new Promise(async (res, rej) => {
const meta = await Meta.findOne();
res(meta.stats);

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
/**
* subscribe service worker
*/
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'endpoint' parameter
const [endpoint, endpointErr] = $.str.get(params.endpoint);
if (endpointErr) return rej('invalid endpoint param');

View File

@ -5,7 +5,7 @@ import { validateUsername } from '../../../../models/user';
/**
* Check available username
*/
module.exports = async (params: any) => new Promise(async (res, rej) => {
export default async (params: any) => new Promise(async (res, rej) => {
// Get 'username' parameter
const [username, usernameError] = $.str.pipe(validateUsername).get(params.username);
if (usernameError) return rej('invalid username param');

View File

@ -4,7 +4,7 @@ import User, { pack, ILocalUser } from '../../../models/user';
/**
* Lists all users
*/
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -7,7 +7,7 @@ import { getFriendIds } from '../../common/get-friends';
/**
* Get followers of a user
*/
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -7,7 +7,7 @@ import { getFriendIds } from '../../common/get-friends';
/**
* Get following users of a user
*/
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -2,7 +2,7 @@ import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import User, { pack, ILocalUser } from '../../../../models/user';
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
/**
* Create a user list
*/
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'title' parameter
const [title, titleErr] = $.str.range(1, 100).get(params.title);
if (titleErr) return rej('invalid title param');

Some files were not shown because too many files have changed in this diff Show More