@ -2,7 +2,6 @@
const validator = require ( 'validator' ) ;
const validator = require ( 'validator' ) ;
const nconf = require ( 'nconf' ) ;
const nconf = require ( 'nconf' ) ;
const winston = require ( 'winston' ) ;
const meta = require ( '../meta' ) ;
const meta = require ( '../meta' ) ;
const user = require ( '../user' ) ;
const user = require ( '../user' ) ;
@ -10,7 +9,6 @@ const categories = require('../categories');
const plugins = require ( '../plugins' ) ;
const plugins = require ( '../plugins' ) ;
const translator = require ( '../translator' ) ;
const translator = require ( '../translator' ) ;
const languages = require ( '../languages' ) ;
const languages = require ( '../languages' ) ;
const api = require ( '../api' ) ;
const apiController = module . exports ;
const apiController = module . exports ;
@ -116,36 +114,6 @@ apiController.getConfig = async function (req, res) {
res . json ( config ) ;
res . json ( config ) ;
} ;
} ;
// TODO: Deprecate these four controllers in 1.17.0
apiController . getPostData = async ( pid , uid ) => api . posts . get ( { uid } , { pid } ) ;
apiController . getTopicData = async ( tid , uid ) => api . topics . get ( { uid } , { tid } ) ;
apiController . getCategoryData = async ( cid , uid ) => api . categories . get ( { uid } , { cid } ) ;
apiController . getObject = async function ( req , res , next ) {
const methods = {
post : apiController . getPostData ,
topic : apiController . getTopicData ,
category : apiController . getCategoryData ,
} ;
const method = methods [ req . params . type ] ;
if ( ! method ) {
return next ( ) ;
}
winston . warn ( '[api] This route has been deprecated and will likely be removed in v1.17.0' ) ;
winston . warn ( '[api] Use GET /api/v3/(posts|topics|categories)/:id instead' ) ;
try {
const result = await method ( req . params . id , req . uid ) ;
if ( ! result ) {
return next ( ) ;
}
res . json ( result ) ;
} catch ( err ) {
next ( err ) ;
}
} ;
apiController . getModerators = async function ( req , res ) {
apiController . getModerators = async function ( req , res ) {
const moderators = await categories . getModerators ( req . params . cid ) ;
const moderators = await categories . getModerators ( req . params . cid ) ;
res . json ( { moderators : moderators } ) ;
res . json ( { moderators : moderators } ) ;