Skip to content

Commit 8b81c13

Browse files
committed
Boilerplate commit for Nodejs(Superagent) Codegen
1 parent 05e35ab commit 8b81c13

12 files changed

+819
-4
lines changed

codegens/nodejs-superagent/.gitignore

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.DS_Store
2+
# Logs
3+
logs
4+
*.log
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
9+
# Coverage directory used by tools like istanbul
10+
.coverage
11+
12+
# node-waf configuration
13+
.lock-wscript
14+
15+
16+
# Dependency directories
17+
node_modules/
18+
jspm_packages/
19+
20+
# Typescript v1 declaration files
21+
typings/
22+
23+
# Optional npm cache directory
24+
.npm
25+
26+
# Optional eslint cache
27+
.eslintcache
28+
29+
# Optional REPL history
30+
.node_repl_history
31+
32+
# Output of 'npm pack'
33+
*.tgz
34+
35+
# Yarn Integrity file
36+
.yarn-integrity
37+
38+
# dotenv environment variables file
39+
.env
40+
41+
out/

codegens/nodejs-superagent/.npmignore

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
### NPM Specific: Disregard recursive project files
2+
### ===============================================
3+
/.editorconfig
4+
/.gitmodules
5+
/test
6+
7+
### Borrowed from .gitignore
8+
### ========================
9+
10+
# Logs
11+
logs
12+
*.log
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*
16+
17+
# Runtime data
18+
pids
19+
*.pid
20+
*.seed
21+
*.pid.lock
22+
23+
# Prevent IDE stuff
24+
.idea
25+
.vscode
26+
*.sublime-*
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
lib-cov
30+
31+
# Coverage directory used by tools like istanbul
32+
.coverage
33+
34+
# nyc test coverage
35+
.nyc_output
36+
37+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
38+
.grunt
39+
40+
# Bower dependency directory (https://bower.io/)
41+
bower_components
42+
43+
# node-waf configuration
44+
.lock-wscript
45+
46+
# Compiled binary addons (http://nodejs.org/api/addons.html)
47+
build/Release
48+
49+
# Dependency directories
50+
node_modules/
51+
jspm_packages/
52+
53+
# Typescript v1 declaration files
54+
typings/
55+
56+
# Optional npm cache directory
57+
.npm
58+
59+
# Optional eslint cache
60+
.eslintcache
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
74+
snippet.swift
75+
76+
out/

codegens/nodejs-superagent/README.md

+39-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
1-
# codegen-nodejs-superagent
2-
3-
> Converts Postman-SDK Request into code snippet for NodeJS-superagent.
41

2+
> Converts Postman-SDK Request into code snippet for Nodejs(Superagent).
53
64
#### Prerequisites
7-
To run the module, ensure that you have NodeJS with superagent as a dependency. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager.
5+
To run Code-Gen, ensure that you have NodeJS >= v8. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager.
6+
7+
## Using the Module
8+
The module will expose an object which will have property `convert` which is the function for converting the Postman-SDK request to swift code snippet.
9+
10+
### convert function
11+
Convert function takes three parameters
12+
13+
* `request` - Postman-SDK Request Object
14+
15+
* `options` - options is an object which hsa following properties
16+
* `indentType` - String denoting type of indentation for code snippet. eg: 'Space', 'Tab'
17+
* `indentCount` - The number of indentation characters to add per code level
18+
* `trimRequestBody` - Whether or not request body fields should be trimmed
19+
20+
* `callback` - callback function with first parameter as error and second parameter as string for code snippet
21+
22+
##### Example:
23+
```js
24+
var request = new sdk.Request('www.google.com'), //using postman sdk to create request
25+
options = {
26+
indentCount: 3,
27+
indentType: 'Space',
28+
requestTimeout: 200,
29+
trimRequestBody: true
30+
};
31+
convert(request, options, function(error, snippet) {
32+
if (error) {
33+
// handle error
34+
}
35+
// handle snippet
36+
});
37+
```
38+
### Guidelines for using generated snippet
39+
40+
* Since Postman-SDK Request object doesn't provide complete path of the file, it needs to be manually inserted in case of uploading a file.
41+
42+
* This module doesn't support cookies.

codegens/nodejs-superagent/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib');
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
convert: function (request, options) {
3+
// Use request object and options object to generate code snippet.
4+
// return (String) snippet
5+
},
6+
getOptions: function () {
7+
// Return an array of options supported by this codegen.
8+
}
9+
};

0 commit comments

Comments
 (0)