Skip to content

Commit 2d1fd12

Browse files
authored
fix: pass in backfillRelatedEntities flag in sync routes (#94)
1 parent 13936f6 commit 2d1fd12

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/routes/sync.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ export default async function routes(fastify: FastifyInstance) {
99
fastify.post('/sync', {
1010
preHandler: [verifyApiKey],
1111
handler: async (request, reply) => {
12-
const { created, object } =
12+
const { created, object, backfillRelatedEntities } =
1313
(request.body as {
1414
created?: Stripe.RangeQueryParam
1515
object?: string
16+
backfillRelatedEntities?: boolean
1617
}) ?? {}
17-
const params = { created, object } as SyncBackfillParams
18+
const params = { created, object, backfillRelatedEntities } as SyncBackfillParams
1819
const result = await syncBackfill(params)
1920
return reply.send({
2021
statusCode: 200,

src/routes/sync/daily.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export default async function routes(fastify: FastifyInstance) {
77
fastify.post('/daily', {
88
preHandler: [verifyApiKey],
99
handler: async (request, reply) => {
10-
const { object } = (request.body as { object?: string }) ?? {}
10+
const { object, backfillRelatedEntities } =
11+
(request.body as { object?: string; backfillRelatedEntities?: boolean }) ?? {}
1112
const currentTimeInSeconds = Math.floor(Date.now() / 1000)
1213
const dayAgoTimeInSeconds = currentTimeInSeconds - 60 * 60 * 24
1314
const params = {
1415
created: { gte: dayAgoTimeInSeconds },
1516
object: object ?? 'all',
17+
backfillRelatedEntities,
1618
} as SyncBackfillParams
1719

1820
await syncBackfill(params)

src/routes/sync/monthly.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export default async function routes(fastify: FastifyInstance) {
77
fastify.post('/monthly', {
88
preHandler: [verifyApiKey],
99
handler: async (request, reply) => {
10-
const { object } = (request.body as { object?: string }) ?? {}
10+
const { object, backfillRelatedEntities } =
11+
(request.body as { object?: string; backfillRelatedEntities?: boolean }) ?? {}
1112
const currentTimeInSeconds = Math.floor(Date.now() / 1000)
1213
const monthAgoTimeInSeconds = currentTimeInSeconds - 60 * 60 * 24 * 30
1314
const params = {
1415
created: { gte: monthAgoTimeInSeconds },
1516
object: object ?? 'all',
17+
backfillRelatedEntities,
1618
} as SyncBackfillParams
1719

1820
const result = await syncBackfill(params)

src/routes/sync/weekly.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export default async function routes(fastify: FastifyInstance) {
77
fastify.post('/weekly', {
88
preHandler: [verifyApiKey],
99
handler: async (request, reply) => {
10-
const { object } = (request.body as { object?: string }) ?? {}
10+
const { object, backfillRelatedEntities } =
11+
(request.body as { object?: string; backfillRelatedEntities?: boolean }) ?? {}
1112
const currentTimeInSeconds = Math.floor(Date.now() / 1000)
1213
const weekAgoTimeInSeconds = currentTimeInSeconds - 60 * 60 * 24 * 7
1314
const params = {
1415
created: { gte: weekAgoTimeInSeconds },
1516
object: object ?? 'all',
17+
backfillRelatedEntities,
1618
} as SyncBackfillParams
1719

1820
const result = await syncBackfill(params)

0 commit comments

Comments
 (0)