加入WebAPI

1.PrinterDev add EventEmitter
2.add Printer WebAPI
This commit is contained in:
Jay
2017-09-10 12:08:45 +08:00
parent a7f7653efa
commit debf1f03d8
3 changed files with 56 additions and 33 deletions
+12
View File
@@ -37,4 +37,16 @@ router.get('/', async (c, n) => {
await c.render('dashboard/index', c.data)
})
router.post('/api/print', KoaBody(), async (c, n) => {
c.async = true
let arr = c.request.body
if (!arr.data) throw 'print data empty'
let status = await Printer.printerString(arr.data)
if (!status) throw 'printer fail'
c.body = 'print success'
})
module.exports = router