diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-10 15:26:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-10 16:38:32 +0200 |
commit | fd8710b897a67518d3a61c319e54b6a65ba443ef (patch) | |
tree | d9953b7e0bb4e5a119c872ab21021f4c1ab33bea /server/middlewares | |
parent | 31b6ddf86652502e0c96d77fa10861ce4af11aa4 (diff) | |
download | PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.tar.gz PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.tar.zst PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.zip |
Add logs endpoint
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/logs.ts | 31 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 8 |
2 files changed, 34 insertions, 5 deletions
diff --git a/server/middlewares/validators/logs.ts b/server/middlewares/validators/logs.ts new file mode 100644 index 000000000..7380c6edd --- /dev/null +++ b/server/middlewares/validators/logs.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | import * as express from 'express' | ||
2 | import { logger } from '../../helpers/logger' | ||
3 | import { areValidationErrors } from './utils' | ||
4 | import { isDateValid } from '../../helpers/custom-validators/misc' | ||
5 | import { query } from 'express-validator/check' | ||
6 | import { isValidLogLevel } from '../../helpers/custom-validators/logs' | ||
7 | |||
8 | const getLogsValidator = [ | ||
9 | query('startDate') | ||
10 | .custom(isDateValid).withMessage('Should have a valid start date'), | ||
11 | query('level') | ||
12 | .optional() | ||
13 | .custom(isValidLogLevel).withMessage('Should have a valid level'), | ||
14 | query('endDate') | ||
15 | .optional() | ||
16 | .custom(isDateValid).withMessage('Should have a valid end date'), | ||
17 | |||
18 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
19 | logger.debug('Checking getLogsValidator parameters.', { parameters: req.query }) | ||
20 | |||
21 | if (areValidationErrors(req, res)) return | ||
22 | |||
23 | return next() | ||
24 | } | ||
25 | ] | ||
26 | |||
27 | // --------------------------------------------------------------------------- | ||
28 | |||
29 | export { | ||
30 | getLogsValidator | ||
31 | } | ||
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index b70abf429..e247db708 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -14,18 +14,18 @@ import { | |||
14 | } from '../../../helpers/custom-validators/misc' | 14 | } from '../../../helpers/custom-validators/misc' |
15 | import { | 15 | import { |
16 | checkUserCanManageVideo, | 16 | checkUserCanManageVideo, |
17 | isVideoOriginallyPublishedAtValid, | 17 | doesVideoChannelOfAccountExist, |
18 | doesVideoExist, | ||
18 | isScheduleVideoUpdatePrivacyValid, | 19 | isScheduleVideoUpdatePrivacyValid, |
19 | isVideoCategoryValid, | 20 | isVideoCategoryValid, |
20 | doesVideoChannelOfAccountExist, | ||
21 | isVideoDescriptionValid, | 21 | isVideoDescriptionValid, |
22 | doesVideoExist, | ||
23 | isVideoFile, | 22 | isVideoFile, |
24 | isVideoFilterValid, | 23 | isVideoFilterValid, |
25 | isVideoImage, | 24 | isVideoImage, |
26 | isVideoLanguageValid, | 25 | isVideoLanguageValid, |
27 | isVideoLicenceValid, | 26 | isVideoLicenceValid, |
28 | isVideoNameValid, | 27 | isVideoNameValid, |
28 | isVideoOriginallyPublishedAtValid, | ||
29 | isVideoPrivacyValid, | 29 | isVideoPrivacyValid, |
30 | isVideoSupportValid, | 30 | isVideoSupportValid, |
31 | isVideoTagsValid | 31 | isVideoTagsValid |
@@ -37,10 +37,8 @@ import { authenticatePromiseIfNeeded } from '../../oauth' | |||
37 | import { areValidationErrors } from '../utils' | 37 | import { areValidationErrors } from '../utils' |
38 | import { cleanUpReqFiles } from '../../../helpers/express-utils' | 38 | import { cleanUpReqFiles } from '../../../helpers/express-utils' |
39 | import { VideoModel } from '../../../models/video/video' | 39 | import { VideoModel } from '../../../models/video/video' |
40 | import { UserModel } from '../../../models/account/user' | ||
41 | import { checkUserCanTerminateOwnershipChange, doesChangeVideoOwnershipExist } from '../../../helpers/custom-validators/video-ownership' | 40 | import { checkUserCanTerminateOwnershipChange, doesChangeVideoOwnershipExist } from '../../../helpers/custom-validators/video-ownership' |
42 | import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/video-change-ownership-accept.model' | 41 | import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/video-change-ownership-accept.model' |
43 | import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership' | ||
44 | import { AccountModel } from '../../../models/account/account' | 42 | import { AccountModel } from '../../../models/account/account' |
45 | import { VideoFetchType } from '../../../helpers/video' | 43 | import { VideoFetchType } from '../../../helpers/video' |
46 | import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' | 44 | import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' |