Skip to content

Commit 3a403f6

Browse files
authored
Merge pull request #142 from Recoupable-com/composio-tool-router
feat: Composio Tool Router integration with Google Sheets
2 parents fb8b7a9 + 7590c3a commit 3a403f6

File tree

16 files changed

+57
-628
lines changed

16 files changed

+57
-628
lines changed

app/api/connectedAccounts/refresh/route.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

app/api/connectors/authorize/route.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { NextRequest } from "next/server";
22
import { NextResponse } from "next/server";
33
import { getCorsHeaders } from "@/lib/networking/getCorsHeaders";
44
import { authorizeConnector } from "@/lib/composio/connectors";
5-
import { getApiKeyAccountId } from "@/lib/auth/getApiKeyAccountId";
5+
import { validateAccountIdHeaders } from "@/lib/accounts/validateAccountIdHeaders";
66
import { validateAuthorizeConnectorBody } from "@/lib/composio/connectors/validateAuthorizeConnectorBody";
77

88
/**
@@ -20,8 +20,8 @@ export async function OPTIONS() {
2020
*
2121
* Generate an OAuth authorization URL for a specific connector.
2222
*
23-
* Authentication: x-api-key header required.
24-
* The account ID is inferred from the API key.
23+
* Authentication: x-api-key OR Authorization Bearer token required.
24+
* The account ID is inferred from the auth header.
2525
*
2626
* Request body:
2727
* - connector: The connector slug, e.g., "googlesheets" (required)
@@ -33,12 +33,12 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
3333
const headers = getCorsHeaders();
3434

3535
try {
36-
const accountIdOrError = await getApiKeyAccountId(request);
37-
if (accountIdOrError instanceof NextResponse) {
38-
return accountIdOrError;
36+
const authResult = await validateAccountIdHeaders(request);
37+
if (authResult instanceof NextResponse) {
38+
return authResult;
3939
}
4040

41-
const accountId = accountIdOrError;
41+
const { accountId } = authResult;
4242
const body = await request.json();
4343

4444
const validated = validateAuthorizeConnectorBody(body);

app/api/connectors/route.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getConnectors } from "@/lib/composio/connectors";
55
import { disconnectConnector } from "@/lib/composio/connectors/disconnectConnector";
66
import { validateDisconnectConnectorBody } from "@/lib/composio/connectors/validateDisconnectConnectorBody";
77
import { verifyConnectorOwnership } from "@/lib/composio/connectors/verifyConnectorOwnership";
8-
import { getApiKeyAccountId } from "@/lib/auth/getApiKeyAccountId";
8+
import { validateAccountIdHeaders } from "@/lib/accounts/validateAccountIdHeaders";
99

1010
/**
1111
* OPTIONS handler for CORS preflight requests.
@@ -22,20 +22,20 @@ export async function OPTIONS() {
2222
*
2323
* List all available connectors and their connection status for a user.
2424
*
25-
* Authentication: x-api-key header required.
25+
* Authentication: x-api-key OR Authorization Bearer token required.
2626
*
2727
* @returns List of connectors with connection status
2828
*/
2929
export async function GET(request: NextRequest): Promise<NextResponse> {
3030
const headers = getCorsHeaders();
3131

3232
try {
33-
const accountIdOrError = await getApiKeyAccountId(request);
34-
if (accountIdOrError instanceof NextResponse) {
35-
return accountIdOrError;
33+
const authResult = await validateAccountIdHeaders(request);
34+
if (authResult instanceof NextResponse) {
35+
return authResult;
3636
}
3737

38-
const accountId = accountIdOrError;
38+
const { accountId } = authResult;
3939

4040
const connectors = await getConnectors(accountId);
4141

@@ -60,20 +60,20 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
6060
*
6161
* Disconnect a connected account from Composio.
6262
*
63-
* Authentication: x-api-key header required.
63+
* Authentication: x-api-key OR Authorization Bearer token required.
6464
*
6565
* Body: { connected_account_id: string }
6666
*/
6767
export async function DELETE(request: NextRequest): Promise<NextResponse> {
6868
const headers = getCorsHeaders();
6969

7070
try {
71-
const accountIdOrError = await getApiKeyAccountId(request);
72-
if (accountIdOrError instanceof NextResponse) {
73-
return accountIdOrError;
71+
const authResult = await validateAccountIdHeaders(request);
72+
if (authResult instanceof NextResponse) {
73+
return authResult;
7474
}
7575

76-
const accountId = accountIdOrError;
76+
const { accountId } = authResult;
7777
const body = await request.json();
7878

7979
const validated = validateDisconnectConnectorBody(body);

lib/agents/googleSheetsAgent/__tests__/getGoogleSheetsTools.test.ts

Lines changed: 0 additions & 238 deletions
This file was deleted.

0 commit comments

Comments
 (0)