mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
13 lines
424 B
CoffeeScript
13 lines
424 B
CoffeeScript
|
Settings = require "settings-sharelatex"
|
||
|
logger = require "logger-sharelatex"
|
||
|
|
||
|
module.exports =
|
||
|
parse: (data, callback = (error, parsed) ->) ->
|
||
|
if data.length > (Settings.max_doc_length or 2 * 1024 * 1024)
|
||
|
logger.error {head: data.slice(0,1024)}, "data too large to parse"
|
||
|
return callback new Error("data too large to parse")
|
||
|
try
|
||
|
parsed = JSON.parse(data)
|
||
|
catch e
|
||
|
return callback e
|
||
|
callback null, parsed
|