postman-code-generators icon indicating copy to clipboard operation
postman-code-generators copied to clipboard

Added Node-Js SuperAgent Code Generator

Open ajwad-shaikh opened this issue 5 years ago • 8 comments

What it does? Fixes (https://github.com/postmanlabs/postman-app-support/issues/6331) Adds support for Node-Js SuperAgent CodeGenerator in the project.

What changes you made? There are no changes to the core structure of the project. I have only added one more codegen directory. The README is updated to include the NodeJs-SuperAgent Support. Other than that there are no changes to any file outside the codegen/nodejs-superagent directory.

Would appreciate a review by the maintainers, @umeshp7 @shreys7

Let me know if I've missed anything.

ajwad-shaikh avatar Apr 02 '20 15:04 ajwad-shaikh

Any updates on this? @umeshp7 @shreys7

Would appreciate a review 😊

ajwad-shaikh avatar Apr 11 '20 13:04 ajwad-shaikh

Hey @ajwad-shaikh , could you post some example snippets generated for a GET and POST request?

shreys7 avatar Apr 16 '20 06:04 shreys7

Sure @shreys7! I have compiled a few results that the generator returns for the newman tests

  • Request Headers
var superagent = require('superagent');

superagent
  .get('https://postman-echo.com/headers')
  .set({
    'my-sample-header': 'Lorem ipsum dolor sit amet',
    'testing': '\'singlequotes\'',
    'TEST': '"doublequotes"',
    'Content-Type': 'text/plain'
  })
  .end(function (error, response) {
    if (error) throw new Error(error);
    console.log(JSON.stringify(response.body));
  });
  • POST json with raw
var superagent = require('superagent');

superagent
  .post('https://postman-echo.com/post')
  .set({
    'Content-Type': 'application/json'
  })
  .send(JSON.stringify({"json":"Test-Test"}))
  .end(function (error, response) {
    if (error) throw new Error(error);
    console.log(JSON.stringify(response.body));
  });
  • PUT Request
var superagent = require('superagent');

superagent
  .put('https://postman-echo.com/put')
  .set({
    'Content-Type': 'text/plain'
  })
  .send("Etiam mi lacus, cursus vitae felis et, blandit pellentesque neque. Vestibulum eget nisi a tortor commodo dignissim.\nQuisque ipsum ligula, faucibus a felis a, commodo elementum nisl. Mauris vulputate sapien et tincidunt viverra. Donec vitae velit nec metus.")
  .end(function (error, response) {
    if (error) throw new Error(error);
    console.log(JSON.stringify(response.body));
  });
  • PATCH Request
var superagent = require('superagent');

superagent
  .patch('https://postman-echo.com/patch')
  .set({
    'Content-Type': 'text/plain'
  })
  .send("Curabitur auctor, elit nec pulvinar porttitor, ex augue condimentum enim, eget suscipit urna felis quis neque.\nSuspendisse sit amet luctus massa, nec venenatis mi. Suspendisse tincidunt massa at nibh efficitur fringilla. Nam quis congue mi. Etiam volutpat.")
  .end(function (error, response) {
    if (error) throw new Error(error);
    console.log(JSON.stringify(response.body));
  });
  • DELETE Request
var superagent = require('superagent');

superagent
  .delete('https://postman-echo.com/delete')
  .set({
    'Content-Type': 'text/plain'
  })
  .end(function (error, response) {
    if (error) throw new Error(error);
    console.log(JSON.stringify(response.body));
  });
  • POST raw Request (ES6)
const superagent = require('superagent');

superagent
  .post('https://postman-echo.com/post')
  .set({
    'Content-Type': 'text/plain'
  })
  .send("Duis posuere augue vel cursus pharetra. In luctus a ex nec pretium. Praesent neque quam, tincidunt nec leo eget, rutrum vehicula magna.\nMaecenas consequat elementum elit, id semper sem tristique et. Integer pulvinar enim quis consectetur interdum volutpat. !@#$%^&*()_+-=,.<>/?")
  .end((error, response) => {
    if (error) throw new Error(error);
    console.log(JSON.stringify(response.body));
  });

ajwad-shaikh avatar Apr 16 '20 07:04 ajwad-shaikh

Any updates? @shreys7

ajwad-shaikh avatar Apr 23 '20 09:04 ajwad-shaikh

@shreys7 Can you give me a heads up on this? Maybe some feedback

Thanks, been a long time.

ajwad-shaikh avatar May 11 '20 04:05 ajwad-shaikh

Good work @ajwad-shaikh 👏

shreys7 avatar May 11 '20 05:05 shreys7

@shreys7 Thanks for #246 The build is now passing CI Tests :)

ajwad-shaikh avatar May 22 '20 14:05 ajwad-shaikh

Hey @shreys7,

Still awaiting your review on this 😄

Thanks!

ajwad-shaikh avatar Jun 29 '20 13:06 ajwad-shaikh