cafy 5.xに移行
This commit is contained in:
@ -7,10 +7,6 @@ import { pack } from '../../../../models/app';
|
||||
|
||||
/**
|
||||
* Get authorized apps of my account
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'limit' parameter
|
||||
|
@ -7,10 +7,6 @@ import User from '../../../../models/user';
|
||||
|
||||
/**
|
||||
* Change password
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'currentPasword' parameter
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import Favorite, { pack } from '../../../../models/favorite';
|
||||
|
||||
/**
|
||||
@ -13,11 +13,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'sinceId' parameter
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$;
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$;
|
||||
if (sinceIdErr) return rej('invalid sinceId param');
|
||||
|
||||
// Get 'untilId' parameter
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.id().$;
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$;
|
||||
if (untilIdErr) return rej('invalid untilId param');
|
||||
|
||||
// Check if both of sinceId and untilId is specified
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import Notification from '../../../../models/notification';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { pack } from '../../../../models/notification';
|
||||
@ -22,7 +22,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
if (markAsReadErr) return rej('invalid markAsRead param');
|
||||
|
||||
// Get 'type' parameter
|
||||
const [type, typeErr] = $(params.type).optional.array('string').unique().$;
|
||||
const [type, typeErr] = $(params.type).optional.array($().string()).unique().$;
|
||||
if (typeErr) return rej('invalid type param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
@ -30,11 +30,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'sinceId' parameter
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$;
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$;
|
||||
if (sinceIdErr) return rej('invalid sinceId param');
|
||||
|
||||
// Get 'untilId' parameter
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.id().$;
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$;
|
||||
if (untilIdErr) return rej('invalid untilId param');
|
||||
|
||||
// Check if both of sinceId and untilId is specified
|
||||
|
@ -1,21 +1,17 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User from '../../../../models/user';
|
||||
import Note from '../../../../models/note';
|
||||
import { pack } from '../../../../models/user';
|
||||
|
||||
/**
|
||||
* Pin note
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'noteId' parameter
|
||||
const [noteId, noteIdErr] = $(params.noteId).id().$;
|
||||
const [noteId, noteIdErr] = $(params.noteId).type(ID).$;
|
||||
if (noteIdErr) return rej('invalid noteId param');
|
||||
|
||||
// Fetch pinee
|
||||
|
@ -9,10 +9,6 @@ import generateUserToken from '../../common/generate-native-user-token';
|
||||
|
||||
/**
|
||||
* Regenerate native token
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'password' parameter
|
||||
|
@ -1,15 +1,11 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import Signin, { pack } from '../../../../models/signin';
|
||||
|
||||
/**
|
||||
* Get signin history of my account
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'limit' parameter
|
||||
@ -17,11 +13,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'sinceId' parameter
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$;
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$;
|
||||
if (sinceIdErr) return rej('invalid sinceId param');
|
||||
|
||||
// Get 'untilId' parameter
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.id().$;
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$;
|
||||
if (untilIdErr) return rej('invalid untilId param');
|
||||
|
||||
// Check if both of sinceId and untilId is specified
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
||||
import event from '../../../../publishers/stream';
|
||||
|
||||
@ -32,12 +32,12 @@ module.exports = async (params, user, app) => new Promise(async (res, rej) => {
|
||||
if (birthday !== undefined) user.profile.birthday = birthday;
|
||||
|
||||
// Get 'avatarId' parameter
|
||||
const [avatarId, avatarIdErr] = $(params.avatarId).optional.id().$;
|
||||
const [avatarId, avatarIdErr] = $(params.avatarId).optional.type(ID).$;
|
||||
if (avatarIdErr) return rej('invalid avatarId param');
|
||||
if (avatarId) user.avatarId = avatarId;
|
||||
|
||||
// Get 'bannerId' parameter
|
||||
const [bannerId, bannerIdErr] = $(params.bannerId).optional.id().$;
|
||||
const [bannerId, bannerIdErr] = $(params.bannerId).optional.type(ID).$;
|
||||
if (bannerIdErr) return rej('invalid bannerId param');
|
||||
if (bannerId) user.bannerId = bannerId;
|
||||
|
||||
|
@ -7,10 +7,6 @@ import event from '../../../../publishers/stream';
|
||||
|
||||
/**
|
||||
* Update myself
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} user
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'name' parameter
|
||||
|
@ -8,7 +8,7 @@ import event from '../../../../publishers/stream';
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'home' parameter
|
||||
const [home, homeErr] = $(params.home).optional.array().each(
|
||||
$().strict.object()
|
||||
$().object(true)
|
||||
.have('name', $().string())
|
||||
.have('id', $().string())
|
||||
.have('place', $().string())
|
||||
|
@ -8,7 +8,7 @@ import event from '../../../../publishers/stream';
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'home' parameter
|
||||
const [home, homeErr] = $(params.home).optional.array().each(
|
||||
$().strict.object()
|
||||
$().object(true)
|
||||
.have('name', $().string())
|
||||
.have('id', $().string())
|
||||
.have('data', $().object())).$;
|
||||
|
Reference in New Issue
Block a user