mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-01 00:24:08 +00:00
* feat: bru.sendRequest api * updated the postman-translations logic to handle `pm.sendRequest` to `bru.sendRequest` translations, and added unit tests * ~ removed `maxRedirects` and `proxy` values for sendRequest axios-instance ~ fixed the imports for the `send-request-transformer` function ~ `sendRequest` and `runRequest` will return same response object in both safe and developer mode ~ sendRequest function optimization * revert sendRequest to async function, added a testcase for sendRequest with url string * sendRequest callback errors handling * updated tests and added await for the callbacks --------- Co-authored-by: lohit <lohit@usebruno.com>
bruno-converters
The converters package is responsible for converting collections from one format to a Bruno collection. It can be used as a standalone package or as a part of the Bruno framework.
Installation
npm install @usebruno/converters
Usage
Convert Postman collection to Bruno collection
const { postmanToBruno } = require('@usebruno/converters');
// Convert Postman collection to Bruno collection
const brunoCollection = postmanToBruno(postmanCollection);
Convert Postman Environment to Bruno Environment
const { postmanToBrunoEnvironment } = require('@usebruno/converters');
const brunoEnvironment = postmanToBrunoEnvironment(postmanEnvironment);
Convert Insomnia collection to Bruno collection
import { insomniaToBruno } from '@usebruno/converters';
const brunoCollection = insomniaToBruno(insomniaCollection);
Convert OpenAPI specification to Bruno collection
import { openApiToBruno } from '@usebruno/converters';
const brunoCollection = openApiToBruno(openApiSpecification);
Example
const { postmanToBruno } = require('@usebruno/converters');
const fs = require('fs/promises');
const path = require('path');
async function convertPostmanToBruno(inputFile, outputFile) {
try {
// Read Postman collection file
const inputData = await fs.readFile(inputFile, 'utf8');
// Convert to Bruno collection
const brunoCollection = postmanToBruno(JSON.parse(inputData));
// Save Bruno collection
await fs.writeFile(outputFile, JSON.stringify(brunoCollection, null, 2));
console.log('Conversion successful!');
} catch (error) {
console.error('Error during conversion:', error);
}
}
// Usage
const inputFilePath = path.resolve(__dirname, 'demo_collection.postman_collection.json');
const outputFilePath = path.resolve(__dirname, 'bruno-collection.json');
convertPostmanToBruno(inputFilePath, outputFilePath);