rm middleware/error

This commit is contained in:
tmshv committed 2019-08-04 19:57:27 +03:00
1 parent bdf9b29f1e
commit 2ab341cd71
1 file changed
-18
-18
View File
@@ -1,18 +0,0 @@
const {readFile} = require('async-file')
const handlebars = require('handlebars')
function notFound(templateFile) {
return async (ctx, next) => {
await next()
if (ctx.status === 404) {
const source = await readFile(templateFile, 'utf-8')
const template = handlebars.compile(source)
ctx.type = 'text/html'
ctx.body = template()
}
}
}
exports.notFound = notFound