mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 21:59:00 +02:00
622ef18b28
Migrate spelling to ES modules GitOrigin-RevId: 4a200c8d1c28be44027cc8a3097e42575ab6593f
29 lines
831 B
JavaScript
29 lines
831 B
JavaScript
import logger from '@overleaf/logger'
|
|
import metrics from '@overleaf/metrics'
|
|
import OError from '@overleaf/o-error'
|
|
import * as SpellingAPIManager from './SpellingAPIManager.js'
|
|
|
|
function extractCheckRequestData(req) {
|
|
const token = req.params?.user_id
|
|
const wordCount = req.body?.words?.length
|
|
return { token, wordCount }
|
|
}
|
|
|
|
export function check(req, res) {
|
|
metrics.inc('spelling-check', 0.1)
|
|
const { token, wordCount } = extractCheckRequestData(req)
|
|
logger.debug({ token, wordCount }, 'running check')
|
|
SpellingAPIManager.runRequest(token, req.body, (error, result) => {
|
|
if (error != null) {
|
|
logger.error(
|
|
OError.tag(error, 'error processing spelling request', {
|
|
user_id: token,
|
|
wordCount,
|
|
})
|
|
)
|
|
return res.sendStatus(500)
|
|
}
|
|
res.send(result)
|
|
})
|
|
}
|