Merge branch 'master' of ssh.dev.azure.com:v3/HackKu/HackKu%202020/backend

This commit is contained in:
garrettmills 2020-02-08 06:57:46 -06:00
commit 89a3386e97
5 changed files with 35 additions and 5 deletions

View 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

View File

@ -24,8 +24,8 @@ class Home extends Controller {
return res.page('welcome', {user: req.user})
}
async get_login(req, res){
const app_name = this.configs.get('app.name')
return res.page('login', {app_name})
const AppName = this.configs.get('app.name')
return res.page('login', {AppName})
}
}

View File

@ -18,8 +18,8 @@ class Example extends Model {
*/
static get schema() {
return {
name: String,
create_date: {type: Date, default: () => new Date},
Name: String,
CreateDate: {type: Date, default: () => new Date},
}
}

View File

@ -46,6 +46,7 @@ const index = {
// your own route protected by 'middleware::auth:UserOnly'
'/dash': [ 'controller::Home.welcome' ],
'/login': [ 'middleware::auth:GuestOnly', 'controller::Home.get_login' ],
'/test-export' : ['controller::Export.json_export' ],
},
/*

View File

@ -61,7 +61,7 @@ html
body
.container#intro
h1 Hi, Welcome to
span#name #{app_name}.
span#name #{AppName}.
h2 Choose your login method.
.container#login