stripe-experiment-sync 0.0.3 → 0.0.5

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.
package/dist/index.cjs CHANGED
@@ -958,12 +958,12 @@ var StripeAutoSync = class {
958
958
  );
959
959
  this.webhookId = webhook.id;
960
960
  this.webhookUuid = uuid;
961
+ app.use(this.getBodyParserMiddleware());
962
+ this.mountWebhook(app);
961
963
  console.log("Starting initial backfill of all Stripe data...");
962
964
  const backfillResult = await this.stripeSync.syncBackfill({ object: "all" });
963
965
  const totalSynced = Object.values(backfillResult).reduce((sum, result) => sum + (result?.synced || 0), 0);
964
966
  console.log(`\u2713 Backfill complete: ${totalSynced} objects synced`);
965
- this.mountWebhook(app);
966
- app.use(this.getBodyParserMiddleware());
967
967
  return {
968
968
  baseUrl,
969
969
  webhookUrl: webhook.url,
@@ -1003,7 +1003,9 @@ var StripeAutoSync = class {
1003
1003
  getBodyParserMiddleware() {
1004
1004
  const webhookPath = this.options.webhookPath;
1005
1005
  return (req, res, next) => {
1006
- if (req.path.startsWith(webhookPath)) {
1006
+ const path2 = req.path || req.url || "";
1007
+ if (path2.startsWith(webhookPath)) {
1008
+ console.log("[BodyParser] Skipping webhook route:", path2);
1007
1009
  return next();
1008
1010
  }
1009
1011
  import_express.default.json()(req, res, (err) => {
@@ -1021,6 +1023,12 @@ var StripeAutoSync = class {
1021
1023
  const webhookRoute = `${this.options.webhookPath}/:uuid`;
1022
1024
  app.use(webhookRoute, import_express.default.raw({ type: "application/json" }));
1023
1025
  app.post(webhookRoute, async (req, res) => {
1026
+ console.log("[Webhook] Received request:", {
1027
+ path: req.path,
1028
+ url: req.url,
1029
+ method: req.method,
1030
+ contentType: req.headers["content-type"]
1031
+ });
1024
1032
  const sig = req.headers["stripe-signature"];
1025
1033
  if (!sig || typeof sig !== "string") {
1026
1034
  console.error("[Webhook] Missing stripe-signature header");
@@ -1033,7 +1041,9 @@ var StripeAutoSync = class {
1033
1041
  hasBody: !!rawBody,
1034
1042
  bodyType: typeof rawBody,
1035
1043
  isBuffer: Buffer.isBuffer(rawBody),
1036
- bodyConstructor: rawBody?.constructor?.name
1044
+ bodyConstructor: rawBody?.constructor?.name,
1045
+ path: req.path,
1046
+ url: req.url
1037
1047
  });
1038
1048
  return res.status(400).send({ error: "Missing raw body for signature verification" });
1039
1049
  }
package/dist/index.js CHANGED
@@ -916,12 +916,12 @@ var StripeAutoSync = class {
916
916
  );
917
917
  this.webhookId = webhook.id;
918
918
  this.webhookUuid = uuid;
919
+ app.use(this.getBodyParserMiddleware());
920
+ this.mountWebhook(app);
919
921
  console.log("Starting initial backfill of all Stripe data...");
920
922
  const backfillResult = await this.stripeSync.syncBackfill({ object: "all" });
921
923
  const totalSynced = Object.values(backfillResult).reduce((sum, result) => sum + (result?.synced || 0), 0);
922
924
  console.log(`\u2713 Backfill complete: ${totalSynced} objects synced`);
923
- this.mountWebhook(app);
924
- app.use(this.getBodyParserMiddleware());
925
925
  return {
926
926
  baseUrl,
927
927
  webhookUrl: webhook.url,
@@ -961,7 +961,9 @@ var StripeAutoSync = class {
961
961
  getBodyParserMiddleware() {
962
962
  const webhookPath = this.options.webhookPath;
963
963
  return (req, res, next) => {
964
- if (req.path.startsWith(webhookPath)) {
964
+ const path2 = req.path || req.url || "";
965
+ if (path2.startsWith(webhookPath)) {
966
+ console.log("[BodyParser] Skipping webhook route:", path2);
965
967
  return next();
966
968
  }
967
969
  express.json()(req, res, (err) => {
@@ -979,6 +981,12 @@ var StripeAutoSync = class {
979
981
  const webhookRoute = `${this.options.webhookPath}/:uuid`;
980
982
  app.use(webhookRoute, express.raw({ type: "application/json" }));
981
983
  app.post(webhookRoute, async (req, res) => {
984
+ console.log("[Webhook] Received request:", {
985
+ path: req.path,
986
+ url: req.url,
987
+ method: req.method,
988
+ contentType: req.headers["content-type"]
989
+ });
982
990
  const sig = req.headers["stripe-signature"];
983
991
  if (!sig || typeof sig !== "string") {
984
992
  console.error("[Webhook] Missing stripe-signature header");
@@ -991,7 +999,9 @@ var StripeAutoSync = class {
991
999
  hasBody: !!rawBody,
992
1000
  bodyType: typeof rawBody,
993
1001
  isBuffer: Buffer.isBuffer(rawBody),
994
- bodyConstructor: rawBody?.constructor?.name
1002
+ bodyConstructor: rawBody?.constructor?.name,
1003
+ path: req.path,
1004
+ url: req.url
995
1005
  });
996
1006
  return res.status(400).send({ error: "Missing raw body for signature verification" });
997
1007
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stripe-experiment-sync",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "private": false,
5
5
  "description": "Stripe Sync Engine to sync Stripe data based on webhooks to Postgres",
6
6
  "type": "module",