Skip to content

Commit a27a50e

Browse files
committed
move post agent runs into app/
1 parent 8f1ad57 commit a27a50e

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

web/src/api/v1/__tests__/agent-runs.test.ts renamed to web/src/app/api/v1/agent-runs/__tests__/agent-runs.test.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test'
2-
import { NextRequest } from 'next/server'
3-
41
import { AnalyticsEvent } from '@codebuff/common/constants/analytics-events'
52
import { TEST_USER_ID } from '@codebuff/common/old-constants'
3+
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test'
4+
import { NextRequest } from 'next/server'
65

7-
import { agentRunsPost } from '../agent-runs'
6+
import { postAgentRuns } from '../_post'
87

98
import type { TrackEventFn } from '@codebuff/common/types/contracts/analytics'
109
import type {
@@ -79,7 +78,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
7978
}),
8079
})
8180

82-
const response = await agentRunsPost({
81+
const response = await postAgentRuns({
8382
req,
8483
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
8584
logger: mockLogger,
@@ -102,7 +101,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
102101
}),
103102
})
104103

105-
const response = await agentRunsPost({
104+
const response = await postAgentRuns({
106105
req,
107106
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
108107
logger: mockLogger,
@@ -125,7 +124,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
125124
}),
126125
})
127126

128-
const response = await agentRunsPost({
127+
const response = await postAgentRuns({
129128
req,
130129
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
131130
logger: mockLogger,
@@ -147,7 +146,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
147146
}),
148147
})
149148

150-
const response = await agentRunsPost({
149+
const response = await postAgentRuns({
151150
req,
152151
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
153152
logger: mockLogger,
@@ -169,7 +168,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
169168
}),
170169
})
171170

172-
const response = await agentRunsPost({
171+
const response = await postAgentRuns({
173172
req,
174173
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
175174
logger: mockLogger,
@@ -191,7 +190,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
191190
body: 'not json',
192191
})
193192

194-
const response = await agentRunsPost({
193+
const response = await postAgentRuns({
195194
req,
196195
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
197196
logger: mockLogger,
@@ -213,7 +212,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
213212
}),
214213
})
215214

216-
const response = await agentRunsPost({
215+
const response = await postAgentRuns({
217216
req,
218217
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
219218
logger: mockLogger,
@@ -236,7 +235,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
236235
}),
237236
})
238237

239-
const response = await agentRunsPost({
238+
const response = await postAgentRuns({
240239
req,
241240
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
242241
logger: mockLogger,
@@ -260,7 +259,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
260259
}),
261260
})
262261

263-
const response = await agentRunsPost({
262+
const response = await postAgentRuns({
264263
req,
265264
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
266265
logger: mockLogger,
@@ -283,7 +282,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
283282
}),
284283
})
285284

286-
const response = await agentRunsPost({
285+
const response = await postAgentRuns({
287286
req,
288287
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
289288
logger: mockLogger,
@@ -321,7 +320,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
321320
}),
322321
})
323322

324-
const response = await agentRunsPost({
323+
const response = await postAgentRuns({
325324
req,
326325
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
327326
logger: mockLogger,
@@ -355,7 +354,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
355354
}),
356355
})
357356

358-
const response = await agentRunsPost({
357+
const response = await postAgentRuns({
359358
req,
360359
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
361360
logger: mockLogger,
@@ -391,7 +390,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
391390
}),
392391
})
393392

394-
const response = await agentRunsPost({
393+
const response = await postAgentRuns({
395394
req,
396395
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
397396
logger: mockLogger,
@@ -428,7 +427,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
428427
}),
429428
})
430429

431-
const response = await agentRunsPost({
430+
const response = await postAgentRuns({
432431
req,
433432
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
434433
logger: mockLogger,
@@ -455,7 +454,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
455454
}),
456455
})
457456

458-
const response = await agentRunsPost({
457+
const response = await postAgentRuns({
459458
req,
460459
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
461460
logger: mockLogger,
@@ -482,7 +481,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
482481
}),
483482
})
484483

485-
const response = await agentRunsPost({
484+
const response = await postAgentRuns({
486485
req,
487486
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
488487
logger: mockLogger,
@@ -509,7 +508,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
509508
}),
510509
})
511510

512-
const response = await agentRunsPost({
511+
const response = await postAgentRuns({
513512
req,
514513
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
515514
logger: mockLogger,
@@ -536,7 +535,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
536535
}),
537536
})
538537

539-
const response = await agentRunsPost({
538+
const response = await postAgentRuns({
540539
req,
541540
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
542541
logger: mockLogger,
@@ -579,7 +578,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
579578
}),
580579
})
581580

582-
const response = await agentRunsPost({
581+
const response = await postAgentRuns({
583582
req,
584583
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
585584
logger: mockLogger,
@@ -620,7 +619,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
620619
}),
621620
})
622621

623-
const response = await agentRunsPost({
622+
const response = await postAgentRuns({
624623
req,
625624
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
626625
logger: mockLogger,
@@ -661,7 +660,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
661660
}),
662661
})
663662

664-
const response = await agentRunsPost({
663+
const response = await postAgentRuns({
665664
req,
666665
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
667666
logger: mockLogger,
@@ -695,7 +694,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
695694
}),
696695
})
697696

698-
const response = await agentRunsPost({
697+
const response = await postAgentRuns({
699698
req,
700699
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
701700
logger: mockLogger,
@@ -733,7 +732,7 @@ describe('/api/v1/agent-runs POST endpoint', () => {
733732
}),
734733
})
735734

736-
const response = await agentRunsPost({
735+
const response = await postAgentRuns({
737736
req,
738737
getUserInfoFromApiKey: mockGetUserInfoFromApiKey,
739738
logger: mockLogger,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async function handleFinishAction(params: {
165165
}
166166
}
167167

168-
export async function agentRunsPost(params: {
168+
export async function postAgentRuns(params: {
169169
req: NextRequest
170170
getUserInfoFromApiKey: GetUserInfoFromApiKeyFn
171171
logger: Logger
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { trackEvent } from '@codebuff/common/analytics'
22
import db from '@codebuff/internal/db'
33

4+
import { postAgentRuns } from './_post'
5+
46
import type { NextRequest } from 'next/server'
57

6-
import { agentRunsPost } from '@/api/v1/agent-runs'
78
import { getUserInfoFromApiKey } from '@/db/user'
89
import { logger } from '@/util/logger'
910

1011
export async function POST(req: NextRequest) {
11-
return agentRunsPost({ req, getUserInfoFromApiKey, logger, trackEvent, db })
12+
return postAgentRuns({ req, getUserInfoFromApiKey, logger, trackEvent, db })
1213
}

0 commit comments

Comments
 (0)