diff --git a/package.json b/package.json index d37bbc040d..515d8e8401 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@prezzemolo/rap": "0.1.2", "@prezzemolo/zip": "0.0.3", "@types/bcryptjs": "2.4.1", - "@types/chai": "4.1.2", + "@types/chai": "4.1.3", "@types/chai-http": "3.0.4", "@types/debug": "0.0.30", "@types/deep-equal": "1.0.1", @@ -51,22 +51,22 @@ "@types/js-yaml": "3.11.1", "@types/koa": "2.0.45", "@types/koa-bodyparser": "4.2.0", - "@types/koa-compress": "^2.0.8", + "@types/koa-compress": "2.0.8", "@types/koa-favicon": "2.0.19", - "@types/koa-logger": "^3.1.0", + "@types/koa-logger": "3.1.0", "@types/koa-mount": "3.0.1", "@types/koa-multer": "1.0.0", - "@types/koa-router": "7.0.27", + "@types/koa-router": "7.0.28", "@types/koa-send": "4.1.1", "@types/koa__cors": "2.2.2", "@types/kue": "0.11.8", "@types/license-checker": "15.0.0", "@types/mkdirp": "0.5.2", - "@types/mocha": "5.0.0", + "@types/mocha": "5.2.0", "@types/mongodb": "3.0.15", "@types/monk": "6.0.0", "@types/ms": "0.7.30", - "@types/node": "9.6.5", + "@types/node": "9.6.6", "@types/nopt": "3.0.29", "@types/pug": "2.0.4", "@types/qrcode": "0.8.1", @@ -79,7 +79,7 @@ "@types/speakeasy": "2.0.2", "@types/tmp": "0.0.33", "@types/uuid": "3.4.3", - "@types/webpack": "4.1.3", + "@types/webpack": "4.1.4", "@types/webpack-stream": "3.2.10", "@types/websocket": "0.0.38", "@types/ws": "4.0.2", @@ -88,10 +88,10 @@ "autwh": "0.1.0", "bcryptjs": "2.4.3", "bootstrap-vue": "2.0.0-rc.6", - "cafy": "6.0.0", + "cafy": "7.0.1", "chai": "4.1.2", "chai-http": "4.0.0", - "chalk": "2.4.0", + "chalk": "2.4.1", "crc-32": "1.2.0", "css-loader": "0.28.11", "debug": "3.1.0", @@ -100,12 +100,12 @@ "diskusage": "0.2.4", "dompurify": "1.0.3", "elasticsearch": "14.2.2", - "element-ui": "2.3.4", + "element-ui": "2.3.6", "emojilib": "2.2.12", "escape-regexp": "0.0.1", "eslint": "4.19.1", - "eslint-plugin-vue": "4.4.0", - "eventemitter3": "3.0.1", + "eslint-plugin-vue": "4.5.0", + "eventemitter3": "3.1.0", "exif-js": "2.3.0", "file-loader": "1.1.11", "file-type": "7.6.0", @@ -133,30 +133,30 @@ "is-root": "2.0.0", "is-url": "1.2.4", "js-yaml": "3.11.0", - "jsdom": "11.8.0", - "koa": "2.5.0", + "jsdom": "11.9.0", + "koa": "2.5.1", "koa-bodyparser": "4.2.0", "koa-compress": "3.0.0", "koa-favicon": "2.0.1", - "koa-json-body": "^5.3.0", - "koa-logger": "^3.2.0", + "koa-json-body": "5.3.0", + "koa-logger": "3.2.0", "koa-mount": "3.0.0", "koa-multer": "1.0.2", "koa-router": "7.4.0", "koa-send": "4.1.3", - "koa-slow": "^2.1.0", + "koa-slow": "2.1.0", "kue": "0.11.6", "license-checker": "18.0.0", "loader-utils": "1.1.0", "mecab-async": "0.1.2", "mkdirp": "0.5.1", - "mocha": "5.1.0", + "mocha": "5.1.1", "moji": "0.5.1", "mongodb": "3.0.7", "monk": "6.0.5", "ms": "2.1.1", "nan": "2.10.0", - "node-sass": "4.8.3", + "node-sass": "4.9.0", "node-sass-json-importer": "3.2.0", "nopt": "4.0.1", "nprogress": "0.2.0", @@ -190,9 +190,9 @@ "textarea-caret": "3.1.0", "tmp": "0.0.33", "ts-loader": "4.2.0", - "ts-node": "6.0.0", + "ts-node": "6.0.1", "tslint": "5.9.1", - "typescript": "2.8.1", + "typescript": "2.8.3", "typescript-eslint-parser": "15.0.0", "uglify-es": "3.3.9", "url-loader": "1.0.1", @@ -201,18 +201,18 @@ "vue": "2.5.16", "vue-cropperjs": "2.2.0", "vue-js-modal": "1.3.13", - "vue-json-tree-view": "2.1.3", - "vue-loader": "14.2.2", + "vue-json-tree-view": "2.1.4", + "vue-loader": "15.0.3", "vue-router": "3.0.1", "vue-template-compiler": "2.5.16", "vuedraggable": "2.16.0", - "vuex": "^3.0.1", + "vuex": "3.0.1", "web-push": "3.3.0", "webfinger.js": "2.6.6", "webpack": "4.6.0", - "webpack-cli": "2.0.14", + "webpack-cli": "2.0.15", "webpack-replace-loader": "1.3.0", - "websocket": "1.0.25", + "websocket": "1.0.26", "ws": "5.1.1", "xev": "2.0.0" } diff --git a/src/client/app/desktop/views/pages/welcome.vue b/src/client/app/desktop/views/pages/welcome.vue index 93d17b58fe..6bda29326f 100644 --- a/src/client/app/desktop/views/pages/welcome.vue +++ b/src/client/app/desktop/views/pages/welcome.vue @@ -125,7 +125,8 @@ export default Vue.extend({ flex 1 $width = 1000px - background-image url('/assets/welcome-bg.svg') + background linear-gradient(to bottom, #1e1d65, #bd6659) + //background-image url('/assets/welcome-bg.svg') background-size cover background-position top center @@ -309,9 +310,3 @@ export default Vue.extend({ a color #666 - - diff --git a/src/client/app/mobile/views/pages/welcome.vue b/src/client/app/mobile/views/pages/welcome.vue index 27baf8bee4..1bc7ffd862 100644 --- a/src/client/app/mobile/views/pages/welcome.vue +++ b/src/client/app/mobile/views/pages/welcome.vue @@ -1,33 +1,35 @@ @@ -84,123 +86,120 @@ export default Vue.extend({ - - diff --git a/src/models/note-reaction.ts b/src/models/note-reaction.ts index f78b0d9d01..7891ebdf17 100644 --- a/src/models/note-reaction.ts +++ b/src/models/note-reaction.ts @@ -1,5 +1,5 @@ import * as mongo from 'mongodb'; -import $ from 'cafy'; import ID from '../../../../cafy-id'; +import $ from 'cafy'; import deepcopy = require('deepcopy'); import db from '../db/mongodb'; import Reaction from './note-reaction'; diff --git a/src/server/api/endpoints/aggregation/posts.ts b/src/server/api/endpoints/aggregation/posts.ts index 17bead2808..87e9af3a56 100644 --- a/src/server/api/endpoints/aggregation/posts.ts +++ b/src/server/api/endpoints/aggregation/posts.ts @@ -9,7 +9,7 @@ import Note from '../../../../models/note'; */ module.exports = params => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 365, limitErr] = $(params.limit).optional.number().range(1, 365).$; + const [limit = 365, limitErr] = $(params.limit).optional.number().range(1, 365).get(); if (limitErr) return rej('invalid limit param'); const datas = await Note diff --git a/src/server/api/endpoints/aggregation/users.ts b/src/server/api/endpoints/aggregation/users.ts index b0a7632f24..831d771333 100644 --- a/src/server/api/endpoints/aggregation/users.ts +++ b/src/server/api/endpoints/aggregation/users.ts @@ -9,7 +9,7 @@ import User from '../../../../models/user'; */ module.exports = params => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 365, limitErr] = $(params.limit).optional.number().range(1, 365).$; + const [limit = 365, limitErr] = $(params.limit).optional.number().range(1, 365).get(); if (limitErr) return rej('invalid limit param'); const users = await User diff --git a/src/server/api/endpoints/aggregation/users/activity.ts b/src/server/api/endpoints/aggregation/users/activity.ts index d36e07a441..4a982ac3ba 100644 --- a/src/server/api/endpoints/aggregation/users/activity.ts +++ b/src/server/api/endpoints/aggregation/users/activity.ts @@ -12,11 +12,11 @@ import Note from '../../../../../models/note'; */ module.exports = (params) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 365, limitErr] = $(params.limit).optional.number().range(1, 365).$; + const [limit = 365, limitErr] = $(params.limit).optional.number().range(1, 365).get(); if (limitErr) return rej('invalid limit param'); // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Lookup user diff --git a/src/server/api/endpoints/aggregation/users/followers.ts b/src/server/api/endpoints/aggregation/users/followers.ts index a6dd29e735..3079542c67 100644 --- a/src/server/api/endpoints/aggregation/users/followers.ts +++ b/src/server/api/endpoints/aggregation/users/followers.ts @@ -10,7 +10,7 @@ import FollowedLog from '../../../../../models/followed-log'; */ module.exports = (params) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Lookup user diff --git a/src/server/api/endpoints/aggregation/users/following.ts b/src/server/api/endpoints/aggregation/users/following.ts index 7336f392fe..4efe20230d 100644 --- a/src/server/api/endpoints/aggregation/users/following.ts +++ b/src/server/api/endpoints/aggregation/users/following.ts @@ -10,7 +10,7 @@ import FollowingLog from '../../../../../models/following-log'; */ module.exports = (params) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Lookup user diff --git a/src/server/api/endpoints/aggregation/users/post.ts b/src/server/api/endpoints/aggregation/users/post.ts index c5a5e5ffca..fc6541065b 100644 --- a/src/server/api/endpoints/aggregation/users/post.ts +++ b/src/server/api/endpoints/aggregation/users/post.ts @@ -10,7 +10,7 @@ import Note from '../../../../../models/note'; */ module.exports = (params) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Lookup user diff --git a/src/server/api/endpoints/aggregation/users/reaction.ts b/src/server/api/endpoints/aggregation/users/reaction.ts index f1664823cd..ea3363e1aa 100644 --- a/src/server/api/endpoints/aggregation/users/reaction.ts +++ b/src/server/api/endpoints/aggregation/users/reaction.ts @@ -13,7 +13,7 @@ import Reaction from '../../../../../models/note-reaction'; */ module.exports = (params) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Lookup user diff --git a/src/server/api/endpoints/app/create.ts b/src/server/api/endpoints/app/create.ts index f403429261..97154690fa 100644 --- a/src/server/api/endpoints/app/create.ts +++ b/src/server/api/endpoints/app/create.ts @@ -67,24 +67,24 @@ import App, { isValidNameId, pack } from '../../../../models/app'; */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'nameId' parameter - const [nameId, nameIdErr] = $(params.nameId).string().pipe(isValidNameId).$; + const [nameId, nameIdErr] = $(params.nameId).string().pipe(isValidNameId).get(); if (nameIdErr) return rej('invalid nameId param'); // Get 'name' parameter - const [name, nameErr] = $(params.name).string().$; + const [name, nameErr] = $(params.name).string().get(); if (nameErr) return rej('invalid name param'); // Get 'description' parameter - const [description, descriptionErr] = $(params.description).string().$; + const [description, descriptionErr] = $(params.description).string().get(); if (descriptionErr) return rej('invalid description param'); // Get 'permission' parameter - const [permission, permissionErr] = $(params.permission).array($().string()).unique().$; + const [permission, permissionErr] = $(params.permission).array($().string()).unique().get(); if (permissionErr) return rej('invalid permission param'); // Get 'callbackUrl' parameter // TODO: Check it is valid url - const [callbackUrl = null, callbackUrlErr] = $(params.callbackUrl).optional.nullable.string().$; + const [callbackUrl = null, callbackUrlErr] = $(params.callbackUrl).optional.nullable.string().get(); if (callbackUrlErr) return rej('invalid callbackUrl param'); // Generate secret diff --git a/src/server/api/endpoints/app/name_id/available.ts b/src/server/api/endpoints/app/name_id/available.ts index ec2d692412..8c32a780ec 100644 --- a/src/server/api/endpoints/app/name_id/available.ts +++ b/src/server/api/endpoints/app/name_id/available.ts @@ -42,7 +42,7 @@ import { isValidNameId } from '../../../../../models/app'; */ module.exports = async (params) => new Promise(async (res, rej) => { // Get 'nameId' parameter - const [nameId, nameIdErr] = $(params.nameId).string().pipe(isValidNameId).$; + const [nameId, nameIdErr] = $(params.nameId).string().pipe(isValidNameId).get(); if (nameIdErr) return rej('invalid nameId param'); // Get exist diff --git a/src/server/api/endpoints/app/show.ts b/src/server/api/endpoints/app/show.ts index 92a03b9838..8408850285 100644 --- a/src/server/api/endpoints/app/show.ts +++ b/src/server/api/endpoints/app/show.ts @@ -41,11 +41,11 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => { const isSecure = user != null && app == null; // Get 'appId' parameter - const [appId, appIdErr] = $(params.appId).optional.type(ID).$; + const [appId, appIdErr] = $(params.appId).optional.type(ID).get(); if (appIdErr) return rej('invalid appId param'); // Get 'nameId' parameter - const [nameId, nameIdErr] = $(params.nameId).optional.string().$; + const [nameId, nameIdErr] = $(params.nameId).optional.string().get(); if (nameIdErr) return rej('invalid nameId param'); if (appId === undefined && nameId === undefined) { diff --git a/src/server/api/endpoints/auth/accept.ts b/src/server/api/endpoints/auth/accept.ts index b6297d663d..cb271f9d67 100644 --- a/src/server/api/endpoints/auth/accept.ts +++ b/src/server/api/endpoints/auth/accept.ts @@ -40,7 +40,7 @@ import AccessToken from '../../../../models/access-token'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'token' parameter - const [token, tokenErr] = $(params.token).string().$; + const [token, tokenErr] = $(params.token).string().get(); if (tokenErr) return rej('invalid token param'); // Fetch token diff --git a/src/server/api/endpoints/auth/session/generate.ts b/src/server/api/endpoints/auth/session/generate.ts index 7c475dbe26..8d243b85cf 100644 --- a/src/server/api/endpoints/auth/session/generate.ts +++ b/src/server/api/endpoints/auth/session/generate.ts @@ -46,7 +46,7 @@ import config from '../../../../../config'; */ module.exports = (params) => new Promise(async (res, rej) => { // Get 'appSecret' parameter - const [appSecret, appSecretErr] = $(params.appSecret).string().$; + const [appSecret, appSecretErr] = $(params.appSecret).string().get(); if (appSecretErr) return rej('invalid appSecret param'); // Lookup app diff --git a/src/server/api/endpoints/auth/session/show.ts b/src/server/api/endpoints/auth/session/show.ts index f7f0b087b7..87a43c94b9 100644 --- a/src/server/api/endpoints/auth/session/show.ts +++ b/src/server/api/endpoints/auth/session/show.ts @@ -53,7 +53,7 @@ import AuthSess, { pack } from '../../../../../models/auth-session'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'token' parameter - const [token, tokenErr] = $(params.token).string().$; + const [token, tokenErr] = $(params.token).string().get(); if (tokenErr) return rej('invalid token param'); // Lookup session diff --git a/src/server/api/endpoints/auth/session/userkey.ts b/src/server/api/endpoints/auth/session/userkey.ts index ddb67cb451..29642e6327 100644 --- a/src/server/api/endpoints/auth/session/userkey.ts +++ b/src/server/api/endpoints/auth/session/userkey.ts @@ -51,7 +51,7 @@ import { pack } from '../../../../../models/user'; */ module.exports = (params) => new Promise(async (res, rej) => { // Get 'appSecret' parameter - const [appSecret, appSecretErr] = $(params.appSecret).string().$; + const [appSecret, appSecretErr] = $(params.appSecret).string().get(); if (appSecretErr) return rej('invalid appSecret param'); // Lookup app @@ -64,7 +64,7 @@ module.exports = (params) => new Promise(async (res, rej) => { } // Get 'token' parameter - const [token, tokenErr] = $(params.token).string().$; + const [token, tokenErr] = $(params.token).string().get(); if (tokenErr) return rej('invalid token param'); // Fetch token diff --git a/src/server/api/endpoints/channels.ts b/src/server/api/endpoints/channels.ts index b68107ed7d..9fd0fcb89c 100644 --- a/src/server/api/endpoints/channels.ts +++ b/src/server/api/endpoints/channels.ts @@ -13,15 +13,15 @@ import Channel, { pack } from '../../../models/channel'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/channels/create.ts b/src/server/api/endpoints/channels/create.ts index a737fcb152..2574e0923d 100644 --- a/src/server/api/endpoints/channels/create.ts +++ b/src/server/api/endpoints/channels/create.ts @@ -11,7 +11,7 @@ import { pack } from '../../../../models/channel'; */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'title' parameter - const [title, titleErr] = $(params.title).string().range(1, 100).$; + const [title, titleErr] = $(params.title).string().range(1, 100).get(); if (titleErr) return rej('invalid title param'); // Create a channel diff --git a/src/server/api/endpoints/channels/notes.ts b/src/server/api/endpoints/channels/notes.ts index 73a69c6d2a..a83cdb34c4 100644 --- a/src/server/api/endpoints/channels/notes.ts +++ b/src/server/api/endpoints/channels/notes.ts @@ -10,15 +10,15 @@ import Note, { pack } from '../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 1000, limitErr] = $(params.limit).optional.number().range(1, 1000).$; + const [limit = 1000, limitErr] = $(params.limit).optional.number().range(1, 1000).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified @@ -27,7 +27,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { } // Get 'channelId' parameter - const [channelId, channelIdErr] = $(params.channelId).type(ID).$; + const [channelId, channelIdErr] = $(params.channelId).type(ID).get(); if (channelIdErr) return rej('invalid channelId param'); // Fetch channel diff --git a/src/server/api/endpoints/channels/show.ts b/src/server/api/endpoints/channels/show.ts index 3f468937ed..d5ca4ba3b7 100644 --- a/src/server/api/endpoints/channels/show.ts +++ b/src/server/api/endpoints/channels/show.ts @@ -9,7 +9,7 @@ import Channel, { IChannel, pack } from '../../../../models/channel'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'channelId' parameter - const [channelId, channelIdErr] = $(params.channelId).type(ID).$; + const [channelId, channelIdErr] = $(params.channelId).type(ID).get(); if (channelIdErr) return rej('invalid channelId param'); // Fetch channel diff --git a/src/server/api/endpoints/channels/unwatch.ts b/src/server/api/endpoints/channels/unwatch.ts index 6ada3c9e1b..9385e209df 100644 --- a/src/server/api/endpoints/channels/unwatch.ts +++ b/src/server/api/endpoints/channels/unwatch.ts @@ -10,7 +10,7 @@ import Watching from '../../../../models/channel-watching'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'channelId' parameter - const [channelId, channelIdErr] = $(params.channelId).type(ID).$; + const [channelId, channelIdErr] = $(params.channelId).type(ID).get(); if (channelIdErr) return rej('invalid channelId param'); //#region Fetch channel diff --git a/src/server/api/endpoints/channels/watch.ts b/src/server/api/endpoints/channels/watch.ts index 7880c34652..ceda3b130a 100644 --- a/src/server/api/endpoints/channels/watch.ts +++ b/src/server/api/endpoints/channels/watch.ts @@ -10,7 +10,7 @@ import Watching from '../../../../models/channel-watching'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'channelId' parameter - const [channelId, channelIdErr] = $(params.channelId).type(ID).$; + const [channelId, channelIdErr] = $(params.channelId).type(ID).get(); if (channelIdErr) return rej('invalid channelId param'); //#region Fetch channel diff --git a/src/server/api/endpoints/drive/files.ts b/src/server/api/endpoints/drive/files.ts index 7f78ef9daa..52dfe60faf 100644 --- a/src/server/api/endpoints/drive/files.ts +++ b/src/server/api/endpoints/drive/files.ts @@ -9,15 +9,15 @@ import DriveFile, { pack } from '../../../../models/drive-file'; */ module.exports = async (params, user, app) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) throw 'invalid limit param'; // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) throw 'invalid sinceId param'; // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) throw 'invalid untilId param'; // Check if both of sinceId and untilId is specified @@ -26,11 +26,11 @@ module.exports = async (params, user, app) => { } // Get 'folderId' parameter - const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).$; + const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).get(); if (folderIdErr) throw 'invalid folderId param'; // Get 'type' parameter - const [type, typeErr] = $(params.type).optional.string().match(/^[a-zA-Z\/\-\*]+$/).$; + const [type, typeErr] = $(params.type).optional.string().match(/^[a-zA-Z\/\-\*]+$/).get(); if (typeErr) throw 'invalid type param'; // Construct query diff --git a/src/server/api/endpoints/drive/files/create.ts b/src/server/api/endpoints/drive/files/create.ts index 3d5048732d..b1a4bc9c52 100644 --- a/src/server/api/endpoints/drive/files/create.ts +++ b/src/server/api/endpoints/drive/files/create.ts @@ -29,7 +29,7 @@ module.exports = async (file, params, user): Promise => { } // Get 'folderId' parameter - const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).$; + const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).get(); if (folderIdErr) throw 'invalid folderId param'; try { diff --git a/src/server/api/endpoints/drive/files/find.ts b/src/server/api/endpoints/drive/files/find.ts index 5d49577983..4636d85050 100644 --- a/src/server/api/endpoints/drive/files/find.ts +++ b/src/server/api/endpoints/drive/files/find.ts @@ -9,11 +9,11 @@ import DriveFile, { pack } from '../../../../../models/drive-file'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'name' parameter - const [name, nameErr] = $(params.name).string().$; + const [name, nameErr] = $(params.name).string().get(); if (nameErr) return rej('invalid name param'); // Get 'folderId' parameter - const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).$; + const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).get(); if (folderIdErr) return rej('invalid folderId param'); // Issue query diff --git a/src/server/api/endpoints/drive/files/show.ts b/src/server/api/endpoints/drive/files/show.ts index 93c3a63031..7e62e12fad 100644 --- a/src/server/api/endpoints/drive/files/show.ts +++ b/src/server/api/endpoints/drive/files/show.ts @@ -9,7 +9,7 @@ import DriveFile, { pack } from '../../../../../models/drive-file'; */ module.exports = async (params, user) => { // Get 'fileId' parameter - const [fileId, fileIdErr] = $(params.fileId).type(ID).$; + const [fileId, fileIdErr] = $(params.fileId).type(ID).get(); if (fileIdErr) throw 'invalid fileId param'; // Fetch file diff --git a/src/server/api/endpoints/drive/files/update.ts b/src/server/api/endpoints/drive/files/update.ts index 3ac157b530..c80e26771c 100644 --- a/src/server/api/endpoints/drive/files/update.ts +++ b/src/server/api/endpoints/drive/files/update.ts @@ -11,7 +11,7 @@ import { publishDriveStream } from '../../../../../publishers/stream'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'fileId' parameter - const [fileId, fileIdErr] = $(params.fileId).type(ID).$; + const [fileId, fileIdErr] = $(params.fileId).type(ID).get(); if (fileIdErr) return rej('invalid fileId param'); // Fetch file @@ -26,12 +26,12 @@ module.exports = (params, user) => new Promise(async (res, rej) => { } // Get 'name' parameter - const [name, nameErr] = $(params.name).optional.string().pipe(validateFileName).$; + const [name, nameErr] = $(params.name).optional.string().pipe(validateFileName).get(); if (nameErr) return rej('invalid name param'); if (name) file.filename = name; // Get 'folderId' parameter - const [folderId, folderIdErr] = $(params.folderId).optional.nullable.type(ID).$; + const [folderId, folderIdErr] = $(params.folderId).optional.nullable.type(ID).get(); if (folderIdErr) return rej('invalid folderId param'); if (folderId !== undefined) { diff --git a/src/server/api/endpoints/drive/files/upload_from_url.ts b/src/server/api/endpoints/drive/files/upload_from_url.ts index cfae1ae192..540c317bee 100644 --- a/src/server/api/endpoints/drive/files/upload_from_url.ts +++ b/src/server/api/endpoints/drive/files/upload_from_url.ts @@ -11,11 +11,11 @@ import uploadFromUrl from '../../../../../services/drive/upload-from-url'; module.exports = async (params, user): Promise => { // Get 'url' parameter // TODO: Validate this url - const [url, urlErr] = $(params.url).string().$; + const [url, urlErr] = $(params.url).string().get(); if (urlErr) throw 'invalid url param'; // Get 'folderId' parameter - const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).$; + const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).get(); if (folderIdErr) throw 'invalid folderId param'; return pack(await uploadFromUrl(url, user, folderId)); diff --git a/src/server/api/endpoints/drive/folders.ts b/src/server/api/endpoints/drive/folders.ts index cba33c4286..8193a8317a 100644 --- a/src/server/api/endpoints/drive/folders.ts +++ b/src/server/api/endpoints/drive/folders.ts @@ -9,15 +9,15 @@ import DriveFolder, { pack } from '../../../../models/drive-folder'; */ module.exports = (params, user, app) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified @@ -26,7 +26,7 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => { } // Get 'folderId' parameter - const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).$; + const [folderId = null, folderIdErr] = $(params.folderId).optional.nullable.type(ID).get(); if (folderIdErr) return rej('invalid folderId param'); // Construct query diff --git a/src/server/api/endpoints/drive/folders/create.ts b/src/server/api/endpoints/drive/folders/create.ts index 65425537a2..487c1b2205 100644 --- a/src/server/api/endpoints/drive/folders/create.ts +++ b/src/server/api/endpoints/drive/folders/create.ts @@ -10,11 +10,11 @@ import { publishDriveStream } from '../../../../../publishers/stream'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'name' parameter - const [name = '無題のフォルダー', nameErr] = $(params.name).optional.string().pipe(isValidFolderName).$; + const [name = '無題のフォルダー', nameErr] = $(params.name).optional.string().pipe(isValidFolderName).get(); if (nameErr) return rej('invalid name param'); // Get 'parentId' parameter - const [parentId = null, parentIdErr] = $(params.parentId).optional.nullable.type(ID).$; + const [parentId = null, parentIdErr] = $(params.parentId).optional.nullable.type(ID).get(); if (parentIdErr) return rej('invalid parentId param'); // If the parent folder is specified diff --git a/src/server/api/endpoints/drive/folders/find.ts b/src/server/api/endpoints/drive/folders/find.ts index d6277f1978..b8579219f9 100644 --- a/src/server/api/endpoints/drive/folders/find.ts +++ b/src/server/api/endpoints/drive/folders/find.ts @@ -9,11 +9,11 @@ import DriveFolder, { pack } from '../../../../../models/drive-folder'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'name' parameter - const [name, nameErr] = $(params.name).string().$; + const [name, nameErr] = $(params.name).string().get(); if (nameErr) return rej('invalid name param'); // Get 'parentId' parameter - const [parentId = null, parentIdErr] = $(params.parentId).optional.nullable.type(ID).$; + const [parentId = null, parentIdErr] = $(params.parentId).optional.nullable.type(ID).get(); if (parentIdErr) return rej('invalid parentId param'); // Issue query diff --git a/src/server/api/endpoints/drive/folders/show.ts b/src/server/api/endpoints/drive/folders/show.ts index c703209fef..36d7f1c69f 100644 --- a/src/server/api/endpoints/drive/folders/show.ts +++ b/src/server/api/endpoints/drive/folders/show.ts @@ -9,7 +9,7 @@ import DriveFolder, { pack } from '../../../../../models/drive-folder'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'folderId' parameter - const [folderId, folderIdErr] = $(params.folderId).type(ID).$; + const [folderId, folderIdErr] = $(params.folderId).type(ID).get(); if (folderIdErr) return rej('invalid folderId param'); // Get folder diff --git a/src/server/api/endpoints/drive/folders/update.ts b/src/server/api/endpoints/drive/folders/update.ts index d8da67fac8..64a6cd293a 100644 --- a/src/server/api/endpoints/drive/folders/update.ts +++ b/src/server/api/endpoints/drive/folders/update.ts @@ -10,7 +10,7 @@ import { publishDriveStream } from '../../../../../publishers/stream'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'folderId' parameter - const [folderId, folderIdErr] = $(params.folderId).type(ID).$; + const [folderId, folderIdErr] = $(params.folderId).type(ID).get(); if (folderIdErr) return rej('invalid folderId param'); // Fetch folder @@ -25,12 +25,12 @@ module.exports = (params, user) => new Promise(async (res, rej) => { } // Get 'name' parameter - const [name, nameErr] = $(params.name).optional.string().pipe(isValidFolderName).$; + const [name, nameErr] = $(params.name).optional.string().pipe(isValidFolderName).get(); if (nameErr) return rej('invalid name param'); if (name) folder.name = name; // Get 'parentId' parameter - const [parentId, parentIdErr] = $(params.parentId).optional.nullable.type(ID).$; + const [parentId, parentIdErr] = $(params.parentId).optional.nullable.type(ID).get(); if (parentIdErr) return rej('invalid parentId param'); if (parentId !== undefined) { if (parentId === null) { diff --git a/src/server/api/endpoints/drive/stream.ts b/src/server/api/endpoints/drive/stream.ts index 00d89582b6..b148f2ce51 100644 --- a/src/server/api/endpoints/drive/stream.ts +++ b/src/server/api/endpoints/drive/stream.ts @@ -9,15 +9,15 @@ import DriveFile, { pack } from '../../../../models/drive-file'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified @@ -26,7 +26,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { } // Get 'type' parameter - const [type, typeErr] = $(params.type).optional.string().match(/^[a-zA-Z\/\-\*]+$/).$; + const [type, typeErr] = $(params.type).optional.string().match(/^[a-zA-Z\/\-\*]+$/).get(); if (typeErr) return rej('invalid type param'); // Construct query diff --git a/src/server/api/endpoints/following/create.ts b/src/server/api/endpoints/following/create.ts index 43f902852e..42a7b79b00 100644 --- a/src/server/api/endpoints/following/create.ts +++ b/src/server/api/endpoints/following/create.ts @@ -13,7 +13,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const follower = user; // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // 自分自身 diff --git a/src/server/api/endpoints/following/delete.ts b/src/server/api/endpoints/following/delete.ts index 99722ccf91..3aef6523de 100644 --- a/src/server/api/endpoints/following/delete.ts +++ b/src/server/api/endpoints/following/delete.ts @@ -13,7 +13,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const follower = user; // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Check if the followee is yourself diff --git a/src/server/api/endpoints/following/stalk.ts b/src/server/api/endpoints/following/stalk.ts index 1dfbc4df98..34e3f80f8a 100644 --- a/src/server/api/endpoints/following/stalk.ts +++ b/src/server/api/endpoints/following/stalk.ts @@ -8,7 +8,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const follower = user; // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Fetch following diff --git a/src/server/api/endpoints/following/unstalk.ts b/src/server/api/endpoints/following/unstalk.ts index 0d91ffeac8..f8ca39ef7d 100644 --- a/src/server/api/endpoints/following/unstalk.ts +++ b/src/server/api/endpoints/following/unstalk.ts @@ -8,7 +8,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const follower = user; // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Fetch following diff --git a/src/server/api/endpoints/i/2fa/done.ts b/src/server/api/endpoints/i/2fa/done.ts index 3e824feffd..310e5c574e 100644 --- a/src/server/api/endpoints/i/2fa/done.ts +++ b/src/server/api/endpoints/i/2fa/done.ts @@ -7,7 +7,7 @@ import User from '../../../../../models/user'; module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'token' parameter - const [token, tokenErr] = $(params.token).string().$; + const [token, tokenErr] = $(params.token).string().get(); if (tokenErr) return rej('invalid token param'); const _token = token.replace(/\s/g, ''); diff --git a/src/server/api/endpoints/i/2fa/register.ts b/src/server/api/endpoints/i/2fa/register.ts index bed64a2545..51f66dc2fe 100644 --- a/src/server/api/endpoints/i/2fa/register.ts +++ b/src/server/api/endpoints/i/2fa/register.ts @@ -10,7 +10,7 @@ import config from '../../../../../config'; module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'password' parameter - const [password, passwordErr] = $(params.password).string().$; + const [password, passwordErr] = $(params.password).string().get(); if (passwordErr) return rej('invalid password param'); // Compare password diff --git a/src/server/api/endpoints/i/2fa/unregister.ts b/src/server/api/endpoints/i/2fa/unregister.ts index f9d7a25f53..9fd940dcaf 100644 --- a/src/server/api/endpoints/i/2fa/unregister.ts +++ b/src/server/api/endpoints/i/2fa/unregister.ts @@ -7,7 +7,7 @@ import User from '../../../../../models/user'; module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'password' parameter - const [password, passwordErr] = $(params.password).string().$; + const [password, passwordErr] = $(params.password).string().get(); if (passwordErr) return rej('invalid password param'); // Compare password diff --git a/src/server/api/endpoints/i/authorized_apps.ts b/src/server/api/endpoints/i/authorized_apps.ts index fd12b3dec0..9635091465 100644 --- a/src/server/api/endpoints/i/authorized_apps.ts +++ b/src/server/api/endpoints/i/authorized_apps.ts @@ -10,15 +10,15 @@ import { pack } from '../../../../models/app'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'sort' parameter - const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').$; + const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').get(); if (sortError) return rej('invalid sort param'); // Get tokens diff --git a/src/server/api/endpoints/i/change_password.ts b/src/server/api/endpoints/i/change_password.ts index a24e9f0be1..5c8c71d140 100644 --- a/src/server/api/endpoints/i/change_password.ts +++ b/src/server/api/endpoints/i/change_password.ts @@ -10,11 +10,11 @@ import User from '../../../../models/user'; */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'currentPasword' parameter - const [currentPassword, currentPasswordErr] = $(params.currentPasword).string().$; + const [currentPassword, currentPasswordErr] = $(params.currentPasword).string().get(); if (currentPasswordErr) return rej('invalid currentPasword param'); // Get 'newPassword' parameter - const [newPassword, newPasswordErr] = $(params.newPassword).string().$; + const [newPassword, newPasswordErr] = $(params.newPassword).string().get(); if (newPasswordErr) return rej('invalid newPassword param'); // Compare password diff --git a/src/server/api/endpoints/i/favorites.ts b/src/server/api/endpoints/i/favorites.ts index a2c472ad17..a65f673a7d 100644 --- a/src/server/api/endpoints/i/favorites.ts +++ b/src/server/api/endpoints/i/favorites.ts @@ -9,15 +9,15 @@ import Favorite, { pack } from '../../../../models/favorite'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/i/notifications.ts b/src/server/api/endpoints/i/notifications.ts index 14ade7b023..a0bf2338a6 100644 --- a/src/server/api/endpoints/i/notifications.ts +++ b/src/server/api/endpoints/i/notifications.ts @@ -14,27 +14,27 @@ import read from '../../common/read-notification'; module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'following' parameter const [following = false, followingError] = - $(params.following).optional.boolean().$; + $(params.following).optional.boolean().get(); if (followingError) return rej('invalid following param'); // Get 'markAsRead' parameter - const [markAsRead = true, markAsReadErr] = $(params.markAsRead).optional.boolean().$; + const [markAsRead = true, markAsReadErr] = $(params.markAsRead).optional.boolean().get(); 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().get(); if (typeErr) return rej('invalid type param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/i/pin.ts b/src/server/api/endpoints/i/pin.ts index 761e41bbea..1d995746dc 100644 --- a/src/server/api/endpoints/i/pin.ts +++ b/src/server/api/endpoints/i/pin.ts @@ -11,7 +11,7 @@ import { pack } from '../../../../models/user'; */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Fetch pinee diff --git a/src/server/api/endpoints/i/regenerate_token.ts b/src/server/api/endpoints/i/regenerate_token.ts index 945ddbdee4..df440c68ab 100644 --- a/src/server/api/endpoints/i/regenerate_token.ts +++ b/src/server/api/endpoints/i/regenerate_token.ts @@ -12,7 +12,7 @@ import generateUserToken from '../../common/generate-native-user-token'; */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'password' parameter - const [password, passwordErr] = $(params.password).string().$; + const [password, passwordErr] = $(params.password).string().get(); if (passwordErr) return rej('invalid password param'); // Compare password diff --git a/src/server/api/endpoints/i/signin_history.ts b/src/server/api/endpoints/i/signin_history.ts index 77beca9fd6..d505caad82 100644 --- a/src/server/api/endpoints/i/signin_history.ts +++ b/src/server/api/endpoints/i/signin_history.ts @@ -9,15 +9,15 @@ import Signin, { pack } from '../../../../models/signin'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index 7505e73387..2b76497025 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -12,42 +12,42 @@ module.exports = async (params, user, app) => new Promise(async (res, rej) => { const isSecure = user != null && app == null; // Get 'name' parameter - const [name, nameErr] = $(params.name).optional.nullable.string().pipe(isValidName).$; + const [name, nameErr] = $(params.name).optional.nullable.string().pipe(isValidName).get(); if (nameErr) return rej('invalid name param'); if (name) user.name = name; // Get 'description' parameter - const [description, descriptionErr] = $(params.description).optional.nullable.string().pipe(isValidDescription).$; + const [description, descriptionErr] = $(params.description).optional.nullable.string().pipe(isValidDescription).get(); if (descriptionErr) return rej('invalid description param'); if (description !== undefined) user.description = description; // Get 'location' parameter - const [location, locationErr] = $(params.location).optional.nullable.string().pipe(isValidLocation).$; + const [location, locationErr] = $(params.location).optional.nullable.string().pipe(isValidLocation).get(); if (locationErr) return rej('invalid location param'); if (location !== undefined) user.profile.location = location; // Get 'birthday' parameter - const [birthday, birthdayErr] = $(params.birthday).optional.nullable.string().pipe(isValidBirthday).$; + const [birthday, birthdayErr] = $(params.birthday).optional.nullable.string().pipe(isValidBirthday).get(); if (birthdayErr) return rej('invalid birthday param'); if (birthday !== undefined) user.profile.birthday = birthday; // Get 'avatarId' parameter - const [avatarId, avatarIdErr] = $(params.avatarId).optional.type(ID).$; + const [avatarId, avatarIdErr] = $(params.avatarId).optional.type(ID).get(); if (avatarIdErr) return rej('invalid avatarId param'); if (avatarId) user.avatarId = avatarId; // Get 'bannerId' parameter - const [bannerId, bannerIdErr] = $(params.bannerId).optional.type(ID).$; + const [bannerId, bannerIdErr] = $(params.bannerId).optional.type(ID).get(); if (bannerIdErr) return rej('invalid bannerId param'); if (bannerId) user.bannerId = bannerId; // Get 'isBot' parameter - const [isBot, isBotErr] = $(params.isBot).optional.boolean().$; + const [isBot, isBotErr] = $(params.isBot).optional.boolean().get(); if (isBotErr) return rej('invalid isBot param'); if (isBot != null) user.isBot = isBot; // Get 'autoWatch' parameter - const [autoWatch, autoWatchErr] = $(params.autoWatch).optional.boolean().$; + const [autoWatch, autoWatchErr] = $(params.autoWatch).optional.boolean().get(); if (autoWatchErr) return rej('invalid autoWatch param'); if (autoWatch != null) user.settings.autoWatch = autoWatch; diff --git a/src/server/api/endpoints/i/update_client_setting.ts b/src/server/api/endpoints/i/update_client_setting.ts index f753c8bcc4..2edc2104d2 100644 --- a/src/server/api/endpoints/i/update_client_setting.ts +++ b/src/server/api/endpoints/i/update_client_setting.ts @@ -10,11 +10,11 @@ import event from '../../../../publishers/stream'; */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'name' parameter - const [name, nameErr] = $(params.name).string().$; + const [name, nameErr] = $(params.name).string().get(); if (nameErr) return rej('invalid name param'); // Get 'value' parameter - const [value, valueErr] = $(params.value).nullable.any().$; + const [value, valueErr] = $(params.value).nullable.any().get(); if (valueErr) return rej('invalid value param'); const x = {}; diff --git a/src/server/api/endpoints/i/update_home.ts b/src/server/api/endpoints/i/update_home.ts index 4b8ba25069..baf9b739ae 100644 --- a/src/server/api/endpoints/i/update_home.ts +++ b/src/server/api/endpoints/i/update_home.ts @@ -12,15 +12,15 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { .have('name', $().string()) .have('id', $().string()) .have('place', $().string()) - .have('data', $().object())).$; + .have('data', $().object())).get(); if (homeErr) return rej('invalid home param'); // Get 'id' parameter - const [id, idErr] = $(params.id).optional.string().$; + const [id, idErr] = $(params.id).optional.string().get(); if (idErr) return rej('invalid id param'); // Get 'data' parameter - const [data, dataErr] = $(params.data).optional.object().$; + const [data, dataErr] = $(params.data).optional.object().get(); if (dataErr) return rej('invalid data param'); if (home) { diff --git a/src/server/api/endpoints/i/update_mobile_home.ts b/src/server/api/endpoints/i/update_mobile_home.ts index c3ecea7178..21d94839b7 100644 --- a/src/server/api/endpoints/i/update_mobile_home.ts +++ b/src/server/api/endpoints/i/update_mobile_home.ts @@ -11,15 +11,15 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { $().object(true) .have('name', $().string()) .have('id', $().string()) - .have('data', $().object())).$; + .have('data', $().object())).get(); if (homeErr) return rej('invalid home param'); // Get 'id' parameter - const [id, idErr] = $(params.id).optional.string().$; + const [id, idErr] = $(params.id).optional.string().get(); if (idErr) return rej('invalid id param'); // Get 'data' parameter - const [data, dataErr] = $(params.data).optional.object().$; + const [data, dataErr] = $(params.data).optional.object().get(); if (dataErr) return rej('invalid data param'); if (home) { diff --git a/src/server/api/endpoints/messaging/history.ts b/src/server/api/endpoints/messaging/history.ts index 654bf5c198..9fd1f80d7b 100644 --- a/src/server/api/endpoints/messaging/history.ts +++ b/src/server/api/endpoints/messaging/history.ts @@ -11,7 +11,7 @@ import { pack } from '../../../../models/messaging-message'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); const mute = await Mute.find({ diff --git a/src/server/api/endpoints/messaging/messages.ts b/src/server/api/endpoints/messaging/messages.ts index f28699cb88..f154133a12 100644 --- a/src/server/api/endpoints/messaging/messages.ts +++ b/src/server/api/endpoints/messaging/messages.ts @@ -16,7 +16,7 @@ import read from '../../common/read-messaging-message'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [recipientId, recipientIdErr] = $(params.userId).type(ID).$; + const [recipientId, recipientIdErr] = $(params.userId).type(ID).get(); if (recipientIdErr) return rej('invalid userId param'); // Fetch recipient @@ -33,19 +33,19 @@ module.exports = (params, user) => new Promise(async (res, rej) => { } // Get 'markAsRead' parameter - const [markAsRead = true, markAsReadErr] = $(params.markAsRead).optional.boolean().$; + const [markAsRead = true, markAsReadErr] = $(params.markAsRead).optional.boolean().get(); if (markAsReadErr) return rej('invalid markAsRead param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/messaging/messages/create.ts b/src/server/api/endpoints/messaging/messages/create.ts index cce326be6e..8b708eeaa9 100644 --- a/src/server/api/endpoints/messaging/messages/create.ts +++ b/src/server/api/endpoints/messaging/messages/create.ts @@ -19,7 +19,7 @@ import config from '../../../../../config'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [recipientId, recipientIdErr] = $(params.userId).type(ID).$; + const [recipientId, recipientIdErr] = $(params.userId).type(ID).get(); if (recipientIdErr) return rej('invalid userId param'); // Myself @@ -41,11 +41,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => { } // Get 'text' parameter - const [text, textErr] = $(params.text).optional.string().pipe(isValidText).$; + const [text, textErr] = $(params.text).optional.string().pipe(isValidText).get(); if (textErr) return rej('invalid text'); // Get 'fileId' parameter - const [fileId, fileIdErr] = $(params.fileId).optional.type(ID).$; + const [fileId, fileIdErr] = $(params.fileId).optional.type(ID).get(); if (fileIdErr) return rej('invalid fileId param'); let file = null; diff --git a/src/server/api/endpoints/mute/create.ts b/src/server/api/endpoints/mute/create.ts index 0d59ecc118..aa9f6eb731 100644 --- a/src/server/api/endpoints/mute/create.ts +++ b/src/server/api/endpoints/mute/create.ts @@ -12,7 +12,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const muter = user; // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // 自分自身 diff --git a/src/server/api/endpoints/mute/delete.ts b/src/server/api/endpoints/mute/delete.ts index 3a37de9a21..f24db6770d 100644 --- a/src/server/api/endpoints/mute/delete.ts +++ b/src/server/api/endpoints/mute/delete.ts @@ -12,7 +12,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const muter = user; // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Check if the mutee is yourself diff --git a/src/server/api/endpoints/mute/list.ts b/src/server/api/endpoints/mute/list.ts index f35bf7d168..f7199db64e 100644 --- a/src/server/api/endpoints/mute/list.ts +++ b/src/server/api/endpoints/mute/list.ts @@ -11,15 +11,15 @@ import { getFriendIds } from '../../common/get-friends'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'iknow' parameter - const [iknow = false, iknowErr] = $(params.iknow).optional.boolean().$; + const [iknow = false, iknowErr] = $(params.iknow).optional.boolean().get(); if (iknowErr) return rej('invalid iknow param'); // Get 'limit' parameter - const [limit = 30, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 30, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'cursor' parameter - const [cursor = null, cursorErr] = $(params.cursor).optional.type(ID).$; + const [cursor = null, cursorErr] = $(params.cursor).optional.type(ID).get(); if (cursorErr) return rej('invalid cursor param'); // Construct query diff --git a/src/server/api/endpoints/my/apps.ts b/src/server/api/endpoints/my/apps.ts index eb7ece70e9..3b58b30241 100644 --- a/src/server/api/endpoints/my/apps.ts +++ b/src/server/api/endpoints/my/apps.ts @@ -9,11 +9,11 @@ import App, { pack } from '../../../../models/app'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); const query = { diff --git a/src/server/api/endpoints/notes.ts b/src/server/api/endpoints/notes.ts index bf4d5bc66f..7be35961d2 100644 --- a/src/server/api/endpoints/notes.ts +++ b/src/server/api/endpoints/notes.ts @@ -9,35 +9,35 @@ import Note, { pack } from '../../../models/note'; */ module.exports = (params) => new Promise(async (res, rej) => { // Get 'reply' parameter - const [reply, replyErr] = $(params.reply).optional.boolean().$; + const [reply, replyErr] = $(params.reply).optional.boolean().get(); if (replyErr) return rej('invalid reply param'); // Get 'renote' parameter - const [renote, renoteErr] = $(params.renote).optional.boolean().$; + const [renote, renoteErr] = $(params.renote).optional.boolean().get(); if (renoteErr) return rej('invalid renote param'); // Get 'media' parameter - const [media, mediaErr] = $(params.media).optional.boolean().$; + const [media, mediaErr] = $(params.media).optional.boolean().get(); if (mediaErr) return rej('invalid media param'); // Get 'poll' parameter - const [poll, pollErr] = $(params.poll).optional.boolean().$; + const [poll, pollErr] = $(params.poll).optional.boolean().get(); if (pollErr) return rej('invalid poll param'); // Get 'bot' parameter - //const [bot, botErr] = $(params.bot).optional.boolean().$; + //const [bot, botErr] = $(params.bot).optional.boolean().get(); //if (botErr) return rej('invalid bot param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/notes/context.ts b/src/server/api/endpoints/notes/context.ts index 309fc26447..7e3533cfd8 100644 --- a/src/server/api/endpoints/notes/context.ts +++ b/src/server/api/endpoints/notes/context.ts @@ -13,15 +13,15 @@ import Note, { pack } from '../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Lookup note diff --git a/src/server/api/endpoints/notes/create.ts b/src/server/api/endpoints/notes/create.ts index 1824a16c24..af4f365226 100644 --- a/src/server/api/endpoints/notes/create.ts +++ b/src/server/api/endpoints/notes/create.ts @@ -14,23 +14,23 @@ import { IApp } from '../../../../models/app'; */ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => { // Get 'visibility' parameter - const [visibility = 'public', visibilityErr] = $(params.visibility).optional.string().or(['public', 'unlisted', 'private', 'direct']).$; + const [visibility = 'public', visibilityErr] = $(params.visibility).optional.string().or(['public', 'unlisted', 'private', 'direct']).get(); if (visibilityErr) return rej('invalid visibility'); // Get 'text' parameter - const [text = null, textErr] = $(params.text).optional.nullable.string().pipe(isValidText).$; + const [text = null, textErr] = $(params.text).optional.nullable.string().pipe(isValidText).get(); if (textErr) return rej('invalid text'); // Get 'cw' parameter - const [cw, cwErr] = $(params.cw).optional.nullable.string().pipe(isValidCw).$; + const [cw, cwErr] = $(params.cw).optional.nullable.string().pipe(isValidCw).get(); if (cwErr) return rej('invalid cw'); // Get 'viaMobile' parameter - const [viaMobile = false, viaMobileErr] = $(params.viaMobile).optional.boolean().$; + const [viaMobile = false, viaMobileErr] = $(params.viaMobile).optional.boolean().get(); if (viaMobileErr) return rej('invalid viaMobile'); // Get 'tags' parameter - const [tags = [], tagsErr] = $(params.tags).optional.array($().string().range(1, 32)).unique().$; + const [tags = [], tagsErr] = $(params.tags).optional.array($().string().range(1, 32)).unique().get(); if (tagsErr) return rej('invalid tags'); // Get 'geo' parameter @@ -43,11 +43,11 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res .have('altitudeAccuracy', $().nullable.number()) .have('heading', $().nullable.number().range(0, 360)) .have('speed', $().nullable.number()) - .$; + .get(); if (geoErr) return rej('invalid geo'); // Get 'mediaIds' parameter - const [mediaIds, mediaIdsErr] = $(params.mediaIds).optional.array($().type(ID)).unique().range(1, 4).$; + const [mediaIds, mediaIdsErr] = $(params.mediaIds).optional.array($().type(ID)).unique().range(1, 4).get(); if (mediaIdsErr) return rej('invalid mediaIds'); let files = []; @@ -74,7 +74,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res } // Get 'renoteId' parameter - const [renoteId, renoteIdErr] = $(params.renoteId).optional.type(ID).$; + const [renoteId, renoteIdErr] = $(params.renoteId).optional.type(ID).get(); if (renoteIdErr) return rej('invalid renoteId'); let renote: INote = null; @@ -95,7 +95,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res } // Get 'replyId' parameter - const [replyId, replyIdErr] = $(params.replyId).optional.type(ID).$; + const [replyId, replyIdErr] = $(params.replyId).optional.type(ID).get(); if (replyIdErr) return rej('invalid replyId'); let reply: INote = null; @@ -116,7 +116,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res } // Get 'channelId' parameter - const [channelId, channelIdErr] = $(params.channelId).optional.type(ID).$; + const [channelId, channelIdErr] = $(params.channelId).optional.type(ID).get(); if (channelIdErr) return rej('invalid channelId'); let channel: IChannel = null; @@ -162,7 +162,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res .unique() .range(2, 10) .each(c => c.length > 0 && c.length < 50)) - .$; + .get(); if (pollErr) return rej('invalid poll'); if (poll) { diff --git a/src/server/api/endpoints/notes/favorites/create.ts b/src/server/api/endpoints/notes/favorites/create.ts index e4c4adb9bb..e6396b85ce 100644 --- a/src/server/api/endpoints/notes/favorites/create.ts +++ b/src/server/api/endpoints/notes/favorites/create.ts @@ -10,7 +10,7 @@ import Note from '../../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get favoritee diff --git a/src/server/api/endpoints/notes/favorites/delete.ts b/src/server/api/endpoints/notes/favorites/delete.ts index 3c4d9a1111..f1de424725 100644 --- a/src/server/api/endpoints/notes/favorites/delete.ts +++ b/src/server/api/endpoints/notes/favorites/delete.ts @@ -10,7 +10,7 @@ import Note from '../../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get favoritee diff --git a/src/server/api/endpoints/notes/global-timeline.ts b/src/server/api/endpoints/notes/global-timeline.ts index e2a94d8a3e..212345aac0 100644 --- a/src/server/api/endpoints/notes/global-timeline.ts +++ b/src/server/api/endpoints/notes/global-timeline.ts @@ -11,23 +11,23 @@ import { pack } from '../../../../models/note'; */ module.exports = async (params, user, app) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) throw 'invalid limit param'; // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) throw 'invalid sinceId param'; // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) throw 'invalid untilId param'; // Get 'sinceDate' parameter - const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().$; + const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().get(); if (sinceDateErr) throw 'invalid sinceDate param'; // Get 'untilDate' parameter - const [untilDate, untilDateErr] = $(params.untilDate).optional.number().$; + const [untilDate, untilDateErr] = $(params.untilDate).optional.number().get(); if (untilDateErr) throw 'invalid untilDate param'; // Check if only one of sinceId, untilId, sinceDate, untilDate specified diff --git a/src/server/api/endpoints/notes/local-timeline.ts b/src/server/api/endpoints/notes/local-timeline.ts index dda83311ac..12dd2d5a85 100644 --- a/src/server/api/endpoints/notes/local-timeline.ts +++ b/src/server/api/endpoints/notes/local-timeline.ts @@ -11,23 +11,23 @@ import { pack } from '../../../../models/note'; */ module.exports = async (params, user, app) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) throw 'invalid limit param'; // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) throw 'invalid sinceId param'; // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) throw 'invalid untilId param'; // Get 'sinceDate' parameter - const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().$; + const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().get(); if (sinceDateErr) throw 'invalid sinceDate param'; // Get 'untilDate' parameter - const [untilDate, untilDateErr] = $(params.untilDate).optional.number().$; + const [untilDate, untilDateErr] = $(params.untilDate).optional.number().get(); if (untilDateErr) throw 'invalid untilDate param'; // Check if only one of sinceId, untilId, sinceDate, untilDate specified diff --git a/src/server/api/endpoints/notes/mentions.ts b/src/server/api/endpoints/notes/mentions.ts index 815cf271a2..db7c630897 100644 --- a/src/server/api/endpoints/notes/mentions.ts +++ b/src/server/api/endpoints/notes/mentions.ts @@ -16,19 +16,19 @@ import { pack } from '../../../../models/note'; module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'following' parameter const [following = false, followingError] = - $(params.following).optional.boolean().$; + $(params.following).optional.boolean().get(); if (followingError) return rej('invalid following param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/notes/polls/recommendation.ts b/src/server/api/endpoints/notes/polls/recommendation.ts index 24b0a4c803..1994c5ce7a 100644 --- a/src/server/api/endpoints/notes/polls/recommendation.ts +++ b/src/server/api/endpoints/notes/polls/recommendation.ts @@ -10,11 +10,11 @@ import Note, { pack } from '../../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get votes diff --git a/src/server/api/endpoints/notes/polls/vote.ts b/src/server/api/endpoints/notes/polls/vote.ts index 2669c39085..1915e0c79b 100644 --- a/src/server/api/endpoints/notes/polls/vote.ts +++ b/src/server/api/endpoints/notes/polls/vote.ts @@ -14,7 +14,7 @@ import notify from '../../../../../publishers/notify'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get votee @@ -34,7 +34,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const [choice, choiceError] = $(params.choice).number() .pipe(c => note.poll.choices.some(x => x.id == c)) - .$; + .get(); if (choiceError) return rej('invalid choice param'); // if already voted diff --git a/src/server/api/endpoints/notes/reactions.ts b/src/server/api/endpoints/notes/reactions.ts index 68ffbacd46..75ed580de2 100644 --- a/src/server/api/endpoints/notes/reactions.ts +++ b/src/server/api/endpoints/notes/reactions.ts @@ -14,19 +14,19 @@ import Reaction, { pack } from '../../../../models/note-reaction'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'sort' parameter - const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').$; + const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').get(); if (sortError) return rej('invalid sort param'); // Lookup note diff --git a/src/server/api/endpoints/notes/reactions/create.ts b/src/server/api/endpoints/notes/reactions/create.ts index 1c21252604..9dc1b3c82a 100644 --- a/src/server/api/endpoints/notes/reactions/create.ts +++ b/src/server/api/endpoints/notes/reactions/create.ts @@ -11,11 +11,11 @@ import { validateReaction } from '../../../../../models/note-reaction'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get 'reaction' parameter - const [reaction, reactionErr] = $(params.reaction).string().pipe(validateReaction.ok).$; + const [reaction, reactionErr] = $(params.reaction).string().pipe(validateReaction.ok).get(); if (reactionErr) return rej('invalid reaction param'); // Fetch reactee diff --git a/src/server/api/endpoints/notes/reactions/delete.ts b/src/server/api/endpoints/notes/reactions/delete.ts index be3c1b214d..6bd5edef42 100644 --- a/src/server/api/endpoints/notes/reactions/delete.ts +++ b/src/server/api/endpoints/notes/reactions/delete.ts @@ -10,7 +10,7 @@ import Note from '../../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Fetch unreactee diff --git a/src/server/api/endpoints/notes/replies.ts b/src/server/api/endpoints/notes/replies.ts index 31f1bb941a..47c9ae501f 100644 --- a/src/server/api/endpoints/notes/replies.ts +++ b/src/server/api/endpoints/notes/replies.ts @@ -13,19 +13,19 @@ import Note, { pack } from '../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'sort' parameter - const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').$; + const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').get(); if (sortError) return rej('invalid sort param'); // Lookup note diff --git a/src/server/api/endpoints/notes/reposts.ts b/src/server/api/endpoints/notes/reposts.ts index fe98931380..b388ee599f 100644 --- a/src/server/api/endpoints/notes/reposts.ts +++ b/src/server/api/endpoints/notes/reposts.ts @@ -13,19 +13,19 @@ import Note, { pack } from '../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/notes/search.ts b/src/server/api/endpoints/notes/search.ts index 021f620aa2..8b3c78145d 100644 --- a/src/server/api/endpoints/notes/search.ts +++ b/src/server/api/endpoints/notes/search.ts @@ -18,63 +18,63 @@ import { pack } from '../../../../models/note'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'text' parameter - const [text, textError] = $(params.text).optional.string().$; + const [text, textError] = $(params.text).optional.string().get(); if (textError) return rej('invalid text param'); // Get 'includeUserIds' parameter - const [includeUserIds = [], includeUserIdsErr] = $(params.includeUserIds).optional.array($().type(ID)).$; + const [includeUserIds = [], includeUserIdsErr] = $(params.includeUserIds).optional.array($().type(ID)).get(); if (includeUserIdsErr) return rej('invalid includeUserIds param'); // Get 'excludeUserIds' parameter - const [excludeUserIds = [], excludeUserIdsErr] = $(params.excludeUserIds).optional.array($().type(ID)).$; + const [excludeUserIds = [], excludeUserIdsErr] = $(params.excludeUserIds).optional.array($().type(ID)).get(); if (excludeUserIdsErr) return rej('invalid excludeUserIds param'); // Get 'includeUserUsernames' parameter - const [includeUserUsernames = [], includeUserUsernamesErr] = $(params.includeUserUsernames).optional.array($().string()).$; + const [includeUserUsernames = [], includeUserUsernamesErr] = $(params.includeUserUsernames).optional.array($().string()).get(); if (includeUserUsernamesErr) return rej('invalid includeUserUsernames param'); // Get 'excludeUserUsernames' parameter - const [excludeUserUsernames = [], excludeUserUsernamesErr] = $(params.excludeUserUsernames).optional.array($().string()).$; + const [excludeUserUsernames = [], excludeUserUsernamesErr] = $(params.excludeUserUsernames).optional.array($().string()).get(); if (excludeUserUsernamesErr) return rej('invalid excludeUserUsernames param'); // Get 'following' parameter - const [following = null, followingErr] = $(params.following).optional.nullable.boolean().$; + const [following = null, followingErr] = $(params.following).optional.nullable.boolean().get(); if (followingErr) return rej('invalid following param'); // Get 'mute' parameter - const [mute = 'mute_all', muteErr] = $(params.mute).optional.string().$; + const [mute = 'mute_all', muteErr] = $(params.mute).optional.string().get(); if (muteErr) return rej('invalid mute param'); // Get 'reply' parameter - const [reply = null, replyErr] = $(params.reply).optional.nullable.boolean().$; + const [reply = null, replyErr] = $(params.reply).optional.nullable.boolean().get(); if (replyErr) return rej('invalid reply param'); // Get 'renote' parameter - const [renote = null, renoteErr] = $(params.renote).optional.nullable.boolean().$; + const [renote = null, renoteErr] = $(params.renote).optional.nullable.boolean().get(); if (renoteErr) return rej('invalid renote param'); // Get 'media' parameter - const [media = null, mediaErr] = $(params.media).optional.nullable.boolean().$; + const [media = null, mediaErr] = $(params.media).optional.nullable.boolean().get(); if (mediaErr) return rej('invalid media param'); // Get 'poll' parameter - const [poll = null, pollErr] = $(params.poll).optional.nullable.boolean().$; + const [poll = null, pollErr] = $(params.poll).optional.nullable.boolean().get(); if (pollErr) return rej('invalid poll param'); // Get 'sinceDate' parameter - const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().$; + const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().get(); if (sinceDateErr) throw 'invalid sinceDate param'; // Get 'untilDate' parameter - const [untilDate, untilDateErr] = $(params.untilDate).optional.number().$; + const [untilDate, untilDateErr] = $(params.untilDate).optional.number().get(); if (untilDateErr) throw 'invalid untilDate param'; // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 30).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 30).get(); if (limitErr) return rej('invalid limit param'); let includeUsers = includeUserIds; diff --git a/src/server/api/endpoints/notes/show.ts b/src/server/api/endpoints/notes/show.ts index 266e0687e9..2a4f8f97e1 100644 --- a/src/server/api/endpoints/notes/show.ts +++ b/src/server/api/endpoints/notes/show.ts @@ -13,7 +13,7 @@ import Note, { pack } from '../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'noteId' parameter - const [noteId, noteIdErr] = $(params.noteId).type(ID).$; + const [noteId, noteIdErr] = $(params.noteId).type(ID).get(); if (noteIdErr) return rej('invalid noteId param'); // Get note diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts index 476d64158c..222f0b795f 100644 --- a/src/server/api/endpoints/notes/timeline.ts +++ b/src/server/api/endpoints/notes/timeline.ts @@ -13,23 +13,23 @@ import { pack } from '../../../../models/note'; */ module.exports = async (params, user, app) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) throw 'invalid limit param'; // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) throw 'invalid sinceId param'; // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) throw 'invalid untilId param'; // Get 'sinceDate' parameter - const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().$; + const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().get(); if (sinceDateErr) throw 'invalid sinceDate param'; // Get 'untilDate' parameter - const [untilDate, untilDateErr] = $(params.untilDate).optional.number().$; + const [untilDate, untilDateErr] = $(params.untilDate).optional.number().get(); if (untilDateErr) throw 'invalid untilDate param'; // Check if only one of sinceId, untilId, sinceDate, untilDate specified @@ -38,11 +38,11 @@ module.exports = async (params, user, app) => { } // Get 'includeMyRenotes' parameter - const [includeMyRenotes = true, includeMyRenotesErr] = $(params.includeMyRenotes).optional.boolean().$; + const [includeMyRenotes = true, includeMyRenotesErr] = $(params.includeMyRenotes).optional.boolean().get(); if (includeMyRenotesErr) throw 'invalid includeMyRenotes param'; // Get 'includeRenotedMyNotes' parameter - const [includeRenotedMyNotes = true, includeRenotedMyNotesErr] = $(params.includeRenotedMyNotes).optional.boolean().$; + const [includeRenotedMyNotes = true, includeRenotedMyNotesErr] = $(params.includeRenotedMyNotes).optional.boolean().get(); if (includeRenotedMyNotesErr) throw 'invalid includeRenotedMyNotes param'; const [followings, watchingChannelIds, mutedUserIds] = await Promise.all([ diff --git a/src/server/api/endpoints/notes/trend.ts b/src/server/api/endpoints/notes/trend.ts index 48ecd5b843..915d45ce91 100644 --- a/src/server/api/endpoints/notes/trend.ts +++ b/src/server/api/endpoints/notes/trend.ts @@ -14,27 +14,27 @@ import Note, { pack } from '../../../../models/note'; */ module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'reply' parameter - const [reply, replyErr] = $(params.reply).optional.boolean().$; + const [reply, replyErr] = $(params.reply).optional.boolean().get(); if (replyErr) return rej('invalid reply param'); // Get 'renote' parameter - const [renote, renoteErr] = $(params.renote).optional.boolean().$; + const [renote, renoteErr] = $(params.renote).optional.boolean().get(); if (renoteErr) return rej('invalid renote param'); // Get 'media' parameter - const [media, mediaErr] = $(params.media).optional.boolean().$; + const [media, mediaErr] = $(params.media).optional.boolean().get(); if (mediaErr) return rej('invalid media param'); // Get 'poll' parameter - const [poll, pollErr] = $(params.poll).optional.boolean().$; + const [poll, pollErr] = $(params.poll).optional.boolean().get(); if (pollErr) return rej('invalid poll param'); const query = { diff --git a/src/server/api/endpoints/notes/user-list-timeline.ts b/src/server/api/endpoints/notes/user-list-timeline.ts index bb94fa0ab9..8d4eb590cb 100644 --- a/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/src/server/api/endpoints/notes/user-list-timeline.ts @@ -12,23 +12,23 @@ import UserList from '../../../../models/user-list'; */ module.exports = async (params, user, app) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) throw 'invalid limit param'; // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) throw 'invalid sinceId param'; // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) throw 'invalid untilId param'; // Get 'sinceDate' parameter - const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().$; + const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().get(); if (sinceDateErr) throw 'invalid sinceDate param'; // Get 'untilDate' parameter - const [untilDate, untilDateErr] = $(params.untilDate).optional.number().$; + const [untilDate, untilDateErr] = $(params.untilDate).optional.number().get(); if (untilDateErr) throw 'invalid untilDate param'; // Check if only one of sinceId, untilId, sinceDate, untilDate specified @@ -37,15 +37,15 @@ module.exports = async (params, user, app) => { } // Get 'includeMyRenotes' parameter - const [includeMyRenotes = true, includeMyRenotesErr] = $(params.includeMyRenotes).optional.boolean().$; + const [includeMyRenotes = true, includeMyRenotesErr] = $(params.includeMyRenotes).optional.boolean().get(); if (includeMyRenotesErr) throw 'invalid includeMyRenotes param'; // Get 'includeRenotedMyNotes' parameter - const [includeRenotedMyNotes = true, includeRenotedMyNotesErr] = $(params.includeRenotedMyNotes).optional.boolean().$; + const [includeRenotedMyNotes = true, includeRenotedMyNotesErr] = $(params.includeRenotedMyNotes).optional.boolean().get(); if (includeRenotedMyNotesErr) throw 'invalid includeRenotedMyNotes param'; // Get 'listId' parameter - const [listId, listIdErr] = $(params.listId).type(ID).$; + const [listId, listIdErr] = $(params.listId).type(ID).get(); if (listIdErr) throw 'invalid listId param'; const [list, mutedUserIds] = await Promise.all([ diff --git a/src/server/api/endpoints/othello/games.ts b/src/server/api/endpoints/othello/games.ts index 3b23b60637..05bff180c1 100644 --- a/src/server/api/endpoints/othello/games.ts +++ b/src/server/api/endpoints/othello/games.ts @@ -3,19 +3,19 @@ import OthelloGame, { pack } from '../../../../models/othello-game'; module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'my' parameter - const [my = false, myErr] = $(params.my).optional.boolean().$; + const [my = false, myErr] = $(params.my).optional.boolean().get(); if (myErr) return rej('invalid my param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Check if both of sinceId and untilId is specified diff --git a/src/server/api/endpoints/othello/games/show.ts b/src/server/api/endpoints/othello/games/show.ts index d76c6556a2..991bb9622e 100644 --- a/src/server/api/endpoints/othello/games/show.ts +++ b/src/server/api/endpoints/othello/games/show.ts @@ -4,7 +4,7 @@ import Othello from '../../../../../othello/core'; module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'gameId' parameter - const [gameId, gameIdErr] = $(params.gameId).type(ID).$; + const [gameId, gameIdErr] = $(params.gameId).type(ID).get(); if (gameIdErr) return rej('invalid gameId param'); const game = await OthelloGame.findOne({ _id: gameId }); diff --git a/src/server/api/endpoints/othello/match.ts b/src/server/api/endpoints/othello/match.ts index b73b64437b..9769c94da3 100644 --- a/src/server/api/endpoints/othello/match.ts +++ b/src/server/api/endpoints/othello/match.ts @@ -7,7 +7,7 @@ import { eighteight } from '../../../../othello/maps'; module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [childId, childIdErr] = $(params.userId).type(ID).$; + const [childId, childIdErr] = $(params.userId).type(ID).get(); if (childIdErr) return rej('invalid userId param'); // Myself diff --git a/src/server/api/endpoints/sw/register.ts b/src/server/api/endpoints/sw/register.ts index 3fe0bda4ee..222e6edc8e 100644 --- a/src/server/api/endpoints/sw/register.ts +++ b/src/server/api/endpoints/sw/register.ts @@ -9,15 +9,15 @@ import Subscription from '../../../../models/sw-subscription'; */ module.exports = async (params, user, app) => new Promise(async (res, rej) => { // Get 'endpoint' parameter - const [endpoint, endpointErr] = $(params.endpoint).string().$; + const [endpoint, endpointErr] = $(params.endpoint).string().get(); if (endpointErr) return rej('invalid endpoint param'); // Get 'auth' parameter - const [auth, authErr] = $(params.auth).string().$; + const [auth, authErr] = $(params.auth).string().get(); if (authErr) return rej('invalid auth param'); // Get 'publickey' parameter - const [publickey, publickeyErr] = $(params.publickey).string().$; + const [publickey, publickeyErr] = $(params.publickey).string().get(); if (publickeyErr) return rej('invalid publickey param'); // if already subscribed diff --git a/src/server/api/endpoints/username/available.ts b/src/server/api/endpoints/username/available.ts index bd27c37de0..65b297683d 100644 --- a/src/server/api/endpoints/username/available.ts +++ b/src/server/api/endpoints/username/available.ts @@ -13,7 +13,7 @@ import { validateUsername } from '../../../../models/user'; */ module.exports = async (params) => new Promise(async (res, rej) => { // Get 'username' parameter - const [username, usernameError] = $(params.username).string().pipe(validateUsername).$; + const [username, usernameError] = $(params.username).string().pipe(validateUsername).get(); if (usernameError) return rej('invalid username param'); // Get exist diff --git a/src/server/api/endpoints/users.ts b/src/server/api/endpoints/users.ts index 5b389d452f..2f7d00fa84 100644 --- a/src/server/api/endpoints/users.ts +++ b/src/server/api/endpoints/users.ts @@ -9,15 +9,15 @@ import User, { pack } from '../../../models/user'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'sort' parameter - const [sort, sortError] = $(params.sort).optional.string().or('+follower|-follower').$; + const [sort, sortError] = $(params.sort).optional.string().or('+follower|-follower').get(); if (sortError) return rej('invalid sort param'); // Construct query diff --git a/src/server/api/endpoints/users/followers.ts b/src/server/api/endpoints/users/followers.ts index 940b5ed9bc..7892f633d4 100644 --- a/src/server/api/endpoints/users/followers.ts +++ b/src/server/api/endpoints/users/followers.ts @@ -12,19 +12,19 @@ import { getFriendIds } from '../../common/get-friends'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Get 'iknow' parameter - const [iknow = false, iknowErr] = $(params.iknow).optional.boolean().$; + const [iknow = false, iknowErr] = $(params.iknow).optional.boolean().get(); if (iknowErr) return rej('invalid iknow param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'cursor' parameter - const [cursor = null, cursorErr] = $(params.cursor).optional.type(ID).$; + const [cursor = null, cursorErr] = $(params.cursor).optional.type(ID).get(); if (cursorErr) return rej('invalid cursor param'); // Lookup user diff --git a/src/server/api/endpoints/users/following.ts b/src/server/api/endpoints/users/following.ts index 63a73a2e27..e584e61f9c 100644 --- a/src/server/api/endpoints/users/following.ts +++ b/src/server/api/endpoints/users/following.ts @@ -16,19 +16,19 @@ import { getFriendIds } from '../../common/get-friends'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Get 'iknow' parameter - const [iknow = false, iknowErr] = $(params.iknow).optional.boolean().$; + const [iknow = false, iknowErr] = $(params.iknow).optional.boolean().get(); if (iknowErr) return rej('invalid iknow param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'cursor' parameter - const [cursor = null, cursorErr] = $(params.cursor).optional.type(ID).$; + const [cursor = null, cursorErr] = $(params.cursor).optional.type(ID).get(); if (cursorErr) return rej('invalid cursor param'); // Lookup user diff --git a/src/server/api/endpoints/users/get_frequently_replied_users.ts b/src/server/api/endpoints/users/get_frequently_replied_users.ts index 4c00620a52..034684260c 100644 --- a/src/server/api/endpoints/users/get_frequently_replied_users.ts +++ b/src/server/api/endpoints/users/get_frequently_replied_users.ts @@ -7,11 +7,11 @@ import User, { pack } from '../../../../models/user'; module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Lookup user diff --git a/src/server/api/endpoints/users/lists/create.ts b/src/server/api/endpoints/users/lists/create.ts index 6ae510f52b..79a680c736 100644 --- a/src/server/api/endpoints/users/lists/create.ts +++ b/src/server/api/endpoints/users/lists/create.ts @@ -9,7 +9,7 @@ import UserList, { pack } from '../../../../../models/user-list'; */ module.exports = async (params, user) => new Promise(async (res, rej) => { // Get 'title' parameter - const [title, titleErr] = $(params.title).string().range(1, 100).$; + const [title, titleErr] = $(params.title).string().range(1, 100).get(); if (titleErr) return rej('invalid title param'); // insert diff --git a/src/server/api/endpoints/users/lists/push.ts b/src/server/api/endpoints/users/lists/push.ts index 5d6f201524..ceb5692c81 100644 --- a/src/server/api/endpoints/users/lists/push.ts +++ b/src/server/api/endpoints/users/lists/push.ts @@ -11,7 +11,7 @@ import { deliver } from '../../../../../queue'; */ module.exports = async (params, me) => new Promise(async (res, rej) => { // Get 'listId' parameter - const [listId, listIdErr] = $(params.listId).type(ID).$; + const [listId, listIdErr] = $(params.listId).type(ID).get(); if (listIdErr) return rej('invalid listId param'); // Fetch the list @@ -25,7 +25,7 @@ module.exports = async (params, me) => new Promise(async (res, rej) => { } // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).type(ID).$; + const [userId, userIdErr] = $(params.userId).type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Fetch the user diff --git a/src/server/api/endpoints/users/lists/show.ts b/src/server/api/endpoints/users/lists/show.ts index 61e0f0463f..54e1df7b2f 100644 --- a/src/server/api/endpoints/users/lists/show.ts +++ b/src/server/api/endpoints/users/lists/show.ts @@ -6,7 +6,7 @@ import UserList, { pack } from '../../../../../models/user-list'; */ module.exports = async (params, me) => new Promise(async (res, rej) => { // Get 'listId' parameter - const [listId, listIdErr] = $(params.listId).type(ID).$; + const [listId, listIdErr] = $(params.listId).type(ID).get(); if (listIdErr) return rej('invalid listId param'); // Fetch the list diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index dafa18bcc9..67b14b36a3 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -11,11 +11,11 @@ import User from '../../../../models/user'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).optional.type(ID).$; + const [userId, userIdErr] = $(params.userId).optional.type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Get 'username' parameter - const [username, usernameErr] = $(params.username).optional.string().$; + const [username, usernameErr] = $(params.username).optional.string().get(); if (usernameErr) return rej('invalid username param'); if (userId === undefined && username === undefined) { @@ -23,7 +23,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => { } // Get 'host' parameter - const [host, hostErr] = $(params.host).optional.string().$; + const [host, hostErr] = $(params.host).optional.string().get(); if (hostErr) return rej('invalid host param'); if (userId === undefined && host === undefined) { @@ -31,31 +31,31 @@ module.exports = (params, me) => new Promise(async (res, rej) => { } // Get 'includeReplies' parameter - const [includeReplies = true, includeRepliesErr] = $(params.includeReplies).optional.boolean().$; + const [includeReplies = true, includeRepliesErr] = $(params.includeReplies).optional.boolean().get(); if (includeRepliesErr) return rej('invalid includeReplies param'); // Get 'withMedia' parameter - const [withMedia = false, withMediaErr] = $(params.withMedia).optional.boolean().$; + const [withMedia = false, withMediaErr] = $(params.withMedia).optional.boolean().get(); if (withMediaErr) return rej('invalid withMedia param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'sinceId' parameter - const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$; + const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).get(); if (sinceIdErr) return rej('invalid sinceId param'); // Get 'untilId' parameter - const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$; + const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).get(); if (untilIdErr) return rej('invalid untilId param'); // Get 'sinceDate' parameter - const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().$; + const [sinceDate, sinceDateErr] = $(params.sinceDate).optional.number().get(); if (sinceDateErr) throw 'invalid sinceDate param'; // Get 'untilDate' parameter - const [untilDate, untilDateErr] = $(params.untilDate).optional.number().$; + const [untilDate, untilDateErr] = $(params.untilDate).optional.number().get(); if (untilDateErr) throw 'invalid untilDate param'; // Check if only one of sinceId, untilId, sinceDate, untilDate specified diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts index f72bb04bf1..f48ac7cb28 100644 --- a/src/server/api/endpoints/users/recommendation.ts +++ b/src/server/api/endpoints/users/recommendation.ts @@ -16,11 +16,11 @@ import Mute from '../../../../models/mute'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // ID list of the user itself and other users who the user follows diff --git a/src/server/api/endpoints/users/search.ts b/src/server/api/endpoints/users/search.ts index da30f47c2a..48630c6fd3 100644 --- a/src/server/api/endpoints/users/search.ts +++ b/src/server/api/endpoints/users/search.ts @@ -16,15 +16,15 @@ const escapeRegexp = require('escape-regexp'); */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'query' parameter - const [query, queryError] = $(params.query).string().pipe(x => x != '').$; + const [query, queryError] = $(params.query).string().pipe(x => x != '').get(); if (queryError) return rej('invalid query param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'max' parameter - const [max = 10, maxErr] = $(params.max).optional.number().range(1, 30).$; + const [max = 10, maxErr] = $(params.max).optional.number().range(1, 30).get(); if (maxErr) return rej('invalid max param'); // If Elasticsearch is available, search by $ diff --git a/src/server/api/endpoints/users/search_by_username.ts b/src/server/api/endpoints/users/search_by_username.ts index 91d9ad1f3a..da38347956 100644 --- a/src/server/api/endpoints/users/search_by_username.ts +++ b/src/server/api/endpoints/users/search_by_username.ts @@ -9,15 +9,15 @@ import User, { pack } from '../../../../models/user'; */ module.exports = (params, me) => new Promise(async (res, rej) => { // Get 'query' parameter - const [query, queryError] = $(params.query).string().$; + const [query, queryError] = $(params.query).string().get(); if (queryError) return rej('invalid query param'); // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; + const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).get(); if (offsetErr) return rej('invalid offset param'); // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).get(); if (limitErr) return rej('invalid limit param'); const users = await User diff --git a/src/server/api/endpoints/users/show.ts b/src/server/api/endpoints/users/show.ts index 141565ece6..89a8684538 100644 --- a/src/server/api/endpoints/users/show.ts +++ b/src/server/api/endpoints/users/show.ts @@ -14,19 +14,19 @@ module.exports = (params, me) => new Promise(async (res, rej) => { let user; // Get 'userId' parameter - const [userId, userIdErr] = $(params.userId).optional.type(ID).$; + const [userId, userIdErr] = $(params.userId).optional.type(ID).get(); if (userIdErr) return rej('invalid userId param'); // Get 'userIds' parameter - const [userIds, userIdsErr] = $(params.userIds).optional.array($().type(ID)).$; + const [userIds, userIdsErr] = $(params.userIds).optional.array($().type(ID)).get(); if (userIdsErr) return rej('invalid userIds param'); // Get 'username' parameter - const [username, usernameErr] = $(params.username).optional.string().$; + const [username, usernameErr] = $(params.username).optional.string().get(); if (usernameErr) return rej('invalid username param'); // Get 'host' parameter - const [host, hostErr] = $(params.host).nullable.optional.string().$; + const [host, hostErr] = $(params.host).nullable.optional.string().get(); if (hostErr) return rej('invalid host param'); if (userIds) { diff --git a/webpack.config.ts b/webpack.config.ts index 96eaf9f4c8..0e12fda633 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -5,6 +5,7 @@ import * as fs from 'fs'; import * as webpack from 'webpack'; import chalk from 'chalk'; +const { VueLoaderPlugin } = require('vue-loader'); import jsonImporter from 'node-sass-json-importer'; const minifyHtml = require('html-minifier').minify; const WebpackOnBuildPlugin = require('on-build-webpack'); @@ -117,7 +118,8 @@ module.exports = entries.map(x => { fs.writeFileSync('./built/client/meta.json', JSON.stringify({ version }), 'utf-8'); - }) + }), + new VueLoaderPlugin() ]; if (isProduction) { @@ -135,7 +137,9 @@ module.exports = entries.map(x => { loader: 'vue-loader', options: { cssSourceMap: false, - preserveWhitespace: false + compilerOptions: { + preserveWhitespace: false + } } }, { loader: 'replace', @@ -165,17 +169,32 @@ module.exports = entries.map(x => { } }] }, { - test: /\.styl$/, + test: /\.styl(us)?$/, exclude: /node_modules/, - use: [{ - loader: 'style-loader' + oneOf: [{ + resourceQuery: /module/, + use: [{ + loader: 'vue-style-loader' + }, { + loader: 'css-loader', + options: { + modules: true, + minimize: true + } + }, { + loader: 'stylus-loader' + }] }, { - loader: 'css-loader', - options: { - minimize: true - } - }, { - loader: 'stylus-loader' + use: [{ + loader: 'vue-style-loader' + }, { + loader: 'css-loader', + options: { + minimize: true + } + }, { + loader: 'stylus-loader' + }] }] }, { test: /\.scss$/, @@ -196,7 +215,7 @@ module.exports = entries.map(x => { }, { test: /\.css$/, use: [{ - loader: 'style-loader' + loader: 'vue-style-loader' }, { loader: 'css-loader', options: {