You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

35 lines
860 B

import { config, method, route, swagger, validate } from "@noderun/hapi-router";
import UploadFunc from "./_upload";
import Joi from "joi";
export default class {
index(request, h) {
return h.view("views/demo.ejs");
}
@config({
payload: {
maxBytes: 20000 * 1024 * 1024,
output: "stream",
parse: false,
// multipart: true,
allow: "multipart/form-data",
}
})
@method("POST")
@swagger("文件上传", "文件上传a ", ["sum", "api"])
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");
}
}