Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .codegraph/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CodeGraph data files — local to each machine, not for committing.
# Ignore everything in .codegraph/ except this file itself, so transient
# files (the database, daemon.pid, sockets, logs) never show up in git.
*
!.gitignore
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- run: npm ci

- name: Lint
run: npm run lint

- name: Type check + build
run: npm run build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ stats.html

#Ignore cursor AI rules
.cursor/rules/codacy.mdc

docs/
31 changes: 16 additions & 15 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,25 @@ app.post("/pdf", async (req, res) => {
return res.status(400).json({ message: "HTML content is required" });
}

try {
let browser;
let browser;

try {
if (process.env.NODE_ENV === "development") {
// Use standard Puppeteer locally
browser = await puppeteer.launch({
headless: true,
args: ["--no-sandbox", "--disable-setuid-sandbox"],
});
}

if (process.env.NODE_ENV === "production") {
// Use Puppeteer with Chromium in production
} else if (process.env.NODE_ENV === "production") {
browser = await puppeteerCore.launch({
args: Chromium.args,
defaultViewport: Chromium.defaultViewport,
executablePath: await Chromium.executablePath(),
headless: Chromium.headless,
});
} else {
return res.status(500).json({
message: "Server misconfigured: NODE_ENV is not set",
});
}

const page = await browser.newPage();
Expand All @@ -181,18 +181,19 @@ app.post("/pdf", async (req, res) => {
},
});

await browser.close();

// Puppeteer 23.x returns a Uint8Array from page.pdf(); Express's
// res.send() only recognizes Buffer instances, so wrap it explicitly
// and use res.end() to send raw bytes without body processing.
res.setHeader("Content-Type", "application/pdf");
res.end(Buffer.from(pdfBuffer));
} catch (error) {
console.error("PDF Generation error:", error);
res
.status(500)
.json({ message: "Internal server error: " + error.message });
res.status(500).json({ message: "Internal server error" });
} finally {
if (browser) {
try {
await browser.close();
} catch (closeError) {
console.error("Failed to close browser:", closeError);
}
}
}
});

Expand Down
10 changes: 10 additions & 0 deletions opencode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"context7": {
"type": "local",
"command": ["npx", "-y", "@upstash/context7-mcp"],
"enabled": true
}
}
}
Loading
Loading