Task #28 - 'Magic trick' - correct lengthy code
This commit is contained in:
parent
68b20a5cf4
commit
5211694adb
29
app/controllers/Export.controller.js
Normal file
29
app/controllers/Export.controller.js
Normal file
@ -0,0 +1,29 @@
|
||||
const Controller = require('libflitter/controller/Controller')
|
||||
|
||||
/*
|
||||
* Export Controller
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class Export extends Controller {
|
||||
static get services() {
|
||||
return [...super.services, 'models']
|
||||
}
|
||||
/*
|
||||
* Serve the main page.
|
||||
*/
|
||||
async json_export(req, res){
|
||||
const Page = this.models.get('api:Page')
|
||||
const user = req.user
|
||||
const pages = await Page.find({OrgUserId:user._id})
|
||||
|
||||
const ExportData = {}
|
||||
for (const page of pages ) {
|
||||
const PageData = {...page}
|
||||
ExportData[page.Name] = PageData
|
||||
}
|
||||
return res.api(ExportData)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = Export
|
Loading…
Reference in New Issue
Block a user