import * as express from 'express'
import { getFormattedObjects } from '../../helpers/utils'
-import { asyncMiddleware, paginationValidator, setAccountsSort, setPagination } from '../../middlewares'
+import { asyncMiddleware, paginationValidator, setDefaultSort, setPagination } from '../../middlewares'
import { accountsGetValidator, accountsSortValidator } from '../../middlewares/validators'
import { AccountModel } from '../../models/account/account'
accountsRouter.get('/',
paginationValidator,
accountsSortValidator,
- setAccountsSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listAccounts)
)
import * as express from 'express'
import { UserRight } from '../../../shared/models/users'
import { getFormattedObjects } from '../../helpers/utils'
-import { asyncMiddleware, authenticate, ensureUserHasRight, jobsSortValidator, setJobsSort, setPagination } from '../../middlewares'
+import { asyncMiddleware, authenticate, ensureUserHasRight, jobsSortValidator, setDefaultSort, setPagination } from '../../middlewares'
import { paginationValidator } from '../../middlewares/validators'
import { JobModel } from '../../models/job/job'
ensureUserHasRight(UserRight.MANAGE_JOBS),
paginationValidator,
jobsSortValidator,
- setJobsSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listJobs)
)
import { getOrCreateActorAndServerAndModel } from '../../../lib/activitypub/actor'
import { sendFollow, sendUndoFollow } from '../../../lib/activitypub/send'
import {
- asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, removeFollowingValidator, setBodyHostsPort,
- setFollowersSort, setFollowingSort, setPagination
+ asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, removeFollowingValidator, setBodyHostsPort, setDefaultSort,
+ setPagination
} from '../../../middlewares'
import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators'
import { ActorModel } from '../../../models/activitypub/actor'
serverFollowsRouter.get('/following',
paginationValidator,
followingSortValidator,
- setFollowingSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listFollowing)
)
serverFollowsRouter.get('/followers',
paginationValidator,
followersSortValidator,
- setFollowersSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listFollowers)
)
import { sendUpdateUser } from '../../lib/activitypub/send'
import { createUserAccountAndChannel } from '../../lib/user'
import {
- asyncMiddleware, authenticate, ensureUserHasRight, ensureUserRegistrationAllowed, paginationValidator, setPagination, setUsersSort,
- setVideosSort, token, usersAddValidator, usersGetValidator, usersRegisterValidator, usersRemoveValidator, usersSortValidator,
+ asyncMiddleware, authenticate, ensureUserHasRight, ensureUserRegistrationAllowed, paginationValidator, setDefaultSort,
+ setPagination, token, usersAddValidator, usersGetValidator, usersRegisterValidator, usersRemoveValidator, usersSortValidator,
usersUpdateMeValidator, usersUpdateValidator, usersVideoRatingValidator
} from '../../middlewares'
import { usersUpdateMyAvatarValidator, videosSortValidator } from '../../middlewares/validators'
authenticate,
paginationValidator,
videosSortValidator,
- setVideosSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(getUserVideos)
)
ensureUserHasRight(UserRight.MANAGE_USERS),
paginationValidator,
usersSortValidator,
- setUsersSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listUsers)
)
import { sequelizeTypescript } from '../../../initializers'
import { sendVideoAbuse } from '../../../lib/activitypub/send'
import {
- asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, setPagination, setVideoAbusesSort,
- videoAbuseReportValidator, videoAbusesSortValidator
+ asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, setDefaultSort, setPagination, videoAbuseReportValidator,
+ videoAbusesSortValidator
} from '../../../middlewares'
import { AccountModel } from '../../../models/account/account'
import { VideoModel } from '../../../models/video/video'
ensureUserHasRight(UserRight.MANAGE_VIDEO_ABUSES),
paginationValidator,
videoAbusesSortValidator,
- setVideoAbusesSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listVideoAbuses)
)
import { setAsyncActorKeys } from '../../../lib/activitypub'
import { createVideoChannel } from '../../../lib/video-channel'
import {
- asyncMiddleware, authenticate, listVideoAccountChannelsValidator, paginationValidator, setPagination, setVideoChannelsSort,
+ asyncMiddleware, authenticate, listVideoAccountChannelsValidator, paginationValidator, setDefaultSort, setPagination,
videoChannelsAddValidator, videoChannelsGetValidator, videoChannelsRemoveValidator, videoChannelsSortValidator,
videoChannelsUpdateValidator
} from '../../../middlewares'
videoChannelRouter.get('/channels',
paginationValidator,
videoChannelsSortValidator,
- setVideoChannelsSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listVideoChannels)
)
import { getFormattedObjects } from '../../../helpers/utils'
import { sequelizeTypescript } from '../../../initializers'
import { buildFormattedCommentTree, createVideoComment } from '../../../lib/video-comment'
-import { asyncMiddleware, authenticate, paginationValidator, setPagination, setVideoCommentThreadsSort } from '../../../middlewares'
+import { asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setPagination } from '../../../middlewares'
import { videoCommentThreadsSortValidator } from '../../../middlewares/validators'
import {
addVideoCommentReplyValidator, addVideoCommentThreadValidator, listVideoCommentThreadsValidator, listVideoThreadCommentsValidator,
videoCommentRouter.get('/:videoId/comment-threads',
paginationValidator,
videoCommentThreadsSortValidator,
- setVideoCommentThreadsSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listVideoCommentThreadsValidator),
asyncMiddleware(listVideoThreads)
import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send'
import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler'
import {
- asyncMiddleware, authenticate, paginationValidator, setPagination, setVideosSort, videosAddValidator, videosGetValidator,
+ asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setPagination, videosAddValidator, videosGetValidator,
videosRemoveValidator, videosSearchValidator, videosSortValidator, videosUpdateValidator
} from '../../../middlewares'
import { TagModel } from '../../../models/video/tag'
videosRouter.get('/',
paginationValidator,
videosSortValidator,
- setVideosSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(listVideos)
)
videosSearchValidator,
paginationValidator,
videosSortValidator,
- setVideosSort,
+ setDefaultSort,
setPagination,
asyncMiddleware(searchVideos)
)
import 'express-validator'
import { SortType } from '../helpers/utils'
-function setAccountsSort (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!req.query.sort) req.query.sort = '-createdAt'
-
- return next()
-}
-
-function setUsersSort (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!req.query.sort) req.query.sort = '-createdAt'
-
- return next()
-}
-
-function setJobsSort (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!req.query.sort) req.query.sort = '-createdAt'
-
- return next()
-}
-
-function setVideoAbusesSort (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!req.query.sort) req.query.sort = '-createdAt'
-
- return next()
-}
-
-function setVideoChannelsSort (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!req.query.sort) req.query.sort = '-createdAt'
-
- return next()
-}
-
-function setVideosSort (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!req.query.sort) req.query.sort = '-createdAt'
-
- return next()
-}
-
-function setVideoCommentThreadsSort (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!req.query.sort) req.query.sort = '-createdAt'
-
- return next()
-}
-
-function setFollowersSort (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!req.query.sort) req.query.sort = '-createdAt'
-
- return next()
-}
-
-function setFollowingSort (req: express.Request, res: express.Response, next: express.NextFunction) {
+function setDefaultSort (req: express.Request, res: express.Response, next: express.NextFunction) {
if (!req.query.sort) req.query.sort = '-createdAt'
return next()
// ---------------------------------------------------------------------------
export {
- setUsersSort,
- setVideoAbusesSort,
- setVideoChannelsSort,
- setVideosSort,
- setBlacklistSort,
- setFollowersSort,
- setFollowingSort,
- setJobsSort,
- setVideoCommentThreadsSort,
- setAccountsSort
+ setDefaultSort,
+ setBlacklistSort
}