Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Node-Js SuperAgent Code Generator #238

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

ajwad-shaikh
Copy link
Contributor

What it does?
Fixes (postmanlabs/postman-app-support#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
Copy link
Contributor Author

Any updates on this? @umeshp7 @shreys7

Would appreciate a review 😊

@shreys7
Copy link
Member

shreys7 commented Apr 16, 2020

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

@ajwad-shaikh
Copy link
Contributor Author

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
Copy link
Contributor Author

Any updates? @shreys7

@ajwad-shaikh
Copy link
Contributor Author

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

Thanks, been a long time.

@shreys7
Copy link
Member

shreys7 commented May 11, 2020

Good work @ajwad-shaikh 👏

`${indentString}}))\n`;
break;
case 'formdata':
bodySnippet = `${extractFormData(requestBody[requestBody.mode], indentString, trimBody, requestBody.mode)}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a \n is missing at the end for formdata case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out @shreys7
I have added a commit to correct this ✔️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing because of #246

@ajwad-shaikh
Copy link
Contributor Author

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

@ajwad-shaikh
Copy link
Contributor Author

Hey @shreys7,

Still awaiting your review on this 😄

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants