mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 09:45:37 -04:00
Move old backend code to old_src folder
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
c42d2223e8
commit
7b9f9a487b
97 changed files with 7 additions and 7 deletions
34
old_src/lib/web/imageRouter/lutim.ts
Normal file
34
old_src/lib/web/imageRouter/lutim.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import lutim from 'old_src/lib/web/imageRouter/lutim'
|
||||
|
||||
import { config } from '../../config'
|
||||
import { logger } from '../../logger'
|
||||
import { UploadProvider } from './index'
|
||||
|
||||
const LutimUploadProvider: UploadProvider = {
|
||||
uploadImage: (imagePath, callback) => {
|
||||
if (!callback || typeof callback !== 'function') {
|
||||
logger.error('Callback has to be a function')
|
||||
return
|
||||
}
|
||||
|
||||
if (!imagePath) {
|
||||
callback(new Error('Image path is missing or wrong'), undefined)
|
||||
return
|
||||
}
|
||||
|
||||
if (config.lutim && config.lutim.url) {
|
||||
lutim.setAPIUrl(config.lutim.url)
|
||||
logger.debug(`Set lutim URL to ${lutim.getAPIUrl()}`)
|
||||
}
|
||||
|
||||
lutim.uploadImage(imagePath)
|
||||
.then(function (json) {
|
||||
logger.debug(`SERVER uploadimage success: ${JSON.stringify(json)}`)
|
||||
callback(undefined, lutim.getAPIUrl() + json.msg.short)
|
||||
}).catch(function (err) {
|
||||
callback(new Error(err), undefined)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export { LutimUploadProvider }
|
Loading…
Add table
Add a link
Reference in a new issue