const Controller = require('libflitter/controller/Controller') const { ObjectId } = require("mongodb"); const Page = require("../../../models/api/Page.model") /* * Misc Controller * ------------------------------------------------------------- * Put some description here! */ class Misc extends Controller { hello_world(req, res) { return res.api({ hello: 'world', }) } async save_page(req, res) { // return res.status(400).message('Missing required field: some_field').api({}) // Name, Parent, originalID requried_fields = { Name: String, Parent: ObjectId, OriginalId: ObjectId } requried_fields.name = req.name requried_fields.Parrent = req.Parrent requried_fields.OriginalId = req.OriginalId if (!requried_fields.Name) { return res.status(400).message('Missing required field: Name').api({}) } else if (!requried_fields.Parrent) { return res.status(400).message('Missing required field: Parent').api({}) } else if (!requried_fields.ObjectId) { return res.status(400).message('Missing required field: ObjectId').api({}) } if (req.body.PageId) { //use the page model to find by id and const page = await Page.findById(req.body.PageId) if (!page) { } } } } module.exports = exports = Misc