Rework #6
					 4 changed files with 6 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -103,7 +103,6 @@ async function renderZipImage(ctx: Context, path: string, page: number) {
 | 
			
		|||
 | 
			
		||||
		ctx.body = nodeReadableStream;
 | 
			
		||||
		ctx.response.length = entry.uncompressedSize;
 | 
			
		||||
		// console.log(`${entry.name}'s ${page}:${entry.size}`);
 | 
			
		||||
		ctx.response.type = entry.filename.split(".").pop() as string;
 | 
			
		||||
		ctx.status = 200;
 | 
			
		||||
		ctx.set("Date", new Date().toUTCString());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,6 @@ const ContentIDHandler = (controller: DocumentAccessor) => async (ctx: Context,
 | 
			
		|||
	}
 | 
			
		||||
	ctx.body = document;
 | 
			
		||||
	ctx.type = "json";
 | 
			
		||||
	console.log(document.additional);
 | 
			
		||||
};
 | 
			
		||||
const ContentTagIDHandler = (controller: DocumentAccessor) => async (ctx: Context, next: Next) => {
 | 
			
		||||
	const num = Number.parseInt(ctx.params.num);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -98,12 +98,14 @@ class ServerApplication {
 | 
			
		|||
		if (setting.mode === "development") {
 | 
			
		||||
			let mm_count = 0;
 | 
			
		||||
			app.use(async (ctx, next) => {
 | 
			
		||||
				console.log(`==========================${mm_count++}`);
 | 
			
		||||
				const ip = ctx.get("X-Real-IP") ?? ctx.ip;
 | 
			
		||||
				console.log(`=== Request No ${mm_count++} \t===`);
 | 
			
		||||
				const ip = ctx.get("X-Real-IP").length > 0 ? ctx.get("X-Real-IP") : ctx.ip;
 | 
			
		||||
				const fromClient = ctx.state.user.username === "" ? ip : ctx.state.user.username;
 | 
			
		||||
				console.log(`${fromClient} : ${ctx.method} ${ctx.url}`);
 | 
			
		||||
				console.log(`${mm_count}	${fromClient} : ${ctx.method} ${ctx.url}`);
 | 
			
		||||
				const start = Date.now();
 | 
			
		||||
				await next();
 | 
			
		||||
				// console.log(`404`);
 | 
			
		||||
				const end = Date.now();
 | 
			
		||||
				console.log(`${mm_count}	${fromClient} : ${ctx.method} ${ctx.url} ${ctx.status} ${end - start}ms`);
 | 
			
		||||
			});
 | 
			
		||||
		}
 | 
			
		||||
		app.use(router.routes());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,9 +39,7 @@ export async function readZip(path: string): Promise<{
 | 
			
		|||
	return { reader, handle: fd };
 | 
			
		||||
}
 | 
			
		||||
export async function entriesByNaturalOrder(zip: ZipReader<FileHandle>) {
 | 
			
		||||
	// console.log(zip);
 | 
			
		||||
	const entries = await zip.getEntries();
 | 
			
		||||
	// console.log(entries.map((v) => v.filename));
 | 
			
		||||
	const ret = orderBy(entries, (v) => v.filename);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue