本文整理汇总了TypeScript中express-validator/check.param函数的典型用法代码示例。如果您正苦于以下问题:TypeScript param函数的具体用法?TypeScript param怎么用?TypeScript param使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了param函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: gameRouter
export function gameRouter(gameHandler: GameHandlerService): Router {
let router: Router = Router();
router.post('/',
[
body('title_ko').isString().not().isEmpty(),
body('title_en').isString().not().isEmpty(),
body('players').isArray(),
body('players.*').isInt().toInt(),
body('box.width').isInt().toInt(),
body('box.height').isInt().toInt(),
body('box.depth').isInt().toInt(),
body('setting.width').isInt().toInt(),
body('setting.height').isInt().toInt(),
],
handleValidationResult,
gameHandler.createGame.bind(gameHandler)
);
router.get('/:gid',
[param('gid').isNumeric().not().isEmpty()],
handleValidationResult,
gameHandler.getGame.bind(gameHandler)
);
return router;
}
示例2: groupRouter
export function groupRouter(groupHandler: GroupHandlerService): Router {
let router: Router = Router();
router.post('/',
[body('name').isString().not().isEmpty()],
handleValidationResult,
groupHandler.createGroup.bind(groupHandler)
);
router.get('/:groupid',
[param('groupid').isNumeric().not().isEmpty()],
handleValidationResult,
groupHandler.getGroup.bind(groupHandler)
);
return router;
}
示例3: userRouter
export function userRouter(userHandler: UserHandlerService): Router {
let router: Router = Router();
router.post('/signin',
[body('token').isString().not().isEmpty()],
handleValidationResult,
userHandler.createUser.bind(userHandler)
);
router.get('/:uid',
[param('uid').isNumeric().not().isEmpty()],
handleValidationResult,
userHandler.getUser.bind(userHandler)
);
router.get('/',
[query('authID').isString().optional()],
handleValidationResult,
userHandler.findUser.bind(userHandler)
);
return router;
}
示例4: param
import * as express from 'express'
import { body, param } from 'express-validator/check'
import { UserRight } from '../../../shared'
import { isAccountIdExist } from '../../helpers/custom-validators/accounts'
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
import {
isVideoChannelDescriptionValid, isVideoChannelExist,
isVideoChannelNameValid, isVideoChannelSupportValid
} from '../../helpers/custom-validators/video-channels'
import { logger } from '../../helpers/logger'
import { UserModel } from '../../models/account/user'
import { VideoChannelModel } from '../../models/video/video-channel'
import { areValidationErrors } from './utils'
const listVideoAccountChannelsValidator = [
param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking listVideoAccountChannelsValidator parameters', { parameters: req.body })
if (areValidationErrors(req, res)) return
if (!await isAccountIdExist(req.params.accountId, res)) return
return next()
}
]
const videoChannelsAddValidator = [
body('name').custom(isVideoChannelNameValid).withMessage('Should have a valid name'),
body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'),
body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'),
示例5: next
.json({
error: 'Cannot follow on a non HTTPS web server.'
})
.end()
}
logger.debug('Checking follow parameters', { parameters: req.body })
if (areValidationErrors(req, res)) return
return next()
}
]
const removeFollowingValidator = [
param('host').custom(isHostValid).withMessage('Should have a valid host'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking unfollow parameters', { parameters: req.params })
if (areValidationErrors(req, res)) return
const serverActor = await getServerActor()
const follow = await ActorFollowModel.loadByActorAndTargetHost(serverActor.id, req.params.host)
if (!follow) {
return res
.status(404)
.json({
error: `Follower ${req.params.host} not found.`
})
示例6: param
import * as express from 'express'
import { param } from 'express-validator/check'
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
import { isVideoExist } from '../../helpers/custom-validators/videos'
import { logger } from '../../helpers/logger'
import { VideoModel } from '../../models/video/video'
import { VideoBlacklistModel } from '../../models/video/video-blacklist'
import { areValidationErrors } from './utils'
const videosBlacklistRemoveValidator = [
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking blacklistRemove parameters.', { parameters: req.params })
if (areValidationErrors(req, res)) return
if (!await isVideoExist(req.params.videoId, res)) return
if (!await checkVideoIsBlacklisted(res.locals.video, res)) return
return next()
}
]
const videosBlacklistAddValidator = [
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videosBlacklist parameters', { parameters: req.params })
if (areValidationErrors(req, res)) return
if (!await isVideoExist(req.params.videoId, res)) return
示例7: param
import * as express from 'express'
import { param } from 'express-validator/check'
import {
isAccountIdExist,
isAccountNameValid,
isAccountNameWithHostExist,
isLocalAccountNameExist
} from '../../helpers/custom-validators/accounts'
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
const localAccountValidator = [
param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
if (areValidationErrors(req, res)) return
if (!await isLocalAccountNameExist(req.params.name, res)) return
return next()
}
]
const accountsGetValidator = [
param('id').custom(isIdOrUUIDValid).withMessage('Should have a valid id'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking accountsGetValidator parameters', { parameters: req.params })
示例8: param
import * as express from 'express'
import { body, param } from 'express-validator/check'
import { UserRight } from '../../../shared'
import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
import { isValidVideoCommentText } from '../../helpers/custom-validators/video-comments'
import { isVideoExist } from '../../helpers/custom-validators/videos'
import { logger } from '../../helpers/logger'
import { UserModel } from '../../models/account/user'
import { VideoModel } from '../../models/video/video'
import { VideoCommentModel } from '../../models/video/video-comment'
import { areValidationErrors } from './utils'
const listVideoCommentThreadsValidator = [
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking listVideoCommentThreads parameters.', { parameters: req.params })
if (areValidationErrors(req, res)) return
if (!await isVideoExist(req.params.videoId, res)) return
return next()
}
]
const listVideoThreadCommentsValidator = [
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
param('threadId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid threadId'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking listVideoThreadComments parameters.', { parameters: req.params })
示例9: param
import * as express from 'express'
import { param } from 'express-validator/check'
import { isAccountNameValid, isAccountNameWithHostExist, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
const localAccountValidator = [
param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
if (areValidationErrors(req, res)) return
if (!await isLocalAccountNameExist(req.params.name, res)) return
return next()
}
]
const accountsNameWithHostGetValidator = [
param('accountName').exists().withMessage('Should have an account name with host'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })
if (areValidationErrors(req, res)) return
if (!await isAccountNameWithHostExist(req.params.accountName, res)) return
return next()
}
]
示例10: param
import * as express from 'express'
import { param, query } from 'express-validator/check'
import { isAccountIdExist, isAccountNameValid } from '../../helpers/custom-validators/accounts'
import { join } from 'path'
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
import { isVideoChannelExist } from '../../helpers/custom-validators/video-channels'
import { isVideoExist } from '../../helpers/custom-validators/videos'
const videoFeedsValidator = [
param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
query('accountId').optional().custom(isIdOrUUIDValid),
query('accountName').optional().custom(isAccountNameValid),
query('videoChannelId').optional().custom(isIdOrUUIDValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking feeds parameters', { parameters: req.query })
if (areValidationErrors(req, res)) return
if (req.query.accountId && !await isAccountIdExist(req.query.accountId, res)) return
if (req.query.videoChannelId && !await isVideoChannelExist(req.query.videoChannelId, res)) return
return next()
}
]
const videoCommentsFeedsValidator = [