summaryrefslogtreecommitdiff
path: root/src/api/endpoints/channels
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-03-28 16:39:14 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-03-28 16:39:14 +0900
commit3d5cdb8d2d60932caf1d29b0581c7d6243e06e37 (patch)
tree9c29d1062b08378d4c4cafe5976793616d45bc01 /src/api/endpoints/channels
parentwip (diff)
downloadsharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.tar.gz
sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.tar.bz2
sharkey-3d5cdb8d2d60932caf1d29b0581c7d6243e06e37.zip
wip
Diffstat (limited to 'src/api/endpoints/channels')
-rw-r--r--src/api/endpoints/channels/create.ts12
-rw-r--r--src/api/endpoints/channels/posts.ts8
-rw-r--r--src/api/endpoints/channels/show.ts6
-rw-r--r--src/api/endpoints/channels/unwatch.ts16
-rw-r--r--src/api/endpoints/channels/watch.ts20
5 files changed, 31 insertions, 31 deletions
diff --git a/src/api/endpoints/channels/create.ts b/src/api/endpoints/channels/create.ts
index 695b4515b3..1dc453c4a5 100644
--- a/src/api/endpoints/channels/create.ts
+++ b/src/api/endpoints/channels/create.ts
@@ -20,11 +20,11 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
// Create a channel
const channel = await Channel.insert({
- created_at: new Date(),
- user_id: user._id,
+ createdAt: new Date(),
+ userId: user._id,
title: title,
index: 0,
- watching_count: 1
+ watchingCount: 1
});
// Response
@@ -32,8 +32,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
// Create Watching
await Watching.insert({
- created_at: new Date(),
- user_id: user._id,
- channel_id: channel._id
+ createdAt: new Date(),
+ userId: user._id,
+ channelId: channel._id
});
});
diff --git a/src/api/endpoints/channels/posts.ts b/src/api/endpoints/channels/posts.ts
index d722589c20..7536664051 100644
--- a/src/api/endpoints/channels/posts.ts
+++ b/src/api/endpoints/channels/posts.ts
@@ -30,9 +30,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
return rej('cannot set since_id and until_id');
}
- // Get 'channel_id' parameter
- const [channelId, channelIdErr] = $(params.channel_id).id().$;
- if (channelIdErr) return rej('invalid channel_id param');
+ // Get 'channelId' parameter
+ const [channelId, channelIdErr] = $(params.channelId).id().$;
+ if (channelIdErr) return rej('invalid channelId param');
// Fetch channel
const channel: IChannel = await Channel.findOne({
@@ -49,7 +49,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
};
const query = {
- channel_id: channel._id
+ channelId: channel._id
} as any;
if (sinceId) {
diff --git a/src/api/endpoints/channels/show.ts b/src/api/endpoints/channels/show.ts
index 332da64675..5874ed18a6 100644
--- a/src/api/endpoints/channels/show.ts
+++ b/src/api/endpoints/channels/show.ts
@@ -12,9 +12,9 @@ import Channel, { IChannel, pack } from '../../models/channel';
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'channel_id' parameter
- const [channelId, channelIdErr] = $(params.channel_id).id().$;
- if (channelIdErr) return rej('invalid channel_id param');
+ // Get 'channelId' parameter
+ const [channelId, channelIdErr] = $(params.channelId).id().$;
+ if (channelIdErr) return rej('invalid channelId param');
// Fetch channel
const channel: IChannel = await Channel.findOne({
diff --git a/src/api/endpoints/channels/unwatch.ts b/src/api/endpoints/channels/unwatch.ts
index 19d3be118a..709313bc6e 100644
--- a/src/api/endpoints/channels/unwatch.ts
+++ b/src/api/endpoints/channels/unwatch.ts
@@ -13,9 +13,9 @@ import Watching from '../../models/channel-watching';
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'channel_id' parameter
- const [channelId, channelIdErr] = $(params.channel_id).id().$;
- if (channelIdErr) return rej('invalid channel_id param');
+ // Get 'channelId' parameter
+ const [channelId, channelIdErr] = $(params.channelId).id().$;
+ if (channelIdErr) return rej('invalid channelId param');
//#region Fetch channel
const channel = await Channel.findOne({
@@ -29,9 +29,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
//#region Check whether not watching
const exist = await Watching.findOne({
- user_id: user._id,
- channel_id: channel._id,
- deleted_at: { $exists: false }
+ userId: user._id,
+ channelId: channel._id,
+ deletedAt: { $exists: false }
});
if (exist === null) {
@@ -44,7 +44,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
_id: exist._id
}, {
$set: {
- deleted_at: new Date()
+ deletedAt: new Date()
}
});
@@ -54,7 +54,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Decrement watching count
Channel.update(channel._id, {
$inc: {
- watching_count: -1
+ watchingCount: -1
}
});
});
diff --git a/src/api/endpoints/channels/watch.ts b/src/api/endpoints/channels/watch.ts
index 030e0dd411..df9e70d5c2 100644
--- a/src/api/endpoints/channels/watch.ts
+++ b/src/api/endpoints/channels/watch.ts
@@ -13,9 +13,9 @@ import Watching from '../../models/channel-watching';
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
- // Get 'channel_id' parameter
- const [channelId, channelIdErr] = $(params.channel_id).id().$;
- if (channelIdErr) return rej('invalid channel_id param');
+ // Get 'channelId' parameter
+ const [channelId, channelIdErr] = $(params.channelId).id().$;
+ if (channelIdErr) return rej('invalid channelId param');
//#region Fetch channel
const channel = await Channel.findOne({
@@ -29,9 +29,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
//#region Check whether already watching
const exist = await Watching.findOne({
- user_id: user._id,
- channel_id: channel._id,
- deleted_at: { $exists: false }
+ userId: user._id,
+ channelId: channel._id,
+ deletedAt: { $exists: false }
});
if (exist !== null) {
@@ -41,9 +41,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Create Watching
await Watching.insert({
- created_at: new Date(),
- user_id: user._id,
- channel_id: channel._id
+ createdAt: new Date(),
+ userId: user._id,
+ channelId: channel._id
});
// Send response
@@ -52,7 +52,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Increment watching count
Channel.update(channel._id, {
$inc: {
- watching_count: 1
+ watchingCount: 1
}
});
});