GithubHelp home page GithubHelp logo

Comments (5)

helloanoop avatar helloanoop commented on June 15, 2024 2

@DivyMohan14 Thanks for taking time and making async scripting work !

from bruno.

helloanoop avatar helloanoop commented on June 15, 2024 1

Hi @DivyMohan14 !

Glad that you like Bruno!
Also, nice to see that you are checking out the external libraries feature.
It's one of the features that makes us unique to other similar tools out there.

The reason for using sandbox is from a security standpoint, the goal being yours script should not access filesystem unless you provide explicit access. This is to protect from any malicious 3rd party libs that might try to access stuff using fs module

The long term plan is to give more flexibility for the user to turn off the sandbox, via a ui toggle in the app OR allow to override it using a property in bruno.json at the collection level

For the short term, I feel we can give access to some core nodejs modules inside the sandbox by default.
I am thinking of opening up access to stream, path, url, util modules

Can you take this up @DivyMohan14 and raise a PR ?
You can import the 4 core node modules here and inject them into the sandbox here

There is a problem that you might run into. The pre-request script works fine with synchronous code, but I don't think it yet handles asynchronous code like fetch. Please let me know how it goes?

from bruno.

helloanoop avatar helloanoop commented on June 15, 2024 1

I spent some time on this today.

Added some node core modules to the sandbox. I also plan to expose node-fetch and axios out of the box as this is a very common use case for people to hit a http endpoint pre/post request.

Here is the PR that is tracking this work: https://github.com/usebruno/bruno/pull/139/files

Currently struggling with making async await work in NodeVM
Raised a github issue here: patriksimek/vm2#513

from bruno.

DivyMohan14 avatar DivyMohan14 commented on June 15, 2024 1

Yeah was working on this as well, same thing NodeVM is not waiting for the async function to finish implementation as you already pointed out.

So I thought if this is not fully supported will shift to some sync request libraries like sync-request
This internally uses child_process to spawn a new worker thread and then process the request. Will be trying to set this up and see if I can make this work.

from bruno.

karl-gustav avatar karl-gustav commented on June 15, 2024

@DivyMohan14 Would you mind posting your resulting access-token pre-request script here for posterity?

from bruno.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.