Make new route in api instead of going through npm script; new retrieveAll call for controller

This commit is contained in:
efarooqui
2021-02-08 11:49:43 -08:00
parent d6d565a0fc
commit 7bafcb0343
4 changed files with 39 additions and 0 deletions

View File

@@ -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()