Import file fron shutdown fix

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-02-11 18:48:26 +06:00
parent aca81cedb0
commit 226cdc9f80

View File

@ -190,6 +190,7 @@ export function start (config: { transactorEndpoint: string, elasticUrl: string,
// todo remove it after update all customers chrome extensions
app.get('/import', (req, res) => {
try {
const authHeader = req.headers.authorization
if (authHeader === undefined) {
res.status(403).send()
@ -200,6 +201,10 @@ export function start (config: { transactorEndpoint: string, elasticUrl: string,
const url = req.query.url as string
const cookie = req.query.cookie as string | undefined
const attachedTo = req.query.attachedTo as Ref<Doc> | undefined
if (url === undefined) {
res.status(500).send('URL param is not defined')
return
}
console.log('importing from', url)
console.log('cookie', cookie)
@ -265,9 +270,14 @@ export function start (config: { transactorEndpoint: string, elasticUrl: string,
res.status(500).send(err)
})
})
} catch (error) {
console.log(error)
res.status(500).send()
}
})
app.post('/import', (req, res) => {
try {
const authHeader = req.headers.authorization
if (authHeader === undefined) {
res.status(403).send()
@ -276,6 +286,10 @@ export function start (config: { transactorEndpoint: string, elasticUrl: string,
const token = authHeader.split(' ')[1]
const payload = decodeToken(token)
const { url, cookie, attachedTo, space } = req.body
if (url === undefined) {
res.status(500).send('URL param is not defined')
return
}
console.log('importing from', url)
console.log('cookie', cookie)
@ -340,6 +354,10 @@ export function start (config: { transactorEndpoint: string, elasticUrl: string,
res.status(500).send(err)
})
})
} catch (error) {
console.log(error)
res.status(500).send()
}
})
app.get('*', function (request, response) {