Add Stripe billing integration + update free tier to 100 PDFs/mo
This commit is contained in:
parent
facb8df8f4
commit
c12c1176b0
7 changed files with 238 additions and 12 deletions
|
|
@ -10,11 +10,14 @@ import { authMiddleware } from "./middleware/auth.js";
|
|||
import { usageMiddleware } from "./middleware/usage.js";
|
||||
import { getUsageStats } from "./middleware/usage.js";
|
||||
import { initBrowser, closeBrowser } from "./services/browser.js";
|
||||
import { billingRouter } from "./routes/billing.js";
|
||||
|
||||
const app = express();
|
||||
const PORT = parseInt(process.env.PORT || "3100", 10);
|
||||
|
||||
app.use(helmet());
|
||||
// Raw body for Stripe webhook signature verification
|
||||
app.use("/v1/billing/webhook", express.raw({ type: "application/json" }));
|
||||
app.use(express.json({ limit: "2mb" }));
|
||||
app.use(express.text({ limit: "2mb", type: "text/*" }));
|
||||
|
||||
|
|
@ -34,6 +37,9 @@ app.use("/health", healthRouter);
|
|||
app.use("/v1/convert", authMiddleware, usageMiddleware, convertRouter);
|
||||
app.use("/v1/templates", authMiddleware, usageMiddleware, templatesRouter);
|
||||
|
||||
// Billing (public — Stripe handles auth)
|
||||
app.use("/v1/billing", billingRouter);
|
||||
|
||||
// Admin: usage stats (protected by auth)
|
||||
app.get("/v1/usage", authMiddleware, (_req, res) => {
|
||||
res.json(getUsageStats());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue