@keyto/koa2-servertiming
v1.0.2
Published
## 安装
Downloads
1
Readme
@keyto/koa2-servertiming
安装
$ pnpm add -D @keyto/koa2-servertiming
使用
import Koa from "koa";
import { ServerTimingPlugin } from "../dist/index.js";
const koa = new Koa();
koa.use(ServerTimingPlugin({ enable: process.env.NODE_ENV !== "production" }));
koa.use(async (ctx) => {
const delay = ctx.query["delay"];
if (Number(delay) > 0) {
await new Promise((resolve) => setTimeout(resolve, Number(delay)));
}
ctx.body = "Hello World";
});
koa.listen(3000, () => {
console.log("open http://localhost:3000/?delay=1000");
});
// $ curl -i localhost:3000/?delay=1000