@contentgrowth/content-emailing 0.7.7 → 0.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1423,7 +1423,7 @@ function createSettingsRoutes(config = {}) {
1423
1423
 
1424
1424
  // src/backend/routes/templates.js
1425
1425
  import { Hono as Hono2 } from "hono";
1426
- function createTemplateRoutes2(config = {}) {
1426
+ function createTemplateRoutes(config = {}) {
1427
1427
  const app = new Hono2();
1428
1428
  app.get("/", async (c) => {
1429
1429
  const emailService = new EmailService(c.env, config);
@@ -1680,6 +1680,36 @@ function createTrackingRoutes(env, config = {}) {
1680
1680
 
1681
1681
  // src/backend/routes/logs.js
1682
1682
  import { Hono as Hono4 } from "hono";
1683
+ function createLogRoutes(config = {}) {
1684
+ const app = new Hono4();
1685
+ app.get("/", async (c) => {
1686
+ const limit = Math.min(parseInt(c.req.query("limit") || "50"), 100);
1687
+ const offset = parseInt(c.req.query("offset") || "0");
1688
+ const env = c.env;
1689
+ try {
1690
+ const table = `${config.emailTablePrefix || "system_email_"}logs`;
1691
+ const { results } = await env.DB.prepare(`
1692
+ SELECT * FROM ${table}
1693
+ ORDER BY created_at DESC
1694
+ LIMIT ? OFFSET ?
1695
+ `).bind(limit, offset).all();
1696
+ const countResult = await env.DB.prepare(`SELECT COUNT(*) as exact_count FROM ${table}`).first();
1697
+ return c.json({
1698
+ logs: results.map((row) => ({
1699
+ ...row,
1700
+ metadata: row.metadata ? JSON.parse(row.metadata) : null
1701
+ })),
1702
+ total: countResult.exact_count,
1703
+ limit,
1704
+ offset
1705
+ });
1706
+ } catch (error) {
1707
+ console.error("Failed to fetch logs:", error);
1708
+ return c.json({ error: "Failed to fetch logs" }, 500);
1709
+ }
1710
+ });
1711
+ return app;
1712
+ }
1683
1713
 
1684
1714
  // src/backend/routes/index.js
1685
1715
  function createEmailRoutes(config = {}, cacheProvider = null) {
@@ -1760,7 +1790,7 @@ export {
1760
1790
  createDOCacheProvider,
1761
1791
  createEmailLoggerCallback,
1762
1792
  createEmailRoutes,
1763
- createTemplateRoutes2 as createTemplateRoutes,
1793
+ createTemplateRoutes,
1764
1794
  createTrackingRoutes,
1765
1795
  encodeTrackingLinks,
1766
1796
  extractVariables,