cafy 5.xに移行

This commit is contained in:
syuilo
2018-04-24 18:13:06 +09:00
parent fd2c45cc02
commit 7602e8f938
90 changed files with 255 additions and 350 deletions

View File

@@ -8,10 +8,6 @@ import { pack } from '../../../../models/channel';
/**
* Create a channel
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
// Get 'title' parameter

View File

@@ -1,16 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import $ from 'cafy'; import ID from '../../../../cafy-id';
import { default as Channel, IChannel } from '../../../../models/channel';
import Note, { pack } from '../../../../models/note';
/**
* Show a notes of a channel
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'limit' parameter
@@ -18,11 +14,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
@@ -31,7 +27,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Get 'channelId' parameter
const [channelId, channelIdErr] = $(params.channelId).id().$;
const [channelId, channelIdErr] = $(params.channelId).type(ID).$;
if (channelIdErr) return rej('invalid channelId param');
// Fetch channel

View File

@@ -1,19 +1,15 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Channel, { IChannel, pack } from '../../../../models/channel';
/**
* Show a channel
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'channelId' parameter
const [channelId, channelIdErr] = $(params.channelId).id().$;
const [channelId, channelIdErr] = $(params.channelId).type(ID).$;
if (channelIdErr) return rej('invalid channelId param');
// Fetch channel

View File

@@ -1,20 +1,16 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Channel from '../../../../models/channel';
import Watching from '../../../../models/channel-watching';
/**
* Unwatch a channel
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'channelId' parameter
const [channelId, channelIdErr] = $(params.channelId).id().$;
const [channelId, channelIdErr] = $(params.channelId).type(ID).$;
if (channelIdErr) return rej('invalid channelId param');
//#region Fetch channel

View File

@@ -1,20 +1,16 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Channel from '../../../../models/channel';
import Watching from '../../../../models/channel-watching';
/**
* Watch a channel
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'channelId' parameter
const [channelId, channelIdErr] = $(params.channelId).id().$;
const [channelId, channelIdErr] = $(params.channelId).type(ID).$;
if (channelIdErr) return rej('invalid channelId param');
//#region Fetch channel