Skip to content

Commit 4696012

Browse files
committed
Revert "chore: keepalive"
This reverts commit 58c9f4b.
1 parent 58c9f4b commit 4696012

File tree

3 files changed

+31
-121
lines changed

3 files changed

+31
-121
lines changed

nuxt.config.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ export default defineNuxtConfig({
1919
jwpubKey: process.env.JWPUB_KEY,
2020
},
2121
compatibilityDate: "2026-01-15",
22-
routeRules: {
23-
"/api/outlines": {
24-
// Mark as long-running operation
25-
cache: false,
26-
},
27-
"/api/export": {
28-
// Mark as long-running operation
29-
cache: false,
30-
},
31-
},
3222
piniaPluginPersistedstate: {
3323
storage: "localStorage",
3424
debug: true,

server/api/outlines.post.ts

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,36 @@
1-
import { type KeepAlive, withKeepAlive } from "../utils/keepalive";
2-
31
export default defineEventHandler(async (event) => {
4-
return withKeepAlive(
5-
event,
6-
async (keepalive: KeepAlive) => {
7-
keepalive.progress("Starting file upload processing...");
8-
9-
const database = await processFileUpload(event, {
10-
maxSize: 256 * 1024 * 1024,
11-
processor: async (fileStream) => {
12-
keepalive.progress("Extracting database from JWPUB file...");
13-
return await getJWPUBDatabase(fileStream);
14-
},
15-
});
16-
17-
keepalive.progress("Database extracted, querying documents...");
18-
const outlines = queryDatabase<{ Title: string }>(
19-
database,
20-
"SELECT Title FROM Document",
21-
);
22-
23-
keepalive.progress("Parsing JWPUB content...");
24-
const htmlOutlines = await parseJWPUB(database);
2+
event.node.req.setTimeout(1 * 60 * 60 * 1000);
3+
console.log("Getting outlines...");
4+
const database = await processFileUpload(event, {
5+
maxSize: 256 * 1024 * 1024,
6+
processor: async (fileStream) => {
7+
console.log("Processing file stream...");
8+
return await getJWPUBDatabase(fileStream);
9+
},
10+
});
2511

26-
keepalive.progress("Processing outlines...");
27-
const parsedOutlines = outlines
28-
.map((outline) => {
29-
const [number, ...title] = outline.Title.split(". ");
30-
return {
31-
number: parseInt(number?.trim() ?? "0"),
32-
title: title.join(". "),
33-
};
34-
})
35-
.filter((outline) => outline.number > 0);
12+
const outlines = queryDatabase<{ Title: string }>(
13+
database,
14+
"SELECT Title FROM Document",
15+
);
16+
const htmlOutlines = await parseJWPUB(database);
17+
const parsedOutlines = outlines
18+
.map((outline) => {
19+
const [number, ...title] = outline.Title.split(". ");
20+
return {
21+
number: parseInt(number?.trim() ?? "0"),
22+
title: title.join(". "),
23+
};
24+
})
25+
.filter((outline) => outline.number > 0);
3626

37-
const match =
38-
htmlOutlines.length === parsedOutlines.length &&
39-
htmlOutlines.every(
40-
(htmlOutline, index) =>
41-
htmlOutline.number === parsedOutlines[index]?.number &&
42-
htmlOutline.title === parsedOutlines[index]?.title,
43-
);
27+
const match =
28+
htmlOutlines.length === parsedOutlines.length &&
29+
htmlOutlines.every(
30+
(htmlOutline, index) =>
31+
htmlOutline.number === parsedOutlines[index]?.number &&
32+
htmlOutline.title === parsedOutlines[index]?.title,
33+
);
4434

45-
keepalive.progress("Outlines processed successfully");
46-
return match ? htmlOutlines : parsedOutlines;
47-
},
48-
"Processing JWPUB file upload...",
49-
);
35+
return match ? htmlOutlines : parsedOutlines;
5036
});

server/utils/keepalive.ts

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)