Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
feat: Rename header to x-customer-id
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyxiao committed Feb 7, 2024
1 parent 98bc126 commit 3d0e85f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions main/scripts/test-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {initBYOSupaglueSDK} from '@supaglue/sdk'

const supaglue = initBYOSupaglueSDK({
headers: {
'x-connection-id': 'outreach1',
'x-customer-id': 'outreach1',
'x-provider-name': 'outreach',
// 'x-connection-id': 'test-connection-id',
// 'x-customer-id': 'test-connection-id',
// 'x-provider-name': 'salesforce',
},
})
Expand Down Expand Up @@ -53,7 +53,7 @@ main()

// const supaglue = initBYOSupaglueSDK({
// headers: {
// 'x-connection-id': 'hubspot1',
// 'x-customer-id': 'hubspot1',
// 'x-provider-name': 'hubspot',
// },
// })
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type BYOSupaglueSDKTypes = SDKTypes<
oasTypes,
Omit<ClientOptions, 'headers'> & {
headers: {
'x-connection-id': string
'x-customer-id': string
'x-provider-name': string
[k: string]: string
}
Expand Down
17 changes: 12 additions & 5 deletions packages/vdk/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export const publicProcedure = trpc.procedure

export const remoteProcedure = publicProcedure.use(
async ({next, ctx, path}) => {
const connectionId = ctx.headers.get('x-connection-id')
if (!connectionId) {
const customerId = ctx.headers.get('x-customer-id')
if (!customerId) {
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'x-connection-id header is required',
message: 'x-customer-id header is required',
})
}
const providerName = ctx.headers.get('x-provider-name')
Expand All @@ -47,13 +47,20 @@ export const remoteProcedure = publicProcedure.use(

const nangoLink = nangoProxyLink({
secretKey: ctx.nangoSecretKey,
connectionId,
connectionId: ctx.headers.get('x-connection-id') ?? customerId,
providerConfigKey:
ctx.headers.get('x-provider-config-key') ?? providerName,
})

return next({
ctx: {...ctx, path, connectionId, providerName, provider, nangoLink},
ctx: {
...ctx,
path,
connectionId: customerId,
providerName,
provider,
nangoLink,
},
})
},
)
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/routines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function syncConnection({

const supaglue = initBYOSupaglueSDK({
headers: {
'x-connection-id': connection_id,
'x-customer-id': connection_id,
'x-provider-name': provider_config_key,
},
})
Expand Down

0 comments on commit 3d0e85f

Please sign in to comment.