Skip to content

Commit 8956604

Browse files
committed
more coderabbit
1 parent b56ab3f commit 8956604

File tree

7 files changed

+23
-28
lines changed

7 files changed

+23
-28
lines changed

apps/webapp/app/routes/api.v1.orgs.$orgParam.projects.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { prisma } from "~/db.server";
1010
import { createProject } from "~/models/project.server";
1111
import { logger } from "~/services/logger.server";
1212
import { authenticateApiRequestWithPersonalAccessToken } from "~/services/personalAccessToken.server";
13+
import { isCuid } from "cuid";
1314

1415
const ParamsSchema = z.object({
1516
orgParam: z.string(),
@@ -135,7 +136,3 @@ function orgParamWhereClause(orgParam: string) {
135136
slug: orgParam,
136137
};
137138
}
138-
139-
function isCuid(orgParam: string): boolean {
140-
return /^[0-9A-HJ-NP-TV-Z]{25}$/.test(orgParam);
141-
}

apps/webapp/app/routes/api.v1.projects.$projectRef.$env.jwt.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { json, type LoaderFunctionArgs } from "@remix-run/server-runtime";
1+
import { ActionFunctionArgs, json } from "@remix-run/node";
22
import { generateJWT as internal_generateJWT } from "@trigger.dev/core/v3";
33
import { z } from "zod";
44
import { prisma } from "~/db.server";
@@ -10,8 +10,6 @@ const ParamsSchema = z.object({
1010
env: z.enum(["dev", "staging", "prod", "preview"]),
1111
});
1212

13-
type ParamsSchema = z.infer<typeof ParamsSchema>;
14-
1513
const RequestBodySchema = z.object({
1614
claims: z
1715
.object({
@@ -21,7 +19,7 @@ const RequestBodySchema = z.object({
2119
expirationTime: z.union([z.number(), z.string()]).optional(),
2220
});
2321

24-
export async function action({ request, params }: LoaderFunctionArgs) {
22+
export async function action({ request, params }: ActionFunctionArgs) {
2523
const authenticationResult = await authenticateApiRequestWithPersonalAccessToken(request);
2624

2725
if (!authenticationResult) {

apps/webapp/app/routes/api.v1.runs.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export const loader = createLoaderApiRoute(
1818
},
1919
findResource: async () => 1, // This is a dummy function, we don't need to find a resource
2020
},
21-
async ({ searchParams, authentication, apiVersion, headers }) => {
22-
logger.info("api.v1.runs.loader", { searchParams, authentication, apiVersion, headers });
23-
21+
async ({ searchParams, authentication, apiVersion }) => {
2422
const presenter = new ApiRunListPresenter();
2523
const result = await presenter.call(
2624
authentication.environment.project,

apps/webapp/app/services/routeBuilders/apiBuilder.server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,14 @@ export function createActionApiRoute<
703703
? await options.findResource(parsedParams, authenticationResult, parsedSearchParams)
704704
: undefined;
705705

706+
if (options.findResource && !resource) {
707+
return await wrapResponse(
708+
request,
709+
json({ error: "Resource not found" }, { status: 404 }),
710+
corsStrategy !== "none"
711+
);
712+
}
713+
706714
const result = await handler({
707715
params: parsedParams,
708716
searchParams: parsedSearchParams,

packages/cli-v3/src/commands/mcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export async function mcpCommand(options: McpCommandOptions) {
7272
});
7373

7474
server.server.oninitialized = async () => {
75-
fileLogger?.log("initialized mcp command", { options, argv: process.argv, env: process.env });
75+
fileLogger?.log("initialized mcp command", { options, argv: process.argv });
7676
};
7777

7878
// Start receiving messages on stdin and sending messages on stdout

packages/cli-v3/src/mcp/context.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2-
import { FileLogger } from "./logger.js";
3-
import { createApiClientWithPublicJWT, mcpAuth } from "./auth.js";
2+
import { tryCatch } from "@trigger.dev/core/utils";
3+
import { ApiClient } from "@trigger.dev/core/v3";
4+
import path from "node:path";
45
import { CliApiClient } from "../apiClient.js";
6+
import { loadConfig } from "../config.js";
7+
import { mcpAuth } from "./auth.js";
58
import {
69
hasElicitationCapability,
710
hasRootsCapability,
811
hasSamplingCapability,
912
} from "./capabilities.js";
10-
import path from "node:path";
11-
import { tryCatch } from "@trigger.dev/core/utils";
12-
import { loadConfig } from "../config.js";
13-
import { ApiClient } from "@trigger.dev/core/v3";
13+
import { FileLogger } from "./logger.js";
14+
import { fileURLToPath } from "node:url";
1415

1516
export type McpContextOptions = {
1617
projectRef?: string;
@@ -85,7 +86,7 @@ export class McpContext {
8586
const response = await this.server.server.listRoots();
8687

8788
if (response.roots.length >= 1) {
88-
return response.roots[0]?.uri ? fileUriToPath(response.roots[0].uri) : undefined;
89+
return response.roots[0]?.uri ? fileURLToPath(response.roots[0].uri) : undefined;
8990
}
9091

9192
return undefined;
@@ -184,7 +185,3 @@ export class McpContext {
184185
return hasElicitationCapability(this.server);
185186
}
186187
}
187-
188-
function fileUriToPath(uri: string) {
189-
return uri.replace("file://", "");
190-
}

packages/cli-v3/src/mcp/tools/deploys.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { x } from "tinyexec";
77
import { getPackageJson, tryResolveTriggerPackageVersion } from "../../commands/update.js";
88
import { VERSION } from "../../version.js";
99
import { resolveSync as esmResolve } from "mlly";
10+
import { fileURLToPath } from "node:url";
1011

1112
export const deployTool = {
1213
name: toolsMetadata.deploy.name,
@@ -171,7 +172,7 @@ async function tryResolveTriggerCLIPath(
171172
url: basedir,
172173
});
173174

174-
const resolvedPath = fileUriToPath(resolvedPathFileURI);
175+
const resolvedPath = fileURLToPath(resolvedPathFileURI);
175176

176177
context.logger?.log("resolve_cli_exec resolvedPathFileURI", { resolvedPathFileURI });
177178

@@ -202,7 +203,3 @@ async function tryResolveTriggerCLIPath(
202203
return undefined;
203204
}
204205
}
205-
206-
function fileUriToPath(uri: string) {
207-
return uri.replace("file://", "");
208-
}

0 commit comments

Comments
 (0)