mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-11 04:48:32 +03:00
Make new route in api instead of going through npm script; new retrieveAll call for controller
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { version } from '../../package.json'
|
||||
import { Router } from 'express'
|
||||
import { exportToFile } from '../utilities'
|
||||
import copy from '../copy/en'
|
||||
|
||||
export default ({ config, controller }) => {
|
||||
@@ -22,6 +23,27 @@ export default ({ config, controller }) => {
|
||||
})
|
||||
})
|
||||
|
||||
api.get('/export', (req, res) => {
|
||||
const bps = controller.blueprints()
|
||||
const bpsParsed = bps.map(bp => ({
|
||||
sheet: bp.sheet.name,
|
||||
tab: bp.name,
|
||||
resources: bp.resources,
|
||||
url: bp.urls[0]
|
||||
}))
|
||||
controller
|
||||
.retrieveAll(bpsParsed)
|
||||
.then(msg =>
|
||||
res.json({
|
||||
success: msg
|
||||
})
|
||||
)
|
||||
.catch(err =>
|
||||
res.status(404)
|
||||
.send({ error: err.message, err })
|
||||
)
|
||||
})
|
||||
|
||||
api.get('/update', (req, res) => {
|
||||
controller
|
||||
.update()
|
||||
|
||||
Reference in New Issue
Block a user