Remove web /spelling/check endpoint (#21740)

GitOrigin-RevId: f10ebfec08ba1156eafce45078bc783ca934864d
This commit is contained in:
Alf Eaton
2024-11-11 09:05:04 +00:00
committed by Copybot
parent 5821dc7273
commit a50d76f4ea
3 changed files with 0 additions and 171 deletions
@@ -1,14 +1,6 @@
import request from 'request'
import Settings from '@overleaf/settings'
import logger from '@overleaf/logger'
import SessionManager from '../Authentication/SessionManager.js'
import LearnedWordsManager from './LearnedWordsManager.js'
const TEN_SECONDS = 1000 * 10
const languageCodeIsSupported = code =>
Settings.languages.some(lang => lang.code === code && lang.server !== false)
export default {
learn(req, res, next) {
const { word } = req.body
@@ -27,36 +19,4 @@ export default {
res.sendStatus(204)
})
},
proxyCheckRequestToSpellingApi(req, res) {
const { language } = req.body
if (!language) {
logger.error({}, '"language" field should be included for spell checking')
return res.status(422).json({ misspellings: [] })
}
if (!languageCodeIsSupported(language)) {
// this log statement can be changed to 'error' once projects with
// unsupported languages are removed from the DB
logger.debug({ language }, 'language not supported')
return res.status(422).json({ misspellings: [] })
}
const userId = SessionManager.getLoggedInUserId(req.session)
const url = `${Settings.apis.spelling.url}/user/${userId}/check`
req.headers.Host = Settings.apis.spelling.host
return request({
url,
method: 'POST',
headers: req.headers,
json: req.body,
timeout: TEN_SECONDS,
})
.on('error', function (error) {
logger.error({ err: error }, 'Spelling Check API error')
return res.status(500).end()
})
.pipe(res)
},
}
-5
View File
@@ -1110,11 +1110,6 @@ async function initialize(webRouter, privateApiRouter, publicApiRouter) {
TpdsController.deleteProjectContents
)
webRouter.post(
'/spelling/check',
AuthenticationController.requireLogin(),
SpellingController.proxyCheckRequestToSpellingApi
)
webRouter.post(
'/spelling/learn',
validate({