wip
This commit is contained in:
parent
fcfd9239c1
commit
9b41023c43
|
@ -89,7 +89,7 @@
|
||||||
"autwh": "0.1.0",
|
"autwh": "0.1.0",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"bootstrap-vue": "2.0.0-rc.11",
|
"bootstrap-vue": "2.0.0-rc.11",
|
||||||
"cafy": "11.0.0",
|
"cafy": "11.1.0",
|
||||||
"chalk": "2.4.1",
|
"chalk": "2.4.1",
|
||||||
"crc-32": "1.2.0",
|
"crc-32": "1.2.0",
|
||||||
"css-loader": "0.28.11",
|
"css-loader": "0.28.11",
|
||||||
|
|
|
@ -16,12 +16,13 @@ import fa from '../../../build/fa';
|
||||||
import config from './../../../config';
|
import config from './../../../config';
|
||||||
|
|
||||||
import generateVars from '../vars';
|
import generateVars from '../vars';
|
||||||
|
import { Context } from 'cafy';
|
||||||
|
import ObjectContext from 'cafy/built/types/object';
|
||||||
|
|
||||||
const langs = Object.keys(locales);
|
const langs = Object.keys(locales);
|
||||||
|
|
||||||
const kebab = (string: string) => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
|
const kebab = (string: string) => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
|
||||||
|
|
||||||
// WIP type
|
|
||||||
const parseParam = (param: any) => {
|
const parseParam = (param: any) => {
|
||||||
const id = param.type.match(/^id\((.+?)\)|^id/);
|
const id = param.type.match(/^id\((.+?)\)|^id/);
|
||||||
const entity = param.type.match(/^entity\((.+?)\)/);
|
const entity = param.type.match(/^entity\((.+?)\)/);
|
||||||
|
@ -58,6 +59,14 @@ const parseParam = (param: any) => {
|
||||||
return param;
|
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}>) => {
|
const sortParams = (params: Array<{name: string}>) => {
|
||||||
params.sort((a, b) => {
|
params.sort((a, b) => {
|
||||||
if (a.name < b.name)
|
if (a.name < b.name)
|
||||||
|
@ -70,17 +79,18 @@ const sortParams = (params: Array<{name: string}>) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// WIP type
|
// WIP type
|
||||||
const extractDefs = (params: any[]) => {
|
const extractDefs = (params: Context[]) => {
|
||||||
let defs: any[] = [];
|
let defs: any[] = [];
|
||||||
|
|
||||||
params.forEach(param => {
|
params.forEach(param => {
|
||||||
if (param.def) {
|
if (param.data && param.data.ref) {
|
||||||
|
const props = (param as ObjectContext<any>).props;
|
||||||
defs.push({
|
defs.push({
|
||||||
name: param.defName,
|
name: param.data.ref,
|
||||||
params: sortParams(param.def.map((p: any) => parseParam(p)))
|
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);
|
defs = defs.concat(childDefs);
|
||||||
}
|
}
|
||||||
|
@ -94,35 +104,33 @@ gulp.task('doc:api', [
|
||||||
'doc:api:entities'
|
'doc:api:entities'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
gulp.task('doc:api:endpoints', async () => {
|
gulp.task('doc:api:endpoints', ['build:ts'], async () => {
|
||||||
const commonVars = await generateVars();
|
const commonVars = await generateVars();
|
||||||
glob('./src/client/docs/api/endpoints/**/*.yaml', (globErr, files) => {
|
glob('./built/server/api/endpoints/**/*.js', (globErr, files) => {
|
||||||
if (globErr) {
|
if (globErr) {
|
||||||
console.error(globErr);
|
console.error(globErr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//console.log(files);
|
console.log(files.map(file => require('../../../../' + file)));
|
||||||
files.forEach(file => {
|
|
||||||
const ep: any = yaml.safeLoad(fs.readFileSync(file, 'utf-8'));
|
files.map(file => require('../../../../' + file)).filter(x => x.meta).map(x => x.meta).forEach(ep => {
|
||||||
|
console.log(ep);
|
||||||
const vars = {
|
const vars = {
|
||||||
endpoint: ep.endpoint,
|
endpoint: ep.name,
|
||||||
url: {
|
url: {
|
||||||
host: config.api_url,
|
host: config.api_url,
|
||||||
path: ep.endpoint
|
path: ep.name
|
||||||
},
|
},
|
||||||
desc: ep.desc,
|
desc: ep.desc,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
params: sortParams(ep.params.map(p => parseParam(p))),
|
params: sortParams(ep.params.map(p => parseEPDefParam(p))),
|
||||||
paramDefs: extractDefs(ep.params),
|
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 => {
|
langs.forEach(lang => {
|
||||||
pug.renderFile('./src/client/docs/api/endpoints/view.pug', Object.assign({}, vars, {
|
pug.renderFile('./src/client/docs/api/endpoints/view.pug', Object.assign({}, vars, {
|
||||||
lang,
|
lang,
|
||||||
title: ep.endpoint,
|
title: ep.name,
|
||||||
src: `https://github.com/syuilo/misskey/tree/master/src/client/docs/api/endpoints/${ep.endpoint}.yaml`,
|
src: `https://github.com/syuilo/misskey/tree/master/src/client/docs/api/endpoints/${ep.name}.yaml`,
|
||||||
kebab,
|
kebab,
|
||||||
common: commonVars
|
common: commonVars
|
||||||
}), (renderErr, html) => {
|
}), (renderErr, html) => {
|
||||||
|
@ -133,7 +141,7 @@ gulp.task('doc:api:endpoints', async () => {
|
||||||
const i18n = new I18nReplacer(lang);
|
const i18n = new I18nReplacer(lang);
|
||||||
html = html.replace(i18n.pattern, i18n.replacement);
|
html = html.replace(i18n.pattern, i18n.replacement);
|
||||||
html = fa(html);
|
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) => {
|
mkdirp(path.dirname(htmlPath), (mkdirErr) => {
|
||||||
if (mkdirErr) {
|
if (mkdirErr) {
|
||||||
console.error(mkdirErr);
|
console.error(mkdirErr);
|
||||||
|
|
|
@ -15,11 +15,11 @@ import I18nReplacer from '../../build/i18n';
|
||||||
import fa from '../../build/fa';
|
import fa from '../../build/fa';
|
||||||
import generateVars from './vars';
|
import generateVars from './vars';
|
||||||
|
|
||||||
require('./api/gulpfile.ts');
|
//require('./api/gulpfile.ts');
|
||||||
|
|
||||||
gulp.task('doc', [
|
gulp.task('doc', [
|
||||||
'doc:docs',
|
'doc:docs',
|
||||||
'doc:api',
|
//'doc:api',
|
||||||
'doc:styles'
|
'doc:styles'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Note from '../../../../models/note';
|
||||||
/**
|
/**
|
||||||
* Aggregate notes
|
* Aggregate notes
|
||||||
*/
|
*/
|
||||||
module.exports = (params: any) => new Promise(async (res, rej) => {
|
export default (params: any) => new Promise(async (res, rej) => {
|
||||||
// Get 'limit' parameter
|
// Get 'limit' parameter
|
||||||
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
|
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -4,7 +4,7 @@ import User from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Aggregate users
|
* Aggregate users
|
||||||
*/
|
*/
|
||||||
module.exports = (params: any) => new Promise(async (res, rej) => {
|
export default (params: any) => new Promise(async (res, rej) => {
|
||||||
// Get 'limit' parameter
|
// Get 'limit' parameter
|
||||||
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
|
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import Note from '../../../../../models/note';
|
||||||
/**
|
/**
|
||||||
* Aggregate activity of a user
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
|
const [limit = 365, limitErr] = $.num.optional.range(1, 365).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -8,7 +8,7 @@ import FollowedLog from '../../../../../models/followed-log';
|
||||||
/**
|
/**
|
||||||
* Aggregate followers of a user
|
* 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
|
// Get 'userId' parameter
|
||||||
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
||||||
if (userIdErr) return rej('invalid userId param');
|
if (userIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -8,7 +8,7 @@ import FollowingLog from '../../../../../models/following-log';
|
||||||
/**
|
/**
|
||||||
* Aggregate following of a user
|
* 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
|
// Get 'userId' parameter
|
||||||
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
||||||
if (userIdErr) return rej('invalid userId param');
|
if (userIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Note from '../../../../../models/note';
|
||||||
/**
|
/**
|
||||||
* Aggregate note of a user
|
* 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
|
// Get 'userId' parameter
|
||||||
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
||||||
if (userIdErr) return rej('invalid userId param');
|
if (userIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Reaction from '../../../../../models/note-reaction';
|
||||||
/**
|
/**
|
||||||
* Aggregate reaction of a user
|
* 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
|
// Get 'userId' parameter
|
||||||
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
||||||
if (userIdErr) return rej('invalid userId param');
|
if (userIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -59,7 +59,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Create an app
|
* 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
|
// Get 'nameId' parameter
|
||||||
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
|
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
|
||||||
if (nameIdErr) return rej('invalid nameId param');
|
if (nameIdErr) return rej('invalid nameId param');
|
||||||
|
|
|
@ -40,7 +40,7 @@ import { isValidNameId } from '../../../../../models/app';
|
||||||
* @param {any} params
|
* @param {any} params
|
||||||
* @return {Promise<any>}
|
* @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
|
// Get 'nameId' parameter
|
||||||
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
|
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
|
||||||
if (nameIdErr) return rej('invalid nameId param');
|
if (nameIdErr) return rej('invalid nameId param');
|
||||||
|
|
|
@ -35,7 +35,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show an app
|
* 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;
|
const isSecure = user != null && app == null;
|
||||||
|
|
||||||
// Get 'appId' parameter
|
// Get 'appId' parameter
|
||||||
|
|
|
@ -32,7 +32,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Accept
|
* 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
|
// Get 'token' parameter
|
||||||
const [token, tokenErr] = $.str.get(params.token);
|
const [token, tokenErr] = $.str.get(params.token);
|
||||||
if (tokenErr) return rej('invalid token param');
|
if (tokenErr) return rej('invalid token param');
|
||||||
|
|
|
@ -44,7 +44,7 @@ import config from '../../../../../config';
|
||||||
* @param {any} params
|
* @param {any} params
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
module.exports = (params: any) => new Promise(async (res, rej) => {
|
export default (params: any) => new Promise(async (res, rej) => {
|
||||||
// Get 'appSecret' parameter
|
// Get 'appSecret' parameter
|
||||||
const [appSecret, appSecretErr] = $.str.get(params.appSecret);
|
const [appSecret, appSecretErr] = $.str.get(params.appSecret);
|
||||||
if (appSecretErr) return rej('invalid appSecret param');
|
if (appSecretErr) return rej('invalid appSecret param');
|
||||||
|
|
|
@ -45,7 +45,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show a session
|
* 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
|
// Get 'token' parameter
|
||||||
const [token, tokenErr] = $.str.get(params.token);
|
const [token, tokenErr] = $.str.get(params.token);
|
||||||
if (tokenErr) return rej('invalid token param');
|
if (tokenErr) return rej('invalid token param');
|
||||||
|
|
|
@ -49,7 +49,7 @@ import { pack } from '../../../../../models/user';
|
||||||
* @param {any} params
|
* @param {any} params
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
module.exports = (params: any) => new Promise(async (res, rej) => {
|
export default (params: any) => new Promise(async (res, rej) => {
|
||||||
// Get 'appSecret' parameter
|
// Get 'appSecret' parameter
|
||||||
const [appSecret, appSecretErr] = $.str.get(params.appSecret);
|
const [appSecret, appSecretErr] = $.str.get(params.appSecret);
|
||||||
if (appSecretErr) return rej('invalid appSecret param');
|
if (appSecretErr) return rej('invalid appSecret param');
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { ILocalUser } from '../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get drive information
|
* 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
|
// Calculate drive usage
|
||||||
const usage = await DriveFile
|
const usage = await DriveFile
|
||||||
.aggregate([{
|
.aggregate([{
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get drive files
|
* Get drive files
|
||||||
*/
|
*/
|
||||||
module.exports = async (params: any, user: ILocalUser) => {
|
export default async (params: any, user: ILocalUser) => {
|
||||||
// Get 'limit' parameter
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) throw 'invalid limit param';
|
if (limitErr) throw 'invalid limit param';
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Create a file
|
* 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) {
|
if (file == null) {
|
||||||
throw 'file is required';
|
throw 'file is required';
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Delete a file
|
* Delete a file
|
||||||
*/
|
*/
|
||||||
module.exports = async (params: any, user: ILocalUser) => {
|
export default async (params: any, user: ILocalUser) => {
|
||||||
// Get 'fileId' parameter
|
// Get 'fileId' parameter
|
||||||
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
|
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
|
||||||
if (fileIdErr) throw 'invalid fileId param';
|
if (fileIdErr) throw 'invalid fileId param';
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Find a file(s)
|
* 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
|
// Get 'name' parameter
|
||||||
const [name, nameErr] = $.str.get(params.name);
|
const [name, nameErr] = $.str.get(params.name);
|
||||||
if (nameErr) return rej('invalid name param');
|
if (nameErr) return rej('invalid name param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show a file
|
* Show a file
|
||||||
*/
|
*/
|
||||||
module.exports = async (params: any, user: ILocalUser) => {
|
export default async (params: any, user: ILocalUser) => {
|
||||||
// Get 'fileId' parameter
|
// Get 'fileId' parameter
|
||||||
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
|
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
|
||||||
if (fileIdErr) throw 'invalid fileId param';
|
if (fileIdErr) throw 'invalid fileId param';
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Update a file
|
* 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
|
// Get 'fileId' parameter
|
||||||
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
|
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
|
||||||
if (fileIdErr) return rej('invalid fileId param');
|
if (fileIdErr) return rej('invalid fileId param');
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Create a file from a URL
|
* 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
|
// Get 'url' parameter
|
||||||
// TODO: Validate this url
|
// TODO: Validate this url
|
||||||
const [url, urlErr] = $.str.get(params.url);
|
const [url, urlErr] = $.str.get(params.url);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get drive folders
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Create drive folder
|
* 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
|
// Get 'name' parameter
|
||||||
const [name = '無題のフォルダー', nameErr] = $.str.optional.pipe(isValidFolderName).get(params.name);
|
const [name = '無題のフォルダー', nameErr] = $.str.optional.pipe(isValidFolderName).get(params.name);
|
||||||
if (nameErr) return rej('invalid name param');
|
if (nameErr) return rej('invalid name param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Find a folder(s)
|
* 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
|
// Get 'name' parameter
|
||||||
const [name, nameErr] = $.str.get(params.name);
|
const [name, nameErr] = $.str.get(params.name);
|
||||||
if (nameErr) return rej('invalid name param');
|
if (nameErr) return rej('invalid name param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show a folder
|
* 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
|
// Get 'folderId' parameter
|
||||||
const [folderId, folderIdErr] = $.type(ID).get(params.folderId);
|
const [folderId, folderIdErr] = $.type(ID).get(params.folderId);
|
||||||
if (folderIdErr) return rej('invalid folderId param');
|
if (folderIdErr) return rej('invalid folderId param');
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Update a folder
|
* 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
|
// Get 'folderId' parameter
|
||||||
const [folderId, folderIdErr] = $.type(ID).get(params.folderId);
|
const [folderId, folderIdErr] = $.type(ID).get(params.folderId);
|
||||||
if (folderIdErr) return rej('invalid folderId param');
|
if (folderIdErr) return rej('invalid folderId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get drive stream
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -6,7 +6,7 @@ import create from '../../../../services/following/create';
|
||||||
/**
|
/**
|
||||||
* Follow a user
|
* 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;
|
const follower = user;
|
||||||
|
|
||||||
// Get 'userId' parameter
|
// Get 'userId' parameter
|
||||||
|
|
|
@ -6,7 +6,7 @@ import deleteFollowing from '../../../../services/following/delete';
|
||||||
/**
|
/**
|
||||||
* Unfollow a user
|
* 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;
|
const follower = user;
|
||||||
|
|
||||||
// Get 'userId' parameter
|
// Get 'userId' parameter
|
||||||
|
|
|
@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Accept a follow request
|
* 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
|
// Get 'userId' parameter
|
||||||
const [followerId, followerIdErr] = $.type(ID).get(params.userId);
|
const [followerId, followerIdErr] = $.type(ID).get(params.userId);
|
||||||
if (followerIdErr) return rej('invalid userId param');
|
if (followerIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import User, { pack, ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Cancel a follow request
|
* 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
|
// Get 'userId' parameter
|
||||||
const [followeeId, followeeIdErr] = $.type(ID).get(params.userId);
|
const [followeeId, followeeIdErr] = $.type(ID).get(params.userId);
|
||||||
if (followeeIdErr) return rej('invalid userId param');
|
if (followeeIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get all pending received follow requests
|
* 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({
|
const reqs = await FollowRequest.find({
|
||||||
followeeId: user._id
|
followeeId: user._id
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Reject a follow request
|
* 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
|
// Get 'userId' parameter
|
||||||
const [followerId, followerIdErr] = $.type(ID).get(params.userId);
|
const [followerId, followerIdErr] = $.type(ID).get(params.userId);
|
||||||
if (followerIdErr) return rej('invalid userId param');
|
if (followerIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Stalk a 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;
|
const follower = user;
|
||||||
|
|
||||||
// Get 'userId' parameter
|
// Get 'userId' parameter
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Unstalk a 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;
|
const follower = user;
|
||||||
|
|
||||||
// Get 'userId' parameter
|
// Get 'userId' parameter
|
||||||
|
|
|
@ -15,7 +15,7 @@ const max = 5;
|
||||||
/**
|
/**
|
||||||
* Get trends of hashtags
|
* Get trends of hashtags
|
||||||
*/
|
*/
|
||||||
module.exports = () => new Promise(async (res, rej) => {
|
export default () => new Promise(async (res, rej) => {
|
||||||
//#region 1. 直近Aの内に投稿されたハッシュタグ(とユーザーのペア)を集計
|
//#region 1. 直近Aの内に投稿されたハッシュタグ(とユーザーのペア)を集計
|
||||||
const data = await Note.aggregate([{
|
const data = await Note.aggregate([{
|
||||||
$match: {
|
$match: {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { IApp } from '../../../models/app';
|
||||||
/**
|
/**
|
||||||
* Show myself
|
* 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;
|
const isSecure = user != null && app == null;
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy';
|
||||||
import * as speakeasy from 'speakeasy';
|
import * as speakeasy from 'speakeasy';
|
||||||
import User, { ILocalUser } from '../../../../../models/user';
|
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
|
// Get 'token' parameter
|
||||||
const [token, tokenErr] = $.str.get(params.token);
|
const [token, tokenErr] = $.str.get(params.token);
|
||||||
if (tokenErr) return rej('invalid token param');
|
if (tokenErr) return rej('invalid token param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as QRCode from 'qrcode';
|
||||||
import User, { ILocalUser } from '../../../../../models/user';
|
import User, { ILocalUser } from '../../../../../models/user';
|
||||||
import config from '../../../../../config';
|
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
|
// Get 'password' parameter
|
||||||
const [password, passwordErr] = $.str.get(params.password);
|
const [password, passwordErr] = $.str.get(params.password);
|
||||||
if (passwordErr) return rej('invalid password param');
|
if (passwordErr) return rej('invalid password param');
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy';
|
||||||
import * as bcrypt from 'bcryptjs';
|
import * as bcrypt from 'bcryptjs';
|
||||||
import User, { ILocalUser } from '../../../../../models/user';
|
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
|
// Get 'password' parameter
|
||||||
const [password, passwordErr] = $.str.get(params.password);
|
const [password, passwordErr] = $.str.get(params.password);
|
||||||
if (passwordErr) return rej('invalid password param');
|
if (passwordErr) return rej('invalid password param');
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get authorized apps of my account
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Change password
|
* 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
|
// Get 'currentPasword' parameter
|
||||||
const [currentPassword, currentPasswordErr] = $.str.get(params.currentPasword);
|
const [currentPassword, currentPasswordErr] = $.str.get(params.currentPasword);
|
||||||
if (currentPasswordErr) return rej('invalid currentPasword param');
|
if (currentPasswordErr) return rej('invalid currentPasword param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get favorited notes
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get notifications
|
* 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
|
// Get 'following' parameter
|
||||||
const [following = false, followingError] =
|
const [following = false, followingError] =
|
||||||
$.bool.optional.get(params.following);
|
$.bool.optional.get(params.following);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { pack } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Pin note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import generateUserToken from '../../common/generate-native-user-token';
|
||||||
/**
|
/**
|
||||||
* Regenerate native 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
|
// Get 'password' parameter
|
||||||
const [password, passwordErr] = $.str.get(params.password);
|
const [password, passwordErr] = $.str.get(params.password);
|
||||||
if (passwordErr) return rej('invalid password param');
|
if (passwordErr) return rej('invalid password param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get signin history of my account
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { IApp } from '../../../../models/app';
|
||||||
/**
|
/**
|
||||||
* Update myself
|
* 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 isSecure = user != null && app == null;
|
||||||
|
|
||||||
const updates = {} as any;
|
const updates = {} as any;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import event from '../../../../publishers/stream';
|
||||||
/**
|
/**
|
||||||
* Update myself
|
* 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
|
// Get 'name' parameter
|
||||||
const [name, nameErr] = $.str.get(params.name);
|
const [name, nameErr] = $.str.get(params.name);
|
||||||
if (nameErr) return rej('invalid name param');
|
if (nameErr) return rej('invalid name param');
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy';
|
||||||
import User, { ILocalUser } from '../../../../models/user';
|
import User, { ILocalUser } from '../../../../models/user';
|
||||||
import event from '../../../../publishers/stream';
|
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
|
// Get 'home' parameter
|
||||||
const [home, homeErr] = $.arr(
|
const [home, homeErr] = $.arr(
|
||||||
$.obj.strict()
|
$.obj.strict()
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy';
|
||||||
import User, { ILocalUser } from '../../../../models/user';
|
import User, { ILocalUser } from '../../../../models/user';
|
||||||
import event from '../../../../publishers/stream';
|
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
|
// Get 'home' parameter
|
||||||
const [home, homeErr] = $.arr(
|
const [home, homeErr] = $.arr(
|
||||||
$.obj.strict()
|
$.obj.strict()
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy';
|
||||||
import User, { ILocalUser } from '../../../../models/user';
|
import User, { ILocalUser } from '../../../../models/user';
|
||||||
import event from '../../../../publishers/stream';
|
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
|
// Get 'id' parameter
|
||||||
const [id, idErr] = $.str.get(params.id);
|
const [id, idErr] = $.str.get(params.id);
|
||||||
if (idErr) return rej('invalid id param');
|
if (idErr) return rej('invalid id param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show messaging history
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import read from '../../common/read-messaging-message';
|
||||||
/**
|
/**
|
||||||
* Get messages
|
* 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
|
// Get 'userId' parameter
|
||||||
const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
|
const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
|
||||||
if (recipientIdErr) return rej('invalid userId param');
|
if (recipientIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -14,7 +14,7 @@ import config from '../../../../../config';
|
||||||
/**
|
/**
|
||||||
* Create a message
|
* 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
|
// Get 'userId' parameter
|
||||||
const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
|
const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
|
||||||
if (recipientIdErr) return rej('invalid userId param');
|
if (recipientIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -38,7 +38,7 @@ const client = require('../../../../built/client/meta.json');
|
||||||
/**
|
/**
|
||||||
* Show core info
|
* 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()) || {};
|
const meta: any = (await Meta.findOne()) || {};
|
||||||
|
|
||||||
res({
|
res({
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Mute from '../../../../models/mute';
|
||||||
/**
|
/**
|
||||||
* Mute a user
|
* 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;
|
const muter = user;
|
||||||
|
|
||||||
// Get 'userId' parameter
|
// Get 'userId' parameter
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Mute from '../../../../models/mute';
|
||||||
/**
|
/**
|
||||||
* Unmute a user
|
* 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;
|
const muter = user;
|
||||||
|
|
||||||
// Get 'userId' parameter
|
// Get 'userId' parameter
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { getFriendIds } from '../../common/get-friends';
|
||||||
/**
|
/**
|
||||||
* Get muted users of a user
|
* 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
|
// Get 'iknow' parameter
|
||||||
const [iknow = false, iknowErr] = $.bool.optional.get(params.iknow);
|
const [iknow = false, iknowErr] = $.bool.optional.get(params.iknow);
|
||||||
if (iknowErr) return rej('invalid iknow param');
|
if (iknowErr) return rej('invalid iknow param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get my apps
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import Note, { pack } from '../../../models/note';
|
||||||
/**
|
/**
|
||||||
* Get all notes
|
* Get all notes
|
||||||
*/
|
*/
|
||||||
module.exports = (params: any) => new Promise(async (res, rej) => {
|
export default (params: any) => new Promise(async (res, rej) => {
|
||||||
// Get 'local' parameter
|
// Get 'local' parameter
|
||||||
const [local, localErr] = $.bool.optional.get(params.local);
|
const [local, localErr] = $.bool.optional.get(params.local);
|
||||||
if (localErr) return rej('invalid local param');
|
if (localErr) return rej('invalid local param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show conversation of a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -7,6 +7,8 @@ import { IApp } from '../../../../models/app';
|
||||||
import getParams from '../../get-params';
|
import getParams from '../../get-params';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
name: 'notes/create',
|
||||||
|
|
||||||
desc: {
|
desc: {
|
||||||
ja: '投稿します。'
|
ja: '投稿します。'
|
||||||
},
|
},
|
||||||
|
@ -57,7 +59,8 @@ export const meta = {
|
||||||
}).optional.nullable.strict().note({
|
}).optional.nullable.strict().note({
|
||||||
desc: {
|
desc: {
|
||||||
ja: '位置情報'
|
ja: '位置情報'
|
||||||
}
|
},
|
||||||
|
ref: 'geo'
|
||||||
}),
|
}),
|
||||||
|
|
||||||
mediaIds: $.arr($.type(ID)).optional.unique().range(1, 4).note({
|
mediaIds: $.arr($.type(ID)).optional.unique().range(1, 4).note({
|
||||||
|
@ -80,7 +83,8 @@ export const meta = {
|
||||||
}).optional.strict().note({
|
}).optional.strict().note({
|
||||||
desc: {
|
desc: {
|
||||||
ja: 'アンケート'
|
ja: 'アンケート'
|
||||||
}
|
},
|
||||||
|
ref: 'poll'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -100,7 +104,7 @@ export const meta = {
|
||||||
/**
|
/**
|
||||||
* Create a note
|
* 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);
|
const [ps, psErr] = getParams(meta, params);
|
||||||
if (psErr) return rej(psErr);
|
if (psErr) return rej(psErr);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Delete a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Favorite a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Unfavorite a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get timeline of global
|
* Get timeline of global
|
||||||
*/
|
*/
|
||||||
module.exports = async (params: any, user: ILocalUser) => {
|
export default async (params: any, user: ILocalUser) => {
|
||||||
// Get 'limit' parameter
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) throw 'invalid limit param';
|
if (limitErr) throw 'invalid limit param';
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get timeline of local
|
* Get timeline of local
|
||||||
*/
|
*/
|
||||||
module.exports = async (params: any, user: ILocalUser) => {
|
export default async (params: any, user: ILocalUser) => {
|
||||||
// Get 'limit' parameter
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) throw 'invalid limit param';
|
if (limitErr) throw 'invalid limit param';
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get mentions of myself
|
* 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
|
// Get 'following' parameter
|
||||||
const [following = false, followingError] =
|
const [following = false, followingError] =
|
||||||
$.bool.optional.get(params.following);
|
$.bool.optional.get(params.following);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get recommended polls
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Vote poll of a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show reactions of a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* React to a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Unreact to a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get replies of a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show a renotes of a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
import { pack } from '../../../../models/note';
|
import { pack } from '../../../../models/note';
|
||||||
import es from '../../../../db/elasticsearch';
|
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
|
// Get 'query' parameter
|
||||||
const [query, queryError] = $.str.get(params.query);
|
const [query, queryError] = $.str.get(params.query);
|
||||||
if (queryError) return rej('invalid query param');
|
if (queryError) return rej('invalid query param');
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { pack } from '../../../../models/note';
|
||||||
/**
|
/**
|
||||||
* Search notes by tag
|
* 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
|
// Get 'tag' parameter
|
||||||
const [tag, tagError] = $.str.get(params.tag);
|
const [tag, tagError] = $.str.get(params.tag);
|
||||||
if (tagError) return rej('invalid tag param');
|
if (tagError) return rej('invalid tag param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Show a note
|
* 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
|
// Get 'noteId' parameter
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
if (noteIdErr) return rej('invalid noteId param');
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get timeline of myself
|
* Get timeline of myself
|
||||||
*/
|
*/
|
||||||
module.exports = async (params: any, user: ILocalUser) => {
|
export default async (params: any, user: ILocalUser) => {
|
||||||
// Get 'limit' parameter
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) throw 'invalid limit param';
|
if (limitErr) throw 'invalid limit param';
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get trend notes
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Get timeline of a user list
|
* Get timeline of a user list
|
||||||
*/
|
*/
|
||||||
module.exports = async (params: any, user: ILocalUser) => {
|
export default async (params: any, user: ILocalUser) => {
|
||||||
// Get 'limit' parameter
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) throw 'invalid limit param';
|
if (limitErr) throw 'invalid limit param';
|
||||||
|
|
|
@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Mark as read all notifications
|
* 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
|
// Update documents
|
||||||
await Notification.update({
|
await Notification.update({
|
||||||
notifieeId: user._id,
|
notifieeId: user._id,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||||
import ReversiGame, { pack } from '../../../../models/reversi-game';
|
import ReversiGame, { pack } from '../../../../models/reversi-game';
|
||||||
import { ILocalUser } from '../../../../models/user';
|
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
|
// Get 'my' parameter
|
||||||
const [my = false, myErr] = $.bool.optional.get(params.my);
|
const [my = false, myErr] = $.bool.optional.get(params.my);
|
||||||
if (myErr) return rej('invalid my param');
|
if (myErr) return rej('invalid my param');
|
||||||
|
|
|
@ -3,7 +3,7 @@ import ReversiGame, { pack } from '../../../../../models/reversi-game';
|
||||||
import Reversi from '../../../../../reversi/core';
|
import Reversi from '../../../../../reversi/core';
|
||||||
import { ILocalUser } from '../../../../../models/user';
|
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
|
// Get 'gameId' parameter
|
||||||
const [gameId, gameIdErr] = $.type(ID).get(params.gameId);
|
const [gameId, gameIdErr] = $.type(ID).get(params.gameId);
|
||||||
if (gameIdErr) return rej('invalid gameId param');
|
if (gameIdErr) return rej('invalid gameId param');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
|
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
|
||||||
import { ILocalUser } from '../../../../models/user';
|
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
|
// Find session
|
||||||
const invitations = await Matching.find({
|
const invitations = await Matching.find({
|
||||||
childId: user._id
|
childId: user._id
|
||||||
|
|
|
@ -5,7 +5,7 @@ import User, { ILocalUser } from '../../../../models/user';
|
||||||
import publishUserStream, { publishReversiStream } from '../../../../publishers/stream';
|
import publishUserStream, { publishReversiStream } from '../../../../publishers/stream';
|
||||||
import { eighteight } from '../../../../reversi/maps';
|
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
|
// Get 'userId' parameter
|
||||||
const [childId, childIdErr] = $.type(ID).get(params.userId);
|
const [childId, childIdErr] = $.type(ID).get(params.userId);
|
||||||
if (childIdErr) return rej('invalid userId param');
|
if (childIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Matching from '../../../../../models/reversi-matching';
|
import Matching from '../../../../../models/reversi-matching';
|
||||||
import { ILocalUser } from '../../../../../models/user';
|
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({
|
await Matching.remove({
|
||||||
parentId: user._id
|
parentId: user._id
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Meta from '../../../models/meta';
|
||||||
/**
|
/**
|
||||||
* Get the misskey's statistics
|
* Get the misskey's statistics
|
||||||
*/
|
*/
|
||||||
module.exports = () => new Promise(async (res, rej) => {
|
export default () => new Promise(async (res, rej) => {
|
||||||
const meta = await Meta.findOne();
|
const meta = await Meta.findOne();
|
||||||
|
|
||||||
res(meta.stats);
|
res(meta.stats);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* subscribe service worker
|
* 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
|
// Get 'endpoint' parameter
|
||||||
const [endpoint, endpointErr] = $.str.get(params.endpoint);
|
const [endpoint, endpointErr] = $.str.get(params.endpoint);
|
||||||
if (endpointErr) return rej('invalid endpoint param');
|
if (endpointErr) return rej('invalid endpoint param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { validateUsername } from '../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Check available username
|
* 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
|
// Get 'username' parameter
|
||||||
const [username, usernameError] = $.str.pipe(validateUsername).get(params.username);
|
const [username, usernameError] = $.str.pipe(validateUsername).get(params.username);
|
||||||
if (usernameError) return rej('invalid username param');
|
if (usernameError) return rej('invalid username param');
|
||||||
|
|
|
@ -4,7 +4,7 @@ import User, { pack, ILocalUser } from '../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Lists all users
|
* 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
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||||
if (limitErr) return rej('invalid limit param');
|
if (limitErr) return rej('invalid limit param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { getFriendIds } from '../../common/get-friends';
|
||||||
/**
|
/**
|
||||||
* Get followers of a user
|
* 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
|
// Get 'userId' parameter
|
||||||
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
||||||
if (userIdErr) return rej('invalid userId param');
|
if (userIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { getFriendIds } from '../../common/get-friends';
|
||||||
/**
|
/**
|
||||||
* Get following users of a user
|
* 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
|
// Get 'userId' parameter
|
||||||
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
||||||
if (userIdErr) return rej('invalid userId param');
|
if (userIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import User, { pack, ILocalUser } from '../../../../models/user';
|
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
|
// Get 'userId' parameter
|
||||||
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
const [userId, userIdErr] = $.type(ID).get(params.userId);
|
||||||
if (userIdErr) return rej('invalid userId param');
|
if (userIdErr) return rej('invalid userId param');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ILocalUser } from '../../../../../models/user';
|
||||||
/**
|
/**
|
||||||
* Create a user list
|
* 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
|
// Get 'title' parameter
|
||||||
const [title, titleErr] = $.str.range(1, 100).get(params.title);
|
const [title, titleErr] = $.str.range(1, 100).get(params.title);
|
||||||
if (titleErr) return rej('invalid title param');
|
if (titleErr) return rej('invalid title param');
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue