-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (21 loc) · 817 Bytes
/
server.js
File metadata and controls
27 lines (21 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import express from "express";
import { fillPdf } from "./core_utils.js";
const app = express();
app.use(express.json({ limit: "10mb" }));
app.post("/fill", async (req, res) => {
try {
const { data = {}, fieldsOverride = null } = req.body;
const out = await fillPdf({ data, fieldsOverride });
res.setHeader("Content-Type", "application/pdf");
res.setHeader("Content-Disposition", 'attachment; filename="filled.pdf"');
return res.send(out);
} catch (err) {
console.error("에러 발생:", err);
return res.status(500).json({ error: "PDF 생성 실패", detail: String(err) });
}
});
app.get("/health", (_, res) => res.json({ ok: true }));
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`PDF fill server listening on http://localhost:${PORT}`);
});