Skip to content

Commit 823a5a0

Browse files
committed
save path to db on endpoint update/ create
1 parent 9425fa7 commit 823a5a0

6 files changed

Lines changed: 14 additions & 4 deletions

File tree

packages/dashboard/src/app/(layout)/endpoints/new/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export default function AddApi() {
158158
regexPath: '^' + data.name.replace(/{[^}]+}/g, '([^/]+)') + '$',
159159
customHeadersEnabled: data.customHeadersEnabled,
160160
customHeaders: JSON.parse(data.customHeaders ?? ''),
161+
path: data.path,
161162
}
162163
)
163164
})

packages/dashboard/src/app/(layout)/services/[id]/endpoints/[endpointId]/components/SettingsTab.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function Settings({endpoint, service}: Props) {
4545
resolver: zodResolver(endpointSchema),
4646
defaultValues: {
4747
name: endpoint.name ?? "",
48-
path: endpoint.full_url.replace(service.base_url, ''),
48+
path: endpoint.path ?? "",
4949
method: endpoint.method as "GET" ?? "GET",
5050
caching: endpoint.cache_enabled ?? true,
5151
cache_ttl_s: (endpoint.cache_ttl_s ?? 60).toString(),
@@ -150,6 +150,7 @@ export default function Settings({endpoint, service}: Props) {
150150
userId: service.user_id,
151151
customHeadersEnabled: data.customHeadersEnabled,
152152
customHeaders: JSON.parse(data.customHeaders ?? ''),
153+
path: data.path,
153154
})
154155
})
155156
.then(response => response.json())

packages/dashboard/src/app/(layout)/services/import/parsePostman.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ function processItems(items: PostmanItem[], endpoints: Tables<'endpoints'>[], ba
514514
// Create the endpoint object
515515
const endpoint: Partial<Tables<'endpoints'>> = {
516516
name: path,
517+
path: path,
517518
method: method,
518519
full_url: full_url,
519520
regex_path: regex_path,

packages/dashboard/src/app/(layout)/services/import/parseSwagger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ function createEndpointsArray(swagger: SwaggerSchema, baseUrl: string): Tables<'
253253
// Create endpoint object
254254
const endpoint: Partial<Tables<'endpoints'>> = {
255255
name,
256+
path: path,
256257
method: method.toUpperCase(),
257258
full_url,
258259
regex_path,

packages/dashboard/src/app/api/endpoints/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export async function POST(req: any) {
3131
regex_path: '^' + data.name.replace(/{[^}]+}/g, '([^/]+)') + '$',
3232
custom_headers_enabled: data.customHeadersEnabled,
3333
custom_headers: data.customHeaders,
34+
path: data.path,
3435
})
3536
.select()
3637
.single();
@@ -76,6 +77,7 @@ export async function PUT(req: any) {
7677
regex_path: '^' + data.name.replace(/{[^}]+}/g, '([^/]+)') + '$',
7778
custom_headers_enabled: data.customHeadersEnabled,
7879
custom_headers: data.customHeaders,
80+
path: data.path,
7981
})
8082
.eq('id', endpointId);
8183

packages/dashboard/src/utils/supabase/database.types.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export type Database = {
5050
mock_response: Json | null
5151
mock_status_code: number | null
5252
name: string
53+
path: string | null
5354
regex_path: string | null
5455
retry_count: number
5556
retry_enabled: boolean
@@ -78,6 +79,7 @@ export type Database = {
7879
mock_response?: Json | null
7980
mock_status_code?: number | null
8081
name: string
82+
path?: string | null
8183
regex_path?: string | null
8284
retry_count?: number
8385
retry_enabled?: boolean
@@ -106,6 +108,7 @@ export type Database = {
106108
mock_response?: Json | null
107109
mock_status_code?: number | null
108110
name?: string
111+
path?: string | null
109112
regex_path?: string | null
110113
retry_count?: number
111114
retry_enabled?: boolean
@@ -316,21 +319,18 @@ export type Database = {
316319
billing_started_at: string
317320
calls_count: number
318321
id: number
319-
mcp_calls_count: number
320322
user_id: string
321323
}
322324
Insert: {
323325
billing_started_at?: string
324326
calls_count?: number
325327
id?: number
326-
mcp_calls_count?: number
327328
user_id: string
328329
}
329330
Update: {
330331
billing_started_at?: string
331332
calls_count?: number
332333
id?: number
333-
mcp_calls_count?: number
334334
user_id?: string
335335
}
336336
Relationships: []
@@ -363,6 +363,10 @@ export type Database = {
363363
c_count: number
364364
}[]
365365
}
366+
update_full_url: {
367+
Args: { p_service_id: number }
368+
Returns: undefined
369+
}
366370
}
367371
Enums: {
368372
[_ in never]: never

0 commit comments

Comments
 (0)