Import file fron shutdown fix
This commit is contained in:
Andrey Sobolev 2022-02-14 16:20:02 +07:00 committed by GitHub
commit 4ee0317149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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) {