(body: CaptureRequest)
| 428 | } |
| 429 | |
| 430 | function createHttpCapture(body: CaptureRequest): CaptureResponse { |
| 431 | const storage = useHttpStorage() |
| 432 | const folderId = body.folderId ?? null |
| 433 | const siblings = storage.requests.getRequests({ |
| 434 | isDeleted: 0, |
| 435 | ...(folderId === null ? { isInbox: 1 } : { folderId }), |
| 436 | }) |
| 437 | const url = trimToValue(body.url) ?? trimToValue(body.source?.url) ?? '' |
| 438 | const name = getUniqueName( |
| 439 | resolveCaptureName(body, 'Captured request'), |
| 440 | siblings.map(item => item.name), |
| 441 | ) |
| 442 | const { id } = storage.requests.createRequest({ |
| 443 | folderId, |
| 444 | method: body.method ?? 'GET', |
| 445 | name, |
| 446 | url, |
| 447 | }) |
| 448 | |
| 449 | const description = createSourceDescription(body) |
| 450 | if (description) { |
| 451 | storage.requests.updateRequest(id, { description }) |
| 452 | } |
| 453 | |
| 454 | return { id, target: 'http' } |
| 455 | } |
| 456 | |
| 457 | app.use(capturesDTO).post( |
| 458 | '/', |
no test coverage detected