mirror of
https://github.com/2234839/web-font.git
synced 2025-12-08 19:22:52 +08:00
微调接口
This commit is contained in:
parent
c6372ea8c3
commit
4230db9058
@ -19,7 +19,8 @@ const logMiddleware: cMiddleware = async (req, res, next) => {
|
||||
const t1 = Date.now();
|
||||
const r = await next(req, res);
|
||||
const t2 = Date.now();
|
||||
console.log(`[${t2 - t1}ms] ${req.url.split("?")[0]}`);
|
||||
const url = new URL(req.url);
|
||||
console.log(`[${t2 - t1}ms] ${url.pathname}`);
|
||||
return r;
|
||||
};
|
||||
|
||||
@ -130,7 +131,6 @@ const fontApiMiddleware: cMiddleware = async (req, res, next) => {
|
||||
const server = new SimpleHttpServer({ port: 8087 });
|
||||
server.use(
|
||||
logMiddleware,
|
||||
// limitMiddleware,
|
||||
corsMiddleware,
|
||||
fontApiMiddleware,
|
||||
staticFileMiddleware,
|
||||
|
||||
@ -73,6 +73,7 @@ async function connectionHandle(
|
||||
},
|
||||
handle: cNext,
|
||||
) {
|
||||
// connection.readable.
|
||||
const { header, body } = await createStreamAfterTarget(connection.readable, target);
|
||||
if (!header) {
|
||||
return;
|
||||
|
||||
@ -14,14 +14,12 @@ export function createTcpServer(
|
||||
socket.on("data", (chunk) => {
|
||||
controller.enqueue(new Uint8Array(chunk));
|
||||
});
|
||||
|
||||
socket.on("end", () => {
|
||||
controller.close();
|
||||
});
|
||||
|
||||
socket.on("error", (err) => {
|
||||
controller.error(err);
|
||||
});
|
||||
socket.on("close", () => {
|
||||
controller.close();
|
||||
});
|
||||
},
|
||||
cancel() {
|
||||
socket.destroy();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user