33 lines
734 B
33 lines
734 B
import { config, method, route } from "@noderun/hapi-router";
|
|
import UploadFunc from "./_upload";
|
|
|
|
export default class {
|
|
index(request, h) {
|
|
return h.view("views/index.ejs");
|
|
}
|
|
|
|
@config({
|
|
payload: {
|
|
maxBytes: 20000 * 1024 * 1024,
|
|
output: "stream",
|
|
parse: false,
|
|
allow: "multipart/form-data",
|
|
},
|
|
})
|
|
@method("POST")
|
|
async upload(req, h) {
|
|
const startTime = new Date().getTime();
|
|
const res = await UploadFunc(req, h);
|
|
const endTime = new Date().getTime();
|
|
console.log(
|
|
`该请求处理时间为:${Number(endTime - startTime).toFixed(2)}ms`
|
|
);
|
|
return res;
|
|
}
|
|
|
|
@route("/{path*}")
|
|
async 404(req, h) {
|
|
// 404页面
|
|
return h.view("404.ejs");
|
|
}
|
|
}
|
|
|