41 lines
759 B
JavaScript
41 lines
759 B
JavaScript
|
/* eslint-disable no-throw-literal */
|
||
|
/* eslint-disable */
|
||
|
const KoaRouter = require('koa-router')
|
||
|
const router = new KoaRouter()
|
||
|
const fs = require('fs')
|
||
|
const path = require('path')
|
||
|
const Printer = require('../PrinterDev')
|
||
|
const KoaBody = require('koa-body')
|
||
|
const uuid = require('uuid')
|
||
|
/* eslint-enable */
|
||
|
|
||
|
router.use(async (c, n) => {
|
||
|
c.data = {
|
||
|
title: 'Printer System Dashboard'
|
||
|
}
|
||
|
let status = 1
|
||
|
try {
|
||
|
await n()
|
||
|
} catch (err) {
|
||
|
status = 0
|
||
|
if (typeof err === 'string') {
|
||
|
c.body = err
|
||
|
} else {
|
||
|
c.body = err.toString()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (c.async) {
|
||
|
c.body = {
|
||
|
status,
|
||
|
msg: c.body
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
router.get('/', async (c, n) => {
|
||
|
await c.render('dashboard/index', c.data)
|
||
|
})
|
||
|
|
||
|
module.exports = router
|