├── .eslintrc.json ├── .github └── workflows │ └── publish.yml ├── .gitignore ├── .prettierrc ├── .vscode └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── bin └── index.js ├── package.json ├── pnpm-lock.yaml ├── readme.md ├── static ├── pm_ts.mp4 └── sample.json └── test.js /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true, 5 | "es2021": true 6 | }, 7 | "extends": "eslint:recommended", 8 | "parserOptions": { 9 | "ecmaVersion": "latest" 10 | }, 11 | "globals": { 12 | "process": "readonly" 13 | }, 14 | "rules": {} 15 | } 16 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish Package to npm 2 | on: 3 | release: 4 | types: [published] 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | # Setup .npmrc file to publish to npm 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: "16.x" 15 | registry-url: "https://registry.npmjs.org" 16 | - run: npm publish 17 | env: 18 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | types 2 | .DS_Store 3 | node_modules 4 | output -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": false, 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": ["previewlanguage"] 3 | } 4 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | . 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to postman-to-typescript 2 | 3 | The [Open Source Guides](https://opensource.guide/) website has a collection of resources for individuals, communities, and companies. These resources help people who want to learn how to run and contribute to open source projects. Contributors and people new to open source alike will find the following guides especially useful: 4 | 5 | - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) 6 | - [Building Welcoming Communities](https://opensource.guide/building-community/) 7 | 8 | ## Get involved 9 | 10 | There are many ways to contribute to the project, and many of them do not involve writing any code. Here's a few ideas to get started: 11 | 12 | - Simply start using postman-to-typescript. Does everything work as expected? If not, we're always looking for improvements or some new features. Let us know by [opening an issue](https://github.com/n1rjal/postman-to-typescript/issues). 13 | - Look through the [open issues](https://github.com/n1rjal/postman-to-typescript/issues). 14 | - If you find an issue you would like to fix, [open a pull request](https://github.com/n1rjal/postman-to-typescript/pulls). 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Nirjal Paudel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/index.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | /* The code is defining two constants: one for all typescript illegal characters and other for numeric types in js*/ 4 | const TS_ILLEGAL_CHARACTERS = /[^\w\s\n]/g; 5 | const NUMERIC_TYPES = ["number", "bigint"]; 6 | const { 7 | readFileSync, 8 | writeFile: writeFileFs, 9 | existsSync, 10 | mkdirSync, 11 | } = require("fs"); 12 | const { join } = require("path"); 13 | const rl = require("readline").createInterface({ 14 | input: process.stdin, 15 | output: process.stdout, 16 | }); 17 | 18 | /* The above code is defining an array called `ALL_DEFINED_ARGS` which contains objects representing 19 | command line arguments. Each object has properties such as `keys` (an array of possible argument 20 | keys), `required` (a boolean indicating if the argument is required), `question` (a string 21 | representing the question to ask the user when the argument is not provided), and `default` (a 22 | default value for the argument if not provided). These objects represent the different command line 23 | arguments that can be passed to a script or program. */ 24 | const ALL_DEFINED_ARGS = [ 25 | { keys: ["-i", "--input"], required: true, question: "Postman input file" }, 26 | { 27 | keys: ["-o", "--output"], 28 | required: true, 29 | question: "The output directory", 30 | }, 31 | { keys: ["-ia", "--include-any"], required: false, default: false }, 32 | { 33 | keys: ["-sc", "--status-codes"], 34 | required: false, 35 | default: "", 36 | }, 37 | { 38 | keys: ["-ft", "--force-text"], 39 | required: false, 40 | default: false, 41 | }, 42 | { 43 | keys: ["-te", "--throw-error"], 44 | required: false, 45 | default: false, 46 | }, 47 | { keys: ["-X", "--api-key"], required: true, question: "Postman API key" }, 48 | { 49 | keys: ["-U", "--collection-url"], 50 | required: true, 51 | question: "Remote postman collection url", 52 | }, 53 | { keys: ["-p", "--prefix"], required: false, default: "" }, 54 | ]; 55 | 56 | /* The above code is defining a map called `ARGS_HELP_MAP` which is used to store help messages for 57 | different command line arguments. Each argument is associated with a help message that describes its 58 | purpose. The map is populated with key-value pairs where the key is the command line argument and 59 | the value is the corresponding help message. */ 60 | const ARGS_HELP_MAP = new Map(); 61 | // from the key array we will be using the first one 62 | // and ignoring the last one 63 | ARGS_HELP_MAP.set( 64 | ALL_DEFINED_ARGS[0], 65 | `The export of postman data as json v2.0`, 66 | ); 67 | ARGS_HELP_MAP.set(ALL_DEFINED_ARGS[1], `The output directory for all types`); 68 | ARGS_HELP_MAP.set( 69 | ALL_DEFINED_ARGS[2], 70 | `This specifies if any must be included in typescript types or not. Default value is false`, 71 | ); 72 | ARGS_HELP_MAP.set( 73 | ALL_DEFINED_ARGS[3], 74 | `This specifies if we can add type support for response of the types provided. Default value is 200[comma separated]`, 75 | ); 76 | ARGS_HELP_MAP.set( 77 | ALL_DEFINED_ARGS[4], 78 | `This specifies if we need to parse text content in postman request or not. Default value is false`, 79 | ); 80 | ARGS_HELP_MAP.set( 81 | ALL_DEFINED_ARGS[5], 82 | `This specifies if the program should throw error`, 83 | ); 84 | ARGS_HELP_MAP.set(ALL_DEFINED_ARGS[6], `This specifies the postman API key`); 85 | ARGS_HELP_MAP.set( 86 | ALL_DEFINED_ARGS[7], 87 | `This specifies the remote postman collection id`, 88 | ); 89 | 90 | /* The above code is filtering an array called `ALL_DEFINED_ARGS` to only include elements that have a 91 | property `required` set to `true`. */ 92 | let requiredArgs = ALL_DEFINED_ARGS.filter((arg) => arg.required); 93 | 94 | /* The above code is declaring and initializing several variables. */ 95 | let file = ""; 96 | let throwError = false; 97 | let INCLUDE_ANY = true; 98 | let TYPES_FOR_STATUS_CODE = [200]; 99 | let OUTPUT_DIR = ""; 100 | let PARSE_TYPES = ["json"]; 101 | let PREFIX = ""; 102 | 103 | /** 104 | * The function `printHelp` checks if the user has requested help by checking command line arguments, 105 | * and if so, it prints out information about available options and their descriptions. 106 | * @returns `false` if the user did not ask for help, and it is not returning anything if the user 107 | * asked for help. 108 | */ 109 | function printHelp() { 110 | const userAskedForHelp = 111 | process.argv.includes("-h") || process.argv.includes("--help"); 112 | 113 | if (!userAskedForHelp) return false; 114 | 115 | console.log(`\n`); 116 | for (const [argKey, argHelp] of ARGS_HELP_MAP.entries()) { 117 | const keys = argKey.keys; 118 | console.log(`Option Flag: ${keys.join(", ")}`); 119 | if (argHelp.required) 120 | console.log(`Required: ${argHelp.required.toString()}`); 121 | if (!argKey.required && argHelp.default) 122 | console.log(`Default: ${argHelp.default.toString()}`); 123 | console.log(`${argHelp}\n\n`); 124 | } 125 | process.exit(0); 126 | } 127 | 128 | /** 129 | * The function `parseAllRequiredArgs` parses command line arguments and checks if all required 130 | * arguments are present. 131 | * @returns an object containing the parsed command line arguments. 132 | */ 133 | async function parseArgs() { 134 | // we will keep iterating and popping from the array until it is empty 135 | // if it is not empty we say that the command line arguments are invalid 136 | // and the following are required or we can ask for user input 137 | // the args here is raw meaning it will have -h and -sc as the key of object args 138 | const args = {}; 139 | 140 | for (let i = 2; i < process.argv.length; i++) { 141 | // usually keys some at with format --input filename.json or -i fn.json 142 | // so argv[i] = --input 143 | // and argv[i+1] = filename.json 144 | 145 | const argKeyRaw = process.argv[i++]; 146 | 147 | const keyObject = ALL_DEFINED_ARGS.find((arg) => 148 | arg.keys.includes(argKeyRaw), 149 | ); 150 | 151 | if (!keyObject) { 152 | i = i + 2; 153 | continue; 154 | } 155 | 156 | const argKey = keyObject.keys[0]; 157 | const argValue = process.argv[i]; 158 | args[argKey] = argValue; 159 | 160 | // basically we are searching by both keys 161 | requiredArgs = requiredArgs.filter( 162 | (arg) => !(arg.keys[0] === argKey || arg.keys[1] === argKey), 163 | ); 164 | } 165 | 166 | if (!(args["-i"] || args["-U"] || args["-X"])) { 167 | let inp = await askQuestion( 168 | "Use remote postman[1] or local json file[2] ? [Default: 2]", 169 | ); 170 | try { 171 | inp = parseInt(inp); 172 | } catch (err) { 173 | inp = 0; 174 | } 175 | switch (inp) { 176 | case 1: 177 | requiredArgs = requiredArgs.filter( 178 | (arg) => !(arg.keys[0] === "-i" || arg.keys[1] === "--input"), 179 | ); 180 | break; 181 | case 2: 182 | requiredArgs = requiredArgs.filter( 183 | (arg) => 184 | !( 185 | arg.keys[0] === "-U" || 186 | arg.keys[1] === "--collection-id" || 187 | arg.keys[0] === "-X" || 188 | arg.keys[1] === "--api-key" 189 | ), 190 | ); 191 | break; 192 | default: 193 | console.error("Please enter 1 or 2 as input"); 194 | process.exit(1); 195 | } 196 | } 197 | if (args["-i"]) 198 | requiredArgs = requiredArgs.filter( 199 | (arg) => 200 | !( 201 | arg.keys[0] === "-U" || 202 | arg.keys[1] === "--collection-id" || 203 | arg.keys[0] === "-X" || 204 | arg.keys[1] === "--api-key" 205 | ), 206 | ); 207 | if (!args["-i"] && (args["-U"] || args["-X"])) 208 | requiredArgs = requiredArgs.filter( 209 | (arg) => !(arg.keys[0] === "-i" || arg.keys[1] === "--input"), 210 | ); 211 | 212 | // fill in the rest with defaults 213 | for (const arg of ALL_DEFINED_ARGS) { 214 | if (!args[arg.keys[0]]) { 215 | args[arg.keys[0]] = arg.default; 216 | } 217 | } 218 | 219 | // prompt user for required arguments 220 | if (requiredArgs.length) { 221 | for (const arg of requiredArgs) { 222 | args[arg.keys[0]] = await askQuestion(arg.question); 223 | } 224 | } 225 | 226 | return args; 227 | } 228 | 229 | /** 230 | * The function `askQuestion` is an asynchronous function that prompts the user with a question and 231 | * returns a promise that resolves with the user's answer. 232 | * @param questionText - The `questionText` parameter is a string that represents the text of the 233 | * question you want to ask the user. 234 | * @returns The function `askQuestion` returns a promise. 235 | */ 236 | async function askQuestion(questionText) { 237 | return new Promise((resolve) => { 238 | const question = `# ${questionText}: `; 239 | rl.question(question, (answer) => { 240 | resolve(answer); 241 | }); 242 | }); 243 | } 244 | 245 | /** 246 | * The function `writeFile` is a JavaScript function that writes content to a file and returns a 247 | * promise that resolves to `true` if the operation is successful. 248 | * @param filePath - The `filePath` parameter is a string that represents the path to the file where 249 | * you want to write the content. It should include the file name and extension. 250 | * @param fileContent - The `fileContent` parameter is the content that you want to write to the file. 251 | * It can be a string, an object, or any other data type that can be converted to a string. 252 | * @returns a Promise object. 253 | */ 254 | function writeFile(filePath, fileContent) { 255 | return new Promise((resolve, reject) => { 256 | writeFileFs(filePath, fileContent, { flag: "w+" }, (err) => { 257 | if (err) reject(err); 258 | resolve(true); 259 | }); 260 | }); 261 | } 262 | 263 | /** 264 | * The function converts a string to camel case by removing illegal characters, splitting the string 265 | * into words, and capitalizing the first letter of each word except the first one. 266 | * @param string - The `string` parameter is the input string that you want to convert to camel case. 267 | * @returns a camelCase version of the input string. 268 | */ 269 | function toCamelCase(string) { 270 | const legalString = string 271 | .replaceAll("\n", "") 272 | .replaceAll("-", "_") 273 | .replaceAll(TS_ILLEGAL_CHARACTERS, "") 274 | .split(" ") 275 | .map((words) => words.trim()) 276 | 277 | .filter((string) => string.length > 0); 278 | 279 | return legalString.reduce((accumulator, word) => { 280 | return accumulator + word[0].toUpperCase() + word.slice(1); 281 | }, ""); 282 | } 283 | 284 | /** 285 | * The function `parseTypeFromPostManRequestQuery` takes in a name and a request object, and if the 286 | * request has a query, it converts the query parameters into a TypeScript type and writes it to a 287 | * file. 288 | * @param name - The `name` parameter is a string that represents the name of the request or query. It 289 | * is used to generate the file name and the interface name in the output file. 290 | * @param request - The `request` parameter is an object that represents a request made in Postman. It 291 | * contains information about the request, such as the method (e.g., GET, POST) and the URL. 292 | */ 293 | async function parseTypeFromPostManRequestQuery(name, request, prefix) { 294 | if (request?.url?.query && request?.url?.query?.length > 0) { 295 | const method = request.method; 296 | const url = request.url.raw; 297 | 298 | if (request?.url?.query && request?.url?.query.length > 0) { 299 | const json = request.url.query.reduce( 300 | (accumulator, item) => ({ 301 | ...accumulator, 302 | [TS_ILLEGAL_CHARACTERS.test(item.key) ? `"${item.key}"` : item.key]: 303 | item.value, 304 | }), 305 | {}, 306 | ); 307 | const content = getTypeScriptTypeFromRawJson( 308 | name, 309 | JSON.stringify(json), 310 | prefix, 311 | ); 312 | const path = join( 313 | `${OUTPUT_DIR}`, 314 | "queries", 315 | `${prefix}${toCamelCase(name)}Query.ts`, 316 | ); 317 | const fileContent = `/*\n${name}\n${method}: ${url}\n*/\n` + content; 318 | writeFile(path, fileContent, { flag: "w+" }, (err) => { 319 | if (err) throw err; 320 | }); 321 | } 322 | } 323 | } 324 | 325 | /** 326 | * The function `parseTypeFromPostManJsonBody` parses a JSON body from a Postman request and generates 327 | * a TypeScript type definition file based on the parsed data. 328 | * @param req - The `req` parameter is an object that represents the request made to the server. It 329 | * contains information such as the request method (`req.method`), the request URL (`req.url.raw`), and 330 | * the query parameters (`req.url.query`). 331 | */ 332 | async function parseTypeFromPostManRequestJsonBody(name, req, prefix) { 333 | if (req?.body?.options?.raw?.language === "json" && req?.body?.raw) { 334 | const raw = req.body.raw; 335 | const method = req.method; 336 | const url = req?.url?.raw ?? req.url; 337 | 338 | const content = getTypeScriptTypeFromRawJson(name, raw, prefix); 339 | const path = join( 340 | `${OUTPUT_DIR}`, 341 | "request", 342 | `${prefix}${toCamelCase(name)}Request.ts`, 343 | ); 344 | const fileContent = `/*\n${name}\n${method}: ${url}\n*/\n` + content; 345 | return writeFile(path, fileContent); 346 | } 347 | } 348 | 349 | /** 350 | * The function `parseTypesFromPostManExamples` parses types from a Postman response and generates a 351 | * TypeScript interface file. 352 | * @param resp - The `resp` parameter is an object that represents a response from a Postman request. 353 | * It contains the following properties: 354 | */ 355 | async function parseTypesFromPostManExampleResponse(resp, prefix) { 356 | const name = `${resp.name} ResponseBody`; 357 | const rawJson = resp.body; 358 | 359 | if ( 360 | PARSE_TYPES.includes(resp._postman_previewlanguage) && 361 | rawJson.length > 0 && 362 | TYPES_FOR_STATUS_CODE.includes(200) 363 | ) { 364 | const content = getTypeScriptTypeFromRawJson(name, rawJson, prefix); 365 | const fileContent = `/*\n${name}\n*/\n` + content; 366 | const path = join( 367 | `${OUTPUT_DIR}`, 368 | "response", 369 | `${prefix}${toCamelCase(name)}.ts`, 370 | ); 371 | return writeFile(path, fileContent); 372 | } 373 | } 374 | 375 | /** 376 | * The function `getTypescriptEquivalentForVariable` returns the TypeScript equivalent type for a given 377 | * JavaScript variable. 378 | * @param value - The `value` parameter in the `getTypescriptEquivalentForVariable` function is the 379 | * variable for which we want to determine the TypeScript equivalent type. 380 | * @returns a TypeScript equivalent type for the given variable. 381 | */ 382 | function getTypescriptEquivalentForVariable(value, prefix, depth = 1) { 383 | const type = typeof value; 384 | 385 | if (value === null) return "null"; 386 | 387 | if (type === "object") { 388 | if (Array.isArray(value)) { 389 | const type = getTypescriptEquivalentForVariable( 390 | value[0], 391 | prefix, 392 | depth + 1, 393 | ); 394 | return type ? `${type}[]` : INCLUDE_ANY ? "any[]" : "unknown[]"; 395 | } 396 | let nestedType = getTypeScriptTypeFromRawJson( 397 | null, 398 | JSON.stringify(value), 399 | prefix, 400 | depth + 1, 401 | ); 402 | return nestedType; 403 | } 404 | 405 | if (type === "boolean") return "boolean"; 406 | if (NUMERIC_TYPES.includes(type)) return "number"; 407 | if (type === "string") return "string"; 408 | return INCLUDE_ANY ? "any" : "unknown"; 409 | } 410 | 411 | /** 412 | * The function `getTypeScriptTypeFromRawJson` takes a name and a raw JSON string as input and returns 413 | * a TypeScript interface or type definition based on the structure of the JSON data. 414 | * @param name - The `name` parameter is a string that represents the name of the TypeScript interface 415 | * you want to generate. It is used to create the interface name by converting it to camel case and 416 | * prefixing it with "I". 417 | * @param rawJson - The `rawJson` parameter is a string that represents a JSON object or array. It is 418 | * the raw JSON data that you want to convert into a TypeScript type. 419 | * @returns a TypeScript interface or object literal as a string. 420 | */ 421 | function getTypeScriptTypeFromRawJson(name, rawJson, prefix, depth = 1) { 422 | let response = 423 | (name && name.length) > 0 424 | ? `export interface ${prefix}${toCamelCase(name)} { \n` 425 | : "{ \n"; 426 | try { 427 | let jsonData = JSON.parse(rawJson); 428 | 429 | if (Array.isArray(jsonData) && jsonData.length > 0) jsonData = jsonData[0]; 430 | 431 | for (const key in jsonData) { 432 | for (let i = 0; i < depth; i++) response += " "; 433 | response += `${key}: ${getTypescriptEquivalentForVariable( 434 | jsonData[key], 435 | prefix, 436 | depth + 1, 437 | )}; \n`; 438 | } 439 | for (let i = 0; i < depth - 1; i++) response += " "; 440 | response += "}"; 441 | return response; 442 | } catch (e) { 443 | if (throwError) throw e; 444 | } 445 | } 446 | 447 | /** 448 | * The function `getData` processes JSON data and generates TypeScript type definitions based on the 449 | * data structure. 450 | * @param jsonData - The `jsonData` parameter is an object that contains information about a request 451 | * and its corresponding response. It is expected to have the following properties: 452 | */ 453 | async function getData(jsonData, prefix) { 454 | if (jsonData.item) { 455 | for (const item of jsonData.item) { 456 | await getData(item, prefix); 457 | } 458 | } else { 459 | const req = jsonData.request; 460 | const exampleResponses = jsonData.response; 461 | await parseTypeFromPostManRequestJsonBody(jsonData.name, req, prefix); 462 | await parseTypeFromPostManRequestQuery(jsonData.name, req, prefix); 463 | await Promise.all( 464 | exampleResponses.map(async (resp) => 465 | parseTypesFromPostManExampleResponse(resp, prefix), 466 | ), 467 | ); 468 | return true; 469 | } 470 | } 471 | 472 | /** 473 | * The function `getPostmanCollectionJSON` fetches remote postman collection with `collectionID` using 474 | * postman API key `apiKey`. 475 | * @param collectionID - The `collectionID` parameter is the collectionID of the remote postman collection. 476 | * @param apiKey - The `apiKey` paramater is the user-generated postman api key. 477 | */ 478 | async function getPostmanCollectionJSON(collectionID, apiKey) { 479 | try { 480 | const response = await fetch( 481 | `https://api.getpostman.com/collections/${collectionID}?format=2.0.0`, 482 | { 483 | headers: { 484 | "X-API-KEY": apiKey, 485 | }, 486 | }, 487 | ); 488 | const data = await response.json(); 489 | if (data.error) { 490 | throw new Error(`${data.error.name}: ${data.error.message}`); 491 | } 492 | return data.collection; 493 | } catch (err) { 494 | throw new Error(err.message); 495 | } 496 | } 497 | 498 | /** 499 | * The main function reads command line arguments, checks file and output folder existence, creates 500 | * necessary directories, reads JSON data from a file, and calls the getData function. 501 | */ 502 | async function main() { 503 | const args = await parseArgs(); 504 | if (args["-i"]) file = args["-i"]; 505 | throwError = Boolean(args["-te"]); 506 | INCLUDE_ANY = Boolean(args["-ia"]); 507 | OUTPUT_DIR = args["-o"]; 508 | PARSE_TYPES = ["json"]; 509 | PREFIX = args["-p"]; 510 | 511 | if (args["-ft"]) PARSE_TYPES.push("text"); 512 | 513 | if (args["-sc"] && args?.["-sc"]?.split(",").length > 0) 514 | args?.sc?.split(",").forEach((code) => { 515 | TYPES_FOR_STATUS_CODE.push(parseInt(code)); 516 | }); 517 | 518 | const outputFolderExists = existsSync(OUTPUT_DIR); 519 | 520 | if (args["-i"] && !existsSync(file)) { 521 | console.log(`File ${file} does not exist`); 522 | process.exit(1); 523 | } 524 | 525 | if (!outputFolderExists) { 526 | mkdirSync(OUTPUT_DIR); 527 | } 528 | 529 | if (!existsSync(join(OUTPUT_DIR, "queries"))) { 530 | mkdirSync(join(OUTPUT_DIR, "queries")); 531 | } 532 | 533 | if (!existsSync(join(OUTPUT_DIR, "request"))) { 534 | mkdirSync(join(OUTPUT_DIR, "request")); 535 | } 536 | 537 | if (!existsSync(join(OUTPUT_DIR, "response"))) { 538 | mkdirSync(join(OUTPUT_DIR, "response")); 539 | } 540 | 541 | if (args["-U"]) { 542 | const collectionID = args["-U"] 543 | .split("") 544 | .reverse() 545 | .join("") 546 | .split("/")[0] 547 | .split("") 548 | .reverse() 549 | .join(""); 550 | const apiKey = args["-X"]; 551 | const jsonData = await getPostmanCollectionJSON(collectionID, apiKey); 552 | await getData(jsonData, PREFIX); 553 | } else { 554 | const data = readFileSync(file); 555 | const jsonData = JSON.parse(data); 556 | await getData(jsonData, PREFIX); 557 | } 558 | } 559 | 560 | // if user has asked for help this will print the help 561 | // help is asked if -h or --help is present in command 562 | // or if there is not args 563 | printHelp(); 564 | 565 | // run the main function 566 | main() 567 | .then(() => { 568 | process.exit(0); 569 | }) 570 | .catch((e) => { 571 | console.log(e?.message ?? e); 572 | process.exit(1); 573 | }); 574 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@n1rjal/pm_ts", 3 | "version": "0.3.2", 4 | "author": "Nirjal Paudel", 5 | "description": "A simple tool that transforms Postman files into typescript type files", 6 | "bin": { 7 | "pm_ts": "bin/index.js" 8 | }, 9 | "homepage": "https://github.com/n1rjal/postman-to-typescript", 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1", 12 | "prepare": "husky install" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/n1rjal/postman-to-typescript" 17 | }, 18 | "files": [ 19 | "bin" 20 | ], 21 | "husky": { 22 | "hooks": { 23 | "pre-commit": "lint-staged" 24 | } 25 | }, 26 | "keywords": [ 27 | "utils", 28 | "postman", 29 | "typescript", 30 | "code-generator", 31 | "generator", 32 | "convertor", 33 | "type-generator" 34 | ], 35 | "engines": { 36 | "node": ">=16.0.0" 37 | }, 38 | "bugs": { 39 | "email": "nirjalpaudel54312@gmail.com", 40 | "url": "https://github.com/n1rjal/postman-to-typescript/issues" 41 | }, 42 | "license": "Apache-2.0", 43 | "devDependencies": { 44 | "eslint": "^8.45.0", 45 | "husky": "^8.0.3" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: '6.0' 2 | 3 | settings: 4 | autoInstallPeers: true 5 | excludeLinksFromLockfile: false 6 | 7 | devDependencies: 8 | eslint: 9 | specifier: ^8.45.0 10 | version: 8.45.0 11 | husky: 12 | specifier: ^8.0.3 13 | version: 8.0.3 14 | 15 | packages: 16 | 17 | /@aashutoshrathi/word-wrap@1.2.6: 18 | resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==} 19 | engines: {node: '>=0.10.0'} 20 | dev: true 21 | 22 | /@eslint-community/eslint-utils@4.4.0(eslint@8.45.0): 23 | resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} 24 | engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} 25 | peerDependencies: 26 | eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 27 | dependencies: 28 | eslint: 8.45.0 29 | eslint-visitor-keys: 3.4.1 30 | dev: true 31 | 32 | /@eslint-community/regexpp@4.6.2: 33 | resolution: {integrity: sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==} 34 | engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} 35 | dev: true 36 | 37 | /@eslint/eslintrc@2.1.0: 38 | resolution: {integrity: sha512-Lj7DECXqIVCqnqjjHMPna4vn6GJcMgul/wuS0je9OZ9gsL0zzDpKPVtcG1HaDVc+9y+qgXneTeUMbCqXJNpH1A==} 39 | engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} 40 | dependencies: 41 | ajv: 6.12.6 42 | debug: 4.3.4 43 | espree: 9.6.1 44 | globals: 13.20.0 45 | ignore: 5.2.4 46 | import-fresh: 3.3.0 47 | js-yaml: 4.1.0 48 | minimatch: 3.1.2 49 | strip-json-comments: 3.1.1 50 | transitivePeerDependencies: 51 | - supports-color 52 | dev: true 53 | 54 | /@eslint/js@8.44.0: 55 | resolution: {integrity: sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==} 56 | engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} 57 | dev: true 58 | 59 | /@humanwhocodes/config-array@0.11.10: 60 | resolution: {integrity: sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==} 61 | engines: {node: '>=10.10.0'} 62 | dependencies: 63 | '@humanwhocodes/object-schema': 1.2.1 64 | debug: 4.3.4 65 | minimatch: 3.1.2 66 | transitivePeerDependencies: 67 | - supports-color 68 | dev: true 69 | 70 | /@humanwhocodes/module-importer@1.0.1: 71 | resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} 72 | engines: {node: '>=12.22'} 73 | dev: true 74 | 75 | /@humanwhocodes/object-schema@1.2.1: 76 | resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} 77 | dev: true 78 | 79 | /@nodelib/fs.scandir@2.1.5: 80 | resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} 81 | engines: {node: '>= 8'} 82 | dependencies: 83 | '@nodelib/fs.stat': 2.0.5 84 | run-parallel: 1.2.0 85 | dev: true 86 | 87 | /@nodelib/fs.stat@2.0.5: 88 | resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} 89 | engines: {node: '>= 8'} 90 | dev: true 91 | 92 | /@nodelib/fs.walk@1.2.8: 93 | resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} 94 | engines: {node: '>= 8'} 95 | dependencies: 96 | '@nodelib/fs.scandir': 2.1.5 97 | fastq: 1.15.0 98 | dev: true 99 | 100 | /acorn-jsx@5.3.2(acorn@8.10.0): 101 | resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} 102 | peerDependencies: 103 | acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 104 | dependencies: 105 | acorn: 8.10.0 106 | dev: true 107 | 108 | /acorn@8.10.0: 109 | resolution: {integrity: sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==} 110 | engines: {node: '>=0.4.0'} 111 | hasBin: true 112 | dev: true 113 | 114 | /ajv@6.12.6: 115 | resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} 116 | dependencies: 117 | fast-deep-equal: 3.1.3 118 | fast-json-stable-stringify: 2.1.0 119 | json-schema-traverse: 0.4.1 120 | uri-js: 4.4.1 121 | dev: true 122 | 123 | /ansi-regex@5.0.1: 124 | resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} 125 | engines: {node: '>=8'} 126 | dev: true 127 | 128 | /ansi-styles@4.3.0: 129 | resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} 130 | engines: {node: '>=8'} 131 | dependencies: 132 | color-convert: 2.0.1 133 | dev: true 134 | 135 | /argparse@2.0.1: 136 | resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} 137 | dev: true 138 | 139 | /balanced-match@1.0.2: 140 | resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} 141 | dev: true 142 | 143 | /brace-expansion@1.1.11: 144 | resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} 145 | dependencies: 146 | balanced-match: 1.0.2 147 | concat-map: 0.0.1 148 | dev: true 149 | 150 | /callsites@3.1.0: 151 | resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} 152 | engines: {node: '>=6'} 153 | dev: true 154 | 155 | /chalk@4.1.2: 156 | resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} 157 | engines: {node: '>=10'} 158 | dependencies: 159 | ansi-styles: 4.3.0 160 | supports-color: 7.2.0 161 | dev: true 162 | 163 | /color-convert@2.0.1: 164 | resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} 165 | engines: {node: '>=7.0.0'} 166 | dependencies: 167 | color-name: 1.1.4 168 | dev: true 169 | 170 | /color-name@1.1.4: 171 | resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} 172 | dev: true 173 | 174 | /concat-map@0.0.1: 175 | resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} 176 | dev: true 177 | 178 | /cross-spawn@7.0.3: 179 | resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} 180 | engines: {node: '>= 8'} 181 | dependencies: 182 | path-key: 3.1.1 183 | shebang-command: 2.0.0 184 | which: 2.0.2 185 | dev: true 186 | 187 | /debug@4.3.4: 188 | resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} 189 | engines: {node: '>=6.0'} 190 | peerDependencies: 191 | supports-color: '*' 192 | peerDependenciesMeta: 193 | supports-color: 194 | optional: true 195 | dependencies: 196 | ms: 2.1.2 197 | dev: true 198 | 199 | /deep-is@0.1.4: 200 | resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} 201 | dev: true 202 | 203 | /doctrine@3.0.0: 204 | resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} 205 | engines: {node: '>=6.0.0'} 206 | dependencies: 207 | esutils: 2.0.3 208 | dev: true 209 | 210 | /escape-string-regexp@4.0.0: 211 | resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} 212 | engines: {node: '>=10'} 213 | dev: true 214 | 215 | /eslint-scope@7.2.1: 216 | resolution: {integrity: sha512-CvefSOsDdaYYvxChovdrPo/ZGt8d5lrJWleAc1diXRKhHGiTYEI26cvo8Kle/wGnsizoCJjK73FMg1/IkIwiNA==} 217 | engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} 218 | dependencies: 219 | esrecurse: 4.3.0 220 | estraverse: 5.3.0 221 | dev: true 222 | 223 | /eslint-visitor-keys@3.4.1: 224 | resolution: {integrity: sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==} 225 | engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} 226 | dev: true 227 | 228 | /eslint@8.45.0: 229 | resolution: {integrity: sha512-pd8KSxiQpdYRfYa9Wufvdoct3ZPQQuVuU5O6scNgMuOMYuxvH0IGaYK0wUFjo4UYYQQCUndlXiMbnxopwvvTiw==} 230 | engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} 231 | hasBin: true 232 | dependencies: 233 | '@eslint-community/eslint-utils': 4.4.0(eslint@8.45.0) 234 | '@eslint-community/regexpp': 4.6.2 235 | '@eslint/eslintrc': 2.1.0 236 | '@eslint/js': 8.44.0 237 | '@humanwhocodes/config-array': 0.11.10 238 | '@humanwhocodes/module-importer': 1.0.1 239 | '@nodelib/fs.walk': 1.2.8 240 | ajv: 6.12.6 241 | chalk: 4.1.2 242 | cross-spawn: 7.0.3 243 | debug: 4.3.4 244 | doctrine: 3.0.0 245 | escape-string-regexp: 4.0.0 246 | eslint-scope: 7.2.1 247 | eslint-visitor-keys: 3.4.1 248 | espree: 9.6.1 249 | esquery: 1.5.0 250 | esutils: 2.0.3 251 | fast-deep-equal: 3.1.3 252 | file-entry-cache: 6.0.1 253 | find-up: 5.0.0 254 | glob-parent: 6.0.2 255 | globals: 13.20.0 256 | graphemer: 1.4.0 257 | ignore: 5.2.4 258 | imurmurhash: 0.1.4 259 | is-glob: 4.0.3 260 | is-path-inside: 3.0.3 261 | js-yaml: 4.1.0 262 | json-stable-stringify-without-jsonify: 1.0.1 263 | levn: 0.4.1 264 | lodash.merge: 4.6.2 265 | minimatch: 3.1.2 266 | natural-compare: 1.4.0 267 | optionator: 0.9.3 268 | strip-ansi: 6.0.1 269 | text-table: 0.2.0 270 | transitivePeerDependencies: 271 | - supports-color 272 | dev: true 273 | 274 | /espree@9.6.1: 275 | resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} 276 | engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} 277 | dependencies: 278 | acorn: 8.10.0 279 | acorn-jsx: 5.3.2(acorn@8.10.0) 280 | eslint-visitor-keys: 3.4.1 281 | dev: true 282 | 283 | /esquery@1.5.0: 284 | resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} 285 | engines: {node: '>=0.10'} 286 | dependencies: 287 | estraverse: 5.3.0 288 | dev: true 289 | 290 | /esrecurse@4.3.0: 291 | resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} 292 | engines: {node: '>=4.0'} 293 | dependencies: 294 | estraverse: 5.3.0 295 | dev: true 296 | 297 | /estraverse@5.3.0: 298 | resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} 299 | engines: {node: '>=4.0'} 300 | dev: true 301 | 302 | /esutils@2.0.3: 303 | resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} 304 | engines: {node: '>=0.10.0'} 305 | dev: true 306 | 307 | /fast-deep-equal@3.1.3: 308 | resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} 309 | dev: true 310 | 311 | /fast-json-stable-stringify@2.1.0: 312 | resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} 313 | dev: true 314 | 315 | /fast-levenshtein@2.0.6: 316 | resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} 317 | dev: true 318 | 319 | /fastq@1.15.0: 320 | resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} 321 | dependencies: 322 | reusify: 1.0.4 323 | dev: true 324 | 325 | /file-entry-cache@6.0.1: 326 | resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} 327 | engines: {node: ^10.12.0 || >=12.0.0} 328 | dependencies: 329 | flat-cache: 3.0.4 330 | dev: true 331 | 332 | /find-up@5.0.0: 333 | resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} 334 | engines: {node: '>=10'} 335 | dependencies: 336 | locate-path: 6.0.0 337 | path-exists: 4.0.0 338 | dev: true 339 | 340 | /flat-cache@3.0.4: 341 | resolution: {integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==} 342 | engines: {node: ^10.12.0 || >=12.0.0} 343 | dependencies: 344 | flatted: 3.2.7 345 | rimraf: 3.0.2 346 | dev: true 347 | 348 | /flatted@3.2.7: 349 | resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} 350 | dev: true 351 | 352 | /fs.realpath@1.0.0: 353 | resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} 354 | dev: true 355 | 356 | /glob-parent@6.0.2: 357 | resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} 358 | engines: {node: '>=10.13.0'} 359 | dependencies: 360 | is-glob: 4.0.3 361 | dev: true 362 | 363 | /glob@7.2.3: 364 | resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} 365 | dependencies: 366 | fs.realpath: 1.0.0 367 | inflight: 1.0.6 368 | inherits: 2.0.4 369 | minimatch: 3.1.2 370 | once: 1.4.0 371 | path-is-absolute: 1.0.1 372 | dev: true 373 | 374 | /globals@13.20.0: 375 | resolution: {integrity: sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==} 376 | engines: {node: '>=8'} 377 | dependencies: 378 | type-fest: 0.20.2 379 | dev: true 380 | 381 | /graphemer@1.4.0: 382 | resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} 383 | dev: true 384 | 385 | /has-flag@4.0.0: 386 | resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} 387 | engines: {node: '>=8'} 388 | dev: true 389 | 390 | /husky@8.0.3: 391 | resolution: {integrity: sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==} 392 | engines: {node: '>=14'} 393 | hasBin: true 394 | dev: true 395 | 396 | /ignore@5.2.4: 397 | resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} 398 | engines: {node: '>= 4'} 399 | dev: true 400 | 401 | /import-fresh@3.3.0: 402 | resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} 403 | engines: {node: '>=6'} 404 | dependencies: 405 | parent-module: 1.0.1 406 | resolve-from: 4.0.0 407 | dev: true 408 | 409 | /imurmurhash@0.1.4: 410 | resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} 411 | engines: {node: '>=0.8.19'} 412 | dev: true 413 | 414 | /inflight@1.0.6: 415 | resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} 416 | dependencies: 417 | once: 1.4.0 418 | wrappy: 1.0.2 419 | dev: true 420 | 421 | /inherits@2.0.4: 422 | resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} 423 | dev: true 424 | 425 | /is-extglob@2.1.1: 426 | resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} 427 | engines: {node: '>=0.10.0'} 428 | dev: true 429 | 430 | /is-glob@4.0.3: 431 | resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} 432 | engines: {node: '>=0.10.0'} 433 | dependencies: 434 | is-extglob: 2.1.1 435 | dev: true 436 | 437 | /is-path-inside@3.0.3: 438 | resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} 439 | engines: {node: '>=8'} 440 | dev: true 441 | 442 | /isexe@2.0.0: 443 | resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} 444 | dev: true 445 | 446 | /js-yaml@4.1.0: 447 | resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} 448 | hasBin: true 449 | dependencies: 450 | argparse: 2.0.1 451 | dev: true 452 | 453 | /json-schema-traverse@0.4.1: 454 | resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} 455 | dev: true 456 | 457 | /json-stable-stringify-without-jsonify@1.0.1: 458 | resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} 459 | dev: true 460 | 461 | /levn@0.4.1: 462 | resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} 463 | engines: {node: '>= 0.8.0'} 464 | dependencies: 465 | prelude-ls: 1.2.1 466 | type-check: 0.4.0 467 | dev: true 468 | 469 | /locate-path@6.0.0: 470 | resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} 471 | engines: {node: '>=10'} 472 | dependencies: 473 | p-locate: 5.0.0 474 | dev: true 475 | 476 | /lodash.merge@4.6.2: 477 | resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} 478 | dev: true 479 | 480 | /minimatch@3.1.2: 481 | resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} 482 | dependencies: 483 | brace-expansion: 1.1.11 484 | dev: true 485 | 486 | /ms@2.1.2: 487 | resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} 488 | dev: true 489 | 490 | /natural-compare@1.4.0: 491 | resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} 492 | dev: true 493 | 494 | /once@1.4.0: 495 | resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} 496 | dependencies: 497 | wrappy: 1.0.2 498 | dev: true 499 | 500 | /optionator@0.9.3: 501 | resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==} 502 | engines: {node: '>= 0.8.0'} 503 | dependencies: 504 | '@aashutoshrathi/word-wrap': 1.2.6 505 | deep-is: 0.1.4 506 | fast-levenshtein: 2.0.6 507 | levn: 0.4.1 508 | prelude-ls: 1.2.1 509 | type-check: 0.4.0 510 | dev: true 511 | 512 | /p-limit@3.1.0: 513 | resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} 514 | engines: {node: '>=10'} 515 | dependencies: 516 | yocto-queue: 0.1.0 517 | dev: true 518 | 519 | /p-locate@5.0.0: 520 | resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} 521 | engines: {node: '>=10'} 522 | dependencies: 523 | p-limit: 3.1.0 524 | dev: true 525 | 526 | /parent-module@1.0.1: 527 | resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} 528 | engines: {node: '>=6'} 529 | dependencies: 530 | callsites: 3.1.0 531 | dev: true 532 | 533 | /path-exists@4.0.0: 534 | resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} 535 | engines: {node: '>=8'} 536 | dev: true 537 | 538 | /path-is-absolute@1.0.1: 539 | resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} 540 | engines: {node: '>=0.10.0'} 541 | dev: true 542 | 543 | /path-key@3.1.1: 544 | resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} 545 | engines: {node: '>=8'} 546 | dev: true 547 | 548 | /prelude-ls@1.2.1: 549 | resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} 550 | engines: {node: '>= 0.8.0'} 551 | dev: true 552 | 553 | /punycode@2.3.0: 554 | resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} 555 | engines: {node: '>=6'} 556 | dev: true 557 | 558 | /queue-microtask@1.2.3: 559 | resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} 560 | dev: true 561 | 562 | /resolve-from@4.0.0: 563 | resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} 564 | engines: {node: '>=4'} 565 | dev: true 566 | 567 | /reusify@1.0.4: 568 | resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} 569 | engines: {iojs: '>=1.0.0', node: '>=0.10.0'} 570 | dev: true 571 | 572 | /rimraf@3.0.2: 573 | resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} 574 | hasBin: true 575 | dependencies: 576 | glob: 7.2.3 577 | dev: true 578 | 579 | /run-parallel@1.2.0: 580 | resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} 581 | dependencies: 582 | queue-microtask: 1.2.3 583 | dev: true 584 | 585 | /shebang-command@2.0.0: 586 | resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} 587 | engines: {node: '>=8'} 588 | dependencies: 589 | shebang-regex: 3.0.0 590 | dev: true 591 | 592 | /shebang-regex@3.0.0: 593 | resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} 594 | engines: {node: '>=8'} 595 | dev: true 596 | 597 | /strip-ansi@6.0.1: 598 | resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} 599 | engines: {node: '>=8'} 600 | dependencies: 601 | ansi-regex: 5.0.1 602 | dev: true 603 | 604 | /strip-json-comments@3.1.1: 605 | resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} 606 | engines: {node: '>=8'} 607 | dev: true 608 | 609 | /supports-color@7.2.0: 610 | resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} 611 | engines: {node: '>=8'} 612 | dependencies: 613 | has-flag: 4.0.0 614 | dev: true 615 | 616 | /text-table@0.2.0: 617 | resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} 618 | dev: true 619 | 620 | /type-check@0.4.0: 621 | resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} 622 | engines: {node: '>= 0.8.0'} 623 | dependencies: 624 | prelude-ls: 1.2.1 625 | dev: true 626 | 627 | /type-fest@0.20.2: 628 | resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} 629 | engines: {node: '>=10'} 630 | dev: true 631 | 632 | /uri-js@4.4.1: 633 | resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} 634 | dependencies: 635 | punycode: 2.3.0 636 | dev: true 637 | 638 | /which@2.0.2: 639 | resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} 640 | engines: {node: '>= 8'} 641 | hasBin: true 642 | dependencies: 643 | isexe: 2.0.0 644 | dev: true 645 | 646 | /wrappy@1.0.2: 647 | resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} 648 | dev: true 649 | 650 | /yocto-queue@0.1.0: 651 | resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} 652 | engines: {node: '>=10'} 653 | dev: true 654 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # POSTMAN TO TYPESCRIPT 2 | 3 | A simple tool built on top of nodejs that scans for all the content of a postman json document and creates interface according to 4 | the examples response output, url request query params and url request query body 5 | 6 | ## Too bored to read ? 7 | I got you covered 😉 8 | 9 | https://github.com/n1rjal/postman-to-typescript/assets/60036262/a1443a38-b0f3-4164-9282-a27756c108f2 10 | 11 | 12 | 13 | ## How to use 14 | 15 | First of all, you'll either need to 16 | - export the postman collection [Learn more about it here](https://learning.postman.com/docs/getting-started/importing-and-exporting-data/#exporting-collections), or, 17 | - use remote postman collection, for which you need to have a postman API key and a remote postman collection. 18 | - To generate your own API key, check [docs](https://learning.postman.com/docs/developer/postman-api/authentication/#generate-a-postman-api-key). 19 | - To get a remote postman collection, you can either make your workspace [public](https://learning.postman.com/docs/collaborating-in-postman/using-workspaces/public-workspaces/) and access your collection remotely, or [explore](https://www.postman.com/explore) public API network. 20 | A collection url is in the format of `https://www.postman.com//workspace//collection/`. 21 | 22 | Then, 23 | 1. Download node version >=16 24 | 2. Git clone the repo: 25 | 26 | ```bash 27 | git clone https://github.com/n1rjal/postman-to-typescript.git 28 | ``` 29 | 30 | 3. Change the config file `eator.json` accordingly or you can use the sample type here. The config and index.js file must be in same directory 31 | 32 | ```bash 33 | node index.js 34 | ``` 35 | 36 | ## Use npx 37 | 38 | ```bash 39 | npx @n1rjal/pm_ts -i cit-input.json -o types # using input file 40 | npx @n1rjal/pm_ts -X YOUR_API_KEY -U REMOTE_POSTMAN_COLLECTION_URL -o types # using remote postman collection 41 | ``` 42 | 43 | ## Command-line Arguments 44 | 45 | The script file is most stable for -i and -o flags. Other files may bring unwanted results. And postman form data can perform errors. 46 | `pm_ts` supports the following command-line arguments: 47 | 48 | | Argument | Description | 49 | | ------------------- | ------------------------------------------------------------------------------------------------------------------- | 50 | | -i, --input | The export of postman data as json v2.0 | 51 | | -X, --api-key | This specifies your postman API key | 52 | | -U, --collection-url| This specifies the remote postman collection url | 53 | | -o, --output | The output directory for all types | 54 | | -ia, --include-any | This specifies if any must be included in typescript types or not. Default value is false | 55 | | -sc, --status-codes | This specifies if we can add type support for response of the types provided. Default value is 200[comma separated] | 56 | | -ft, --force-text | This specifies if we need to parse text content in postman request or not. Default value is false | 57 | | -te, --throw-error | This specifies if the program should throw an error | 58 | | -p, --prefix | This specifies if the output files need prefix | 59 | 60 | You can use these arguments when running the script or program to provide additional options or information. 61 | 62 | ## After successful execution 63 | 64 | On local run, before your folder structure, should look like this 65 | 66 | ```bash 67 | . 68 | ├── eater.json 69 | ├── index.js 70 | ├── readme.md 71 | ├── sample.json 72 | └── types 73 | 74 | 75 | ``` 76 | 77 | ## Interface 78 | 79 | Every interface here will have the following format 80 | 81 | ```typescript 82 | /* 83 | Get all requests from one time to another 84 | GET: {{host}}/report/time-stamps?startDate=05-22-2021&endDate=07-30-2021 85 | */ 86 | export interface GetAllRequestsFromOneTimeToAnother { 87 | startDate: string; 88 | endDate: string; 89 | } 90 | ``` 91 | 92 | ## Option Flag 93 | 94 | The option flags, we have for the command are listed below 95 | 96 | This will prompt you for some basic information about your project, such as the project name and the package manager you want to use (`npm` or `yarn`). After providing the required information, `pm_ts` will set up a new TypeScript project for you with the selected package manager. 97 | 98 | ## Contributing 99 | 100 | Please see [CONTRIBUTING.md](https://github.com/bigyanse/postman-to-typescript/blob/main/CONTRIBUTING.md) for contributing guide. 101 | 102 | ## License 103 | 104 | This project is licensed under the [MIT License](LICENSE). 105 | 106 | Use this table as a quick reference for understanding the purpose of each field in the configuration file. 107 | 108 | ## Warning 109 | 110 | Note that this project is still in beta stage and might return files with undefined in it every here and there. So feel free to create issues and contribute the project as necessary 111 | -------------------------------------------------------------------------------- /static/pm_ts.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n1rjal/postman-to-typescript/4b56341fc27393518a76bb13b9ed70f1d0d7df32/static/pm_ts.mp4 -------------------------------------------------------------------------------- /static/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "item": [ 3 | { 4 | "name": "User", 5 | "item": [ 6 | { 7 | "name": "Create a User", 8 | "event": [ 9 | { 10 | "listen": "test", 11 | "script": { 12 | "exec": [ 13 | "pm.test(\"Status code is 400\", function () {\r", 14 | " pm.response.to.have.status(400);\r", 15 | "});\r", 16 | "pm.test(\"Status code is 200 [ MOSTLY FAILS ]\", function () {\r", 17 | " pm.response.to.have.status(200);\r", 18 | " //only for signup users\r", 19 | "});\r", 20 | "\r", 21 | "pm.test(\"User name passed\", function () {\r", 22 | " pm.expect(pm.response.text()).to.include(\"name\");\r", 23 | "});\r", 24 | "pm.test(\"Phone no is passed\", function () {\r", 25 | " pm.expect(pm.response.text()).to.include(\"phone\");\r", 26 | "});\r", 27 | "\r", 28 | "" 29 | ], 30 | "type": "text/javascript" 31 | } 32 | } 33 | ], 34 | "request": { 35 | "auth": { 36 | "type": "noauth" 37 | }, 38 | "method": "POST", 39 | "header": [], 40 | "body": { 41 | "mode": "formdata", 42 | "formdata": [ 43 | { 44 | "key": "profile_picture", 45 | "description": "provide profile pictyre as a file", 46 | "type": "file", 47 | "src": [] 48 | }, 49 | { 50 | "key": "email", 51 | "value": "testuser2@gmail.com", 52 | "description": "unique", 53 | "type": "text" 54 | }, 55 | { 56 | "key": "name", 57 | "value": "Test User Part2", 58 | "type": "text" 59 | }, 60 | { 61 | "key": "bio", 62 | "value": "Biology", 63 | "description": "Bio", 64 | "type": "text" 65 | }, 66 | { 67 | "key": "password1", 68 | "value": "test12345", 69 | "description": "password", 70 | "type": "text" 71 | }, 72 | { 73 | "key": "password2", 74 | "value": "test12345", 75 | "type": "text" 76 | }, 77 | { 78 | "key": "phone", 79 | "value": "+977 123456789", 80 | "description": "unique", 81 | "type": "text" 82 | } 83 | ] 84 | }, 85 | "url": "{{host}}/user/signup" 86 | }, 87 | "response": [ 88 | { 89 | "name": "User Created Successfully", 90 | "originalRequest": { 91 | "method": "POST", 92 | "header": [], 93 | "body": { 94 | "mode": "formdata", 95 | "formdata": [ 96 | { 97 | "key": "profile_picture", 98 | "description": "provide profile pictyre as a file", 99 | "type": "file", 100 | "src": "/C:/Users/alphawolfnirjal/Pictures/71SnRYHv-CL._AC_SY450_.jpg" 101 | }, 102 | { 103 | "key": "email", 104 | "value": "testuser@gmail.com", 105 | "description": "unique", 106 | "type": "text" 107 | }, 108 | { 109 | "key": "name", 110 | "value": "Test User", 111 | "type": "text" 112 | }, 113 | { 114 | "key": "bio", 115 | "value": "Biology", 116 | "description": "Bio", 117 | "type": "text" 118 | }, 119 | { 120 | "key": "password1", 121 | "value": "test12345", 122 | "description": "password", 123 | "type": "text" 124 | }, 125 | { 126 | "key": "password2", 127 | "value": "test12345", 128 | "type": "text" 129 | }, 130 | { 131 | "key": "phone", 132 | "value": "123456789", 133 | "description": "unique", 134 | "type": "text" 135 | } 136 | ] 137 | }, 138 | "url": "localhost:3000/user/signup" 139 | }, 140 | "status": "OK", 141 | "code": 200, 142 | "_postman_previewlanguage": "json", 143 | "header": [ 144 | { 145 | "key": "X-Powered-By", 146 | "value": "Express" 147 | }, 148 | { 149 | "key": "Content-Type", 150 | "value": "application/json; charset=utf-8" 151 | }, 152 | { 153 | "key": "Content-Length", 154 | "value": "295" 155 | }, 156 | { 157 | "key": "ETag", 158 | "value": "W/\"127-Mi5t6apk+k361vlEabpDeahVFS4\"" 159 | }, 160 | { 161 | "key": "Date", 162 | "value": "Sun, 11 Apr 2021 10:51:55 GMT" 163 | }, 164 | { 165 | "key": "Connection", 166 | "value": "keep-alive" 167 | }, 168 | { 169 | "key": "Keep-Alive", 170 | "value": "timeout=5" 171 | } 172 | ], 173 | "cookie": [], 174 | "body": "{\n \"is_admin\": false,\n \"_id\": \"6072d4cb73d73e2064cb4c92\",\n \"email\": \"testuser@gmail.com\",\n \"name\": \"Test User\",\n \"bio\": \"Biology\",\n \"phone\": \"123456789\",\n \"password\": \"$2b$10$q/MPDd2tpFk5Zygc3fqIxeem1vBkVV9b7jHhq00XKB.HzJefLB4b6\",\n \"profile_picture\": \"\\\\public\\\\pp\\\\1618138304860 -- 71SnRYHv-CL._AC_SY450_.jpg\",\n \"__v\": 0\n}" 175 | }, 176 | { 177 | "name": "Error in use creation", 178 | "originalRequest": { 179 | "method": "POST", 180 | "header": [], 181 | "body": { 182 | "mode": "formdata", 183 | "formdata": [ 184 | { 185 | "key": "profile_picture", 186 | "description": "provide profile pictyre as a file", 187 | "type": "file", 188 | "src": "/C:/Users/alphawolfnirjal/Pictures/71SnRYHv-CL._AC_SY450_.jpg" 189 | }, 190 | { 191 | "key": "email", 192 | "value": "testuser@gmail.com", 193 | "description": "unique", 194 | "type": "text" 195 | }, 196 | { 197 | "key": "name", 198 | "value": "Test User", 199 | "type": "text" 200 | }, 201 | { 202 | "key": "bio", 203 | "value": "Biology", 204 | "description": "Bio", 205 | "type": "text" 206 | }, 207 | { 208 | "key": "password1", 209 | "value": "test12345", 210 | "description": "password", 211 | "type": "text" 212 | }, 213 | { 214 | "key": "password2", 215 | "value": "test12345", 216 | "type": "text" 217 | }, 218 | { 219 | "key": "phone", 220 | "value": "123456789", 221 | "description": "unique", 222 | "type": "text" 223 | } 224 | ] 225 | }, 226 | "url": "localhost:3000/user/signup" 227 | }, 228 | "status": "Bad Request", 229 | "code": 400, 230 | "_postman_previewlanguage": "json", 231 | "header": [ 232 | { 233 | "key": "X-Powered-By", 234 | "value": "Express" 235 | }, 236 | { 237 | "key": "Content-Type", 238 | "value": "application/json; charset=utf-8" 239 | }, 240 | { 241 | "key": "Content-Length", 242 | "value": "248" 243 | }, 244 | { 245 | "key": "ETag", 246 | "value": "W/\"f8-vyFTPBV4EdGt7qXFwr4HMZa9ILY\"" 247 | }, 248 | { 249 | "key": "Date", 250 | "value": "Sun, 11 Apr 2021 10:52:16 GMT" 251 | }, 252 | { 253 | "key": "Connection", 254 | "value": "keep-alive" 255 | }, 256 | { 257 | "key": "Keep-Alive", 258 | "value": "timeout=5" 259 | } 260 | ], 261 | "cookie": [], 262 | "body": "{\n \"errors\": [\n {\n \"msg\": \"Invalid value(s)\",\n \"param\": \"_error\",\n \"nestedErrors\": [\n {\n \"value\": \"testuser@gmail.com\",\n \"msg\": \"Email already used\",\n \"param\": \"email\",\n \"location\": \"body\"\n },\n {\n \"value\": \"123456789\",\n \"msg\": \"Phone already used\",\n \"param\": \"phone\",\n \"location\": \"body\"\n }\n ]\n }\n ]\n}" 263 | } 264 | ] 265 | }, 266 | { 267 | "name": "Update User", 268 | "event": [ 269 | { 270 | "listen": "test", 271 | "script": { 272 | "exec": [ 273 | "pm.test(\"Response time is less than 1s\", function () {\r", 274 | " pm.expect(pm.response.responseTime).to.be.below(1000);\r", 275 | "});\r", 276 | "\r", 277 | "pm.test(\"Status code is 200\", function () {\r", 278 | " pm.response.to.have.status(200);\r", 279 | "});\r", 280 | "\r", 281 | "pm.test(\"Body have _id\", function () {\r", 282 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 283 | "});\r", 284 | "\r", 285 | "pm.test(\"Email field is there\", function () {\r", 286 | " pm.expect(pm.response.text()).to.include(\"email\");\r", 287 | "});\r", 288 | "\r", 289 | "pm.test(\"Phone field is there\", function () {\r", 290 | " pm.expect(pm.response.text()).to.include(\"phone\");\r", 291 | "});\r", 292 | "\r", 293 | "" 294 | ], 295 | "type": "text/javascript" 296 | } 297 | } 298 | ], 299 | "request": { 300 | "method": "PUT", 301 | "header": [], 302 | "body": { 303 | "mode": "formdata", 304 | "formdata": [ 305 | { 306 | "key": "profile_picture", 307 | "type": "file", 308 | "src": "/C:/Users/alphawolfnirjal/Downloads/608903eb190fa608902390e2 (4).jpg", 309 | "disabled": true 310 | }, 311 | { 312 | "key": "bio", 313 | "value": "I am white lartern. Green latern is fake. White rocks", 314 | "type": "text" 315 | }, 316 | { 317 | "key": "name", 318 | "value": "TeSt UsEr 12", 319 | "type": "text" 320 | } 321 | ] 322 | }, 323 | "url": "{{host}}/user/update" 324 | }, 325 | "response": [ 326 | { 327 | "name": "Token user not foun", 328 | "originalRequest": { 329 | "method": "PUT", 330 | "header": [ 331 | { 332 | "key": "Authorization", 333 | "value": "{{JWT}}", 334 | "type": "text" 335 | } 336 | ], 337 | "body": { 338 | "mode": "formdata", 339 | "formdata": [ 340 | { 341 | "key": "profile_picture", 342 | "type": "file", 343 | "src": "/C:/Users/alphawolfnirjal/Pictures/Camera Roll/WIN_20200915_16_05_42_Pro.jpg" 344 | }, 345 | { 346 | "key": "is_admin", 347 | "value": "true", 348 | "type": "text" 349 | } 350 | ], 351 | "options": { 352 | "raw": { 353 | "language": "json" 354 | } 355 | } 356 | }, 357 | "url": "localhost:3000/user/update" 358 | }, 359 | "status": "Not Found", 360 | "code": 404, 361 | "_postman_previewlanguage": "json", 362 | "header": [ 363 | { 364 | "key": "X-Powered-By", 365 | "value": "Express" 366 | }, 367 | { 368 | "key": "Content-Type", 369 | "value": "application/json; charset=utf-8" 370 | }, 371 | { 372 | "key": "Content-Length", 373 | "value": "40" 374 | }, 375 | { 376 | "key": "ETag", 377 | "value": "W/\"28-QiyClkJvdD37yHHK/W0MkrUbuc0\"" 378 | }, 379 | { 380 | "key": "Date", 381 | "value": "Sun, 11 Apr 2021 10:56:46 GMT" 382 | }, 383 | { 384 | "key": "Connection", 385 | "value": "keep-alive" 386 | }, 387 | { 388 | "key": "Keep-Alive", 389 | "value": "timeout=5" 390 | } 391 | ], 392 | "cookie": [], 393 | "body": "{\n \"error\": \"User by this token not found\"\n}" 394 | }, 395 | { 396 | "name": "Successfully updated", 397 | "originalRequest": { 398 | "method": "PUT", 399 | "header": [ 400 | { 401 | "key": "Authorization", 402 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDcyZDRjYjczZDczZTIwNjRjYjRjOTIiLCJpYXQiOjE2MTgxMzg0MzUsImV4cCI6MTYxODE0OTIzNX0.QZ6-f7vKD99j9sVEOutNksNkr22pgkWIbn_TVbl4qLo", 403 | "description": "TOken can be found in update", 404 | "type": "text" 405 | } 406 | ], 407 | "body": { 408 | "mode": "formdata", 409 | "formdata": [ 410 | { 411 | "key": "profile_picture", 412 | "type": "file", 413 | "src": "/C:/Users/alphawolfnirjal/Pictures/Camera Roll/WIN_20200915_16_05_42_Pro.jpg" 414 | }, 415 | { 416 | "key": "is_admin", 417 | "value": "true", 418 | "type": "text" 419 | } 420 | ], 421 | "options": { 422 | "raw": { 423 | "language": "json" 424 | } 425 | } 426 | }, 427 | "url": "localhost:3000/user/update" 428 | }, 429 | "status": "OK", 430 | "code": 200, 431 | "_postman_previewlanguage": "json", 432 | "header": [ 433 | { 434 | "key": "X-Powered-By", 435 | "value": "Express" 436 | }, 437 | { 438 | "key": "Content-Type", 439 | "value": "application/json; charset=utf-8" 440 | }, 441 | { 442 | "key": "Content-Length", 443 | "value": "297" 444 | }, 445 | { 446 | "key": "ETag", 447 | "value": "W/\"129-KGSvldWs1grS0AxxroLBhWSdhhw\"" 448 | }, 449 | { 450 | "key": "Date", 451 | "value": "Sun, 11 Apr 2021 10:58:18 GMT" 452 | }, 453 | { 454 | "key": "Connection", 455 | "value": "keep-alive" 456 | }, 457 | { 458 | "key": "Keep-Alive", 459 | "value": "timeout=5" 460 | } 461 | ], 462 | "cookie": [], 463 | "body": "{\n \"is_admin\": true,\n \"_id\": \"6072d4cb73d73e2064cb4c92\",\n \"email\": \"testuser@gmail.com\",\n \"name\": \"Test User\",\n \"bio\": \"Biology\",\n \"phone\": \"123456789\",\n \"password\": \"$2b$10$q/MPDd2tpFk5Zygc3fqIxeem1vBkVV9b7jHhq00XKB.HzJefLB4b6\",\n \"profile_picture\": \"\\\\public\\\\pp\\\\1618138698296 -- WIN_20200915_16_05_42_Pro.jpg\",\n \"__v\": 0\n}" 464 | } 465 | ] 466 | }, 467 | { 468 | "name": "Delete User", 469 | "event": [ 470 | { 471 | "listen": "test", 472 | "script": { 473 | "exec": [ 474 | "pm.test(\"Status code is 200\", function () {\r", 475 | " pm.response.to.have.status(200);\r", 476 | "});" 477 | ], 478 | "type": "text/javascript" 479 | } 480 | } 481 | ], 482 | "request": { 483 | "method": "DELETE", 484 | "header": [], 485 | "url": "{{host}}/user/delete" 486 | }, 487 | "response": [ 488 | { 489 | "name": "Successful deletion", 490 | "originalRequest": { 491 | "method": "DELETE", 492 | "header": [ 493 | { 494 | "key": "Authorization", 495 | "value": "{{JWT}}", 496 | "type": "text" 497 | } 498 | ], 499 | "url": "localhost:3000/user/delete" 500 | }, 501 | "status": "OK", 502 | "code": 200, 503 | "_postman_previewlanguage": "json", 504 | "header": [ 505 | { 506 | "key": "X-Powered-By", 507 | "value": "Express" 508 | }, 509 | { 510 | "key": "Content-Type", 511 | "value": "application/json; charset=utf-8" 512 | }, 513 | { 514 | "key": "Content-Length", 515 | "value": "297" 516 | }, 517 | { 518 | "key": "ETag", 519 | "value": "W/\"129-KGSvldWs1grS0AxxroLBhWSdhhw\"" 520 | }, 521 | { 522 | "key": "Date", 523 | "value": "Sun, 11 Apr 2021 11:04:06 GMT" 524 | }, 525 | { 526 | "key": "Connection", 527 | "value": "keep-alive" 528 | }, 529 | { 530 | "key": "Keep-Alive", 531 | "value": "timeout=5" 532 | } 533 | ], 534 | "cookie": [], 535 | "body": "{\n \"is_admin\": true,\n \"_id\": \"6072d4cb73d73e2064cb4c92\",\n \"email\": \"testuser@gmail.com\",\n \"name\": \"Test User\",\n \"bio\": \"Biology\",\n \"phone\": \"123456789\",\n \"password\": \"$2b$10$q/MPDd2tpFk5Zygc3fqIxeem1vBkVV9b7jHhq00XKB.HzJefLB4b6\",\n \"profile_picture\": \"\\\\public\\\\pp\\\\1618138698296 -- WIN_20200915_16_05_42_Pro.jpg\",\n \"__v\": 0\n}" 536 | } 537 | ] 538 | }, 539 | { 540 | "name": "Get new access token using refresh token", 541 | "event": [ 542 | { 543 | "listen": "test", 544 | "script": { 545 | "exec": [ 546 | "pm.test(\"Response time is less than 200ms\", function () {\r", 547 | " pm.expect(pm.response.responseTime).to.be.below(200);\r", 548 | "});" 549 | ], 550 | "type": "text/javascript" 551 | } 552 | } 553 | ], 554 | "request": { 555 | "auth": { 556 | "type": "noauth" 557 | }, 558 | "method": "POST", 559 | "header": [ 560 | { 561 | "key": "Authorization", 562 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDc4MWI4ZDhjMzQyYTIwOGM5NzQxMDUiLCJpYXQiOjE2MTg0ODQxNTMsImV4cCI6MTYxODQ4Nzc1M30.FdsS_nsUehPNgaUJyKURRbSR44c66gMg10Ch78KaO9g", 563 | "type": "text", 564 | "disabled": true 565 | } 566 | ], 567 | "body": { 568 | "mode": "raw", 569 | "raw": "{\r\n \"token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDg5MDNlYjE5MGZhNjA4OTAyMzkwZTIiLCJpYXQiOjE2MjU3NDg5MTEsImV4cCI6MTYyODM0MDkxMX0.xi97e313_5JOw-3cUFZUOU5JMxwhbj1SATDMrq3Qf3Q\"\r\n}", 570 | "options": { 571 | "raw": { 572 | "language": "json" 573 | } 574 | } 575 | }, 576 | "url": "{{host}}/user/token-refresh", 577 | "description": "# Refresh your token here\nGet new access token using a refresh token" 578 | }, 579 | "response": [ 580 | { 581 | "name": "Get new access token using refresh token", 582 | "originalRequest": { 583 | "method": "POST", 584 | "header": [ 585 | { 586 | "key": "Authorization", 587 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDc4MWI4ZDhjMzQyYTIwOGM5NzQxMDUiLCJpYXQiOjE2MTg0ODQxNTMsImV4cCI6MTYxODQ4Nzc1M30.FdsS_nsUehPNgaUJyKURRbSR44c66gMg10Ch78KaO9g", 588 | "type": "text", 589 | "disabled": true 590 | } 591 | ], 592 | "body": { 593 | "mode": "raw", 594 | "raw": "{\r\n \"token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDc4MWI4ZDhjMzQyYTIwOGM5NzQxMDUiLCJpYXQiOjE2MTg0ODQxNTMsImV4cCI6MTYxODUyMDE1M30.bnaUdEJJGgyjcYHO_sFD0JkMS5TmFXYBrOm1amm2Nyo\"\r\n}", 595 | "options": { 596 | "raw": { 597 | "language": "json" 598 | } 599 | } 600 | }, 601 | "url": "localhost:3000/user/token-refresh" 602 | }, 603 | "status": "OK", 604 | "code": 200, 605 | "_postman_previewlanguage": "json", 606 | "header": [ 607 | { 608 | "key": "X-Powered-By", 609 | "value": "Express" 610 | }, 611 | { 612 | "key": "Content-Type", 613 | "value": "application/json; charset=utf-8" 614 | }, 615 | { 616 | "key": "Content-Length", 617 | "value": "190" 618 | }, 619 | { 620 | "key": "ETag", 621 | "value": "W/\"be-jN4UTt/jN+zCSHz+fDKWaX5NMKg\"" 622 | }, 623 | { 624 | "key": "Date", 625 | "value": "Thu, 15 Apr 2021 14:18:39 GMT" 626 | }, 627 | { 628 | "key": "Connection", 629 | "value": "keep-alive" 630 | }, 631 | { 632 | "key": "Keep-Alive", 633 | "value": "timeout=5" 634 | } 635 | ], 636 | "cookie": [], 637 | "body": "{\n \"accessToken\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDc4MWI4ZDhjMzQyYTIwOGM5NzQxMDUiLCJpYXQiOjE2MTg0OTYzMTksImV4cCI6MTYxODQ5OTkxOX0.wOSwyFTTyGa3_jDyHexoB8eTY8GkVFPpohQBu8VZ7kI\"\n}" 638 | } 639 | ] 640 | }, 641 | { 642 | "name": "Sigin User", 643 | "event": [ 644 | { 645 | "listen": "test", 646 | "script": { 647 | "exec": [ 648 | "pm.test(\"Status code is 200\", function () {\r", 649 | " pm.response.to.have.status(200);\r", 650 | "});\r", 651 | "\r", 652 | "pm.test(\"Body have token\", function () {\r", 653 | " pm.expect(pm.response.text()).to.include(\"token\");\r", 654 | "});\r", 655 | "\r", 656 | "pm.test(\"Body have _id\", function () {\r", 657 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 658 | "});\r", 659 | "\r", 660 | "pm.test(\"Body have phone\", function () {\r", 661 | " pm.expect(pm.response.text()).to.include(\"phone\");\r", 662 | "});\r", 663 | "\r", 664 | "pm.test(\"Body have email\", function () {\r", 665 | " pm.expect(pm.response.text()).to.include(\"email\");\r", 666 | "});\r", 667 | "\r", 668 | "pm.test(\"Response time is less than 1s\", function () {\r", 669 | " pm.expect(pm.response.responseTime).to.be.below(1000);\r", 670 | "});\r", 671 | "" 672 | ], 673 | "type": "text/javascript" 674 | } 675 | } 676 | ], 677 | "request": { 678 | "auth": { 679 | "type": "noauth" 680 | }, 681 | "method": "POST", 682 | "header": [ 683 | { 684 | "key": "", 685 | "value": "", 686 | "type": "text", 687 | "disabled": true 688 | } 689 | ], 690 | "body": { 691 | "mode": "raw", 692 | "raw": "{\r\n \"email\": \"testuser@gmail.com\",\r\n \"password\":\"test12345\"\r\n}", 693 | "options": { 694 | "raw": { 695 | "language": "json" 696 | } 697 | } 698 | }, 699 | "url": "{{host}}/user/signin", 700 | "description": "# Note\nBoth access and refresh tokens can be found from here" 701 | }, 702 | "response": [ 703 | { 704 | "name": "Successfully signed", 705 | "originalRequest": { 706 | "method": "POST", 707 | "header": [ 708 | { 709 | "key": "", 710 | "value": "", 711 | "type": "text" 712 | } 713 | ], 714 | "body": { 715 | "mode": "raw", 716 | "raw": "{\r\n \"email\": \"testuser@gmail.com\",\r\n \"password\":\"test12345\"\r\n}", 717 | "options": { 718 | "raw": { 719 | "language": "json" 720 | } 721 | } 722 | }, 723 | "url": "localhost:3000/user/signin" 724 | }, 725 | "status": "OK", 726 | "code": 200, 727 | "_postman_previewlanguage": "json", 728 | "header": [ 729 | { 730 | "key": "X-Powered-By", 731 | "value": "Express" 732 | }, 733 | { 734 | "key": "Content-Type", 735 | "value": "application/json; charset=utf-8" 736 | }, 737 | { 738 | "key": "Content-Length", 739 | "value": "233" 740 | }, 741 | { 742 | "key": "ETag", 743 | "value": "W/\"e9-tTlkWD3oahwHhDg6Jh39URJMeVE\"" 744 | }, 745 | { 746 | "key": "Date", 747 | "value": "Sun, 11 Apr 2021 10:53:55 GMT" 748 | }, 749 | { 750 | "key": "Connection", 751 | "value": "keep-alive" 752 | }, 753 | { 754 | "key": "Keep-Alive", 755 | "value": "timeout=5" 756 | } 757 | ], 758 | "cookie": [], 759 | "body": "{\n \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDcyZDRjYjczZDczZTIwNjRjYjRjOTIiLCJpYXQiOjE2MTgxMzg0MzUsImV4cCI6MTYxODE0OTIzNX0.QZ6-f7vKD99j9sVEOutNksNkr22pgkWIbn_TVbl4qLo\",\n \"email\": \"testuser@gmail.com\",\n \"phone\": \"123456789\"\n}" 760 | }, 761 | { 762 | "name": "Sigin Failure", 763 | "originalRequest": { 764 | "method": "POST", 765 | "header": [ 766 | { 767 | "key": "", 768 | "value": "", 769 | "type": "text" 770 | } 771 | ], 772 | "body": { 773 | "mode": "raw", 774 | "raw": "{\r\n \"email\": \"testuser@gmail.com\",\r\n \"password\":\"test1234as5\"\r\n}", 775 | "options": { 776 | "raw": { 777 | "language": "json" 778 | } 779 | } 780 | }, 781 | "url": "localhost:3000/user/signin" 782 | }, 783 | "status": "Bad Request", 784 | "code": 400, 785 | "_postman_previewlanguage": "json", 786 | "header": [ 787 | { 788 | "key": "X-Powered-By", 789 | "value": "Express" 790 | }, 791 | { 792 | "key": "Content-Type", 793 | "value": "application/json; charset=utf-8" 794 | }, 795 | { 796 | "key": "Content-Length", 797 | "value": "46" 798 | }, 799 | { 800 | "key": "ETag", 801 | "value": "W/\"2e-hnCNHJQ75HzCGMdPaHBDCT0XAzo\"" 802 | }, 803 | { 804 | "key": "Date", 805 | "value": "Sun, 11 Apr 2021 10:55:10 GMT" 806 | }, 807 | { 808 | "key": "Connection", 809 | "value": "keep-alive" 810 | }, 811 | { 812 | "key": "Keep-Alive", 813 | "value": "timeout=5" 814 | } 815 | ], 816 | "cookie": [], 817 | "body": "{\n \"error\": \"Username or password doesnot match\"\n}" 818 | } 819 | ] 820 | }, 821 | { 822 | "name": "Follow someone", 823 | "event": [ 824 | { 825 | "listen": "test", 826 | "script": { 827 | "exec": [ 828 | "pm.test(\"Status code is 200\", function () {\r", 829 | " pm.response.to.have.status(200);\r", 830 | "});\r", 831 | "pm.test(\"status valid check\", function () {\r", 832 | " pm.expect(pm.response.text()).to.include(\"ok\");\r", 833 | "});" 834 | ], 835 | "type": "text/javascript" 836 | } 837 | } 838 | ], 839 | "request": { 840 | "method": "POST", 841 | "header": [], 842 | "url": { 843 | "raw": "{{host}}/user/friendship/:userId/follow", 844 | "host": ["{{host}}"], 845 | "path": ["user", "friendship", ":userId", "follow"], 846 | "variable": [ 847 | { 848 | "key": "userId", 849 | "value": "60ab66259b15db3d5716e0dd" 850 | } 851 | ] 852 | } 853 | }, 854 | "response": [] 855 | }, 856 | { 857 | "name": "unfollow someone", 858 | "event": [ 859 | { 860 | "listen": "test", 861 | "script": { 862 | "exec": [ 863 | "pm.test(\"Status code is 200\", function () {\r", 864 | " pm.response.to.have.status(200);\r", 865 | "});\r", 866 | "pm.test(\"status valid check\", function () {\r", 867 | " pm.expect(pm.response.text()).to.include(\"ok\");\r", 868 | "});\r", 869 | "" 870 | ], 871 | "type": "text/javascript" 872 | } 873 | } 874 | ], 875 | "request": { 876 | "method": "POST", 877 | "header": [], 878 | "url": { 879 | "raw": "{{host}}/user/friendship/:userID/unfollow", 880 | "host": ["{{host}}"], 881 | "path": ["user", "friendship", ":userID", "unfollow"], 882 | "variable": [ 883 | { 884 | "key": "userID", 885 | "value": "60ab66259b15db3d5716e0dd" 886 | } 887 | ] 888 | } 889 | }, 890 | "response": [] 891 | }, 892 | { 893 | "name": "Search a user", 894 | "event": [ 895 | { 896 | "listen": "test", 897 | "script": { 898 | "exec": [ 899 | "pm.test(\"Have status 200\",function(){\r", 900 | " pm.response.to.have.status(200)\r", 901 | "})" 902 | ], 903 | "type": "text/javascript" 904 | } 905 | } 906 | ], 907 | "request": { 908 | "method": "GET", 909 | "header": [], 910 | "url": { 911 | "raw": "{{host}}/user/search?name=60ab66259b15db3d5716e0dd&ulimit=2&uskip=0", 912 | "host": ["{{host}}"], 913 | "path": ["user", "search"], 914 | "query": [ 915 | { 916 | "key": "name", 917 | "value": "60ab66259b15db3d5716e0dd" 918 | }, 919 | { 920 | "key": "ulimit", 921 | "value": "2" 922 | }, 923 | { 924 | "key": "uskip", 925 | "value": "0" 926 | } 927 | ] 928 | }, 929 | "description": "## All query parameters\n|key | value |Default Value | \n|----------|---------|------|\n| ulimit | Number of posts in the response |10|\n| uskip | Skip the number of post specified |0|\n| sort_by | Specify the field you want to sort by |name|\n| order | ASC for ASCENDING any other value means DESCENDING |DESCENDING SORT|" 930 | }, 931 | "response": [] 932 | }, 933 | { 934 | "name": "Get a user profile", 935 | "event": [ 936 | { 937 | "listen": "test", 938 | "script": { 939 | "exec": [ 940 | "pm.test(\"Lets test response time\",()=>{\r", 941 | " pm.expect( pm.response.responseTime ).to.be.below(2000)\r", 942 | "})" 943 | ], 944 | "type": "text/javascript" 945 | } 946 | } 947 | ], 948 | "request": { 949 | "method": "GET", 950 | "header": [], 951 | "url": { 952 | "raw": "{{host}}/user/:userid/profile", 953 | "host": ["{{host}}"], 954 | "path": ["user", ":userid", "profile"], 955 | "variable": [ 956 | { 957 | "key": "userid", 958 | "value": "608ed6155e3e994e00ef15e0", 959 | "description": "_id value of user ou want to get profile of" 960 | } 961 | ] 962 | }, 963 | "description": "Request URL \n> {{host}}/user/:user_id/profile\n\nRequest Parameters\n\n|key|value|default|\n|-------|------|------|\n| followings_limit | Number | 20 |\n| followings_skip | Number | 0 |\n| followers_limit | Number | 20 |\n| followers_skip | Number | 0 |" 964 | }, 965 | "response": [] 966 | }, 967 | { 968 | "name": "user profile by token", 969 | "event": [ 970 | { 971 | "listen": "test", 972 | "script": { 973 | "exec": [ 974 | "pm.test(\"Getting User Profile From Token\",function(){\r", 975 | " pm.response.to.have.status(200);\r", 976 | "});\r", 977 | "\r", 978 | "pm.test(\"Body have _id\", function () {\r", 979 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 980 | "});\r", 981 | "\r", 982 | "pm.test(\"Email field is there\", function () {\r", 983 | " pm.expect(pm.response.text()).to.include(\"email\");\r", 984 | "});\r", 985 | "\r", 986 | "pm.test(\"Phone field is there\", function () {\r", 987 | " pm.expect(pm.response.text()).to.include(\"phone\");\r", 988 | "});\r", 989 | "\r", 990 | "pm.test(\"Check If admin True or False\", function () {\r", 991 | " pm.expect(pm.response.text()).to.include(\"is_admin\");\r", 992 | "});" 993 | ], 994 | "type": "text/javascript" 995 | } 996 | } 997 | ], 998 | "request": { 999 | "method": "GET", 1000 | "header": [], 1001 | "url": "{{host}}/user/token-user" 1002 | }, 1003 | "response": [] 1004 | }, 1005 | { 1006 | "name": "Get Followers", 1007 | "event": [ 1008 | { 1009 | "listen": "test", 1010 | "script": { 1011 | "exec": [ 1012 | "pm.test(\"Status code is 200\", function () {\r", 1013 | " pm.response.to.have.status(200);\r", 1014 | "});" 1015 | ], 1016 | "type": "text/javascript" 1017 | } 1018 | } 1019 | ], 1020 | "request": { 1021 | "method": "GET", 1022 | "header": [], 1023 | "url": { 1024 | "raw": "{{host}}/user/:userId/profile/followers", 1025 | "host": ["{{host}}"], 1026 | "path": ["user", ":userId", "profile", "followers"], 1027 | "variable": [ 1028 | { 1029 | "key": "userId", 1030 | "value": "608ed6155e3e994e00ef15e0" 1031 | } 1032 | ] 1033 | } 1034 | }, 1035 | "response": [] 1036 | }, 1037 | { 1038 | "name": "Get Followings", 1039 | "event": [ 1040 | { 1041 | "listen": "test", 1042 | "script": { 1043 | "exec": [ 1044 | "pm.test(\"Status code is 200\", function () {\r", 1045 | " pm.response.to.have.status(200);\r", 1046 | "});\r", 1047 | "pm.test(\"Response time is less than 3 SEC\", function () {\r", 1048 | " pm.expect(pm.response.responseTime).to.be.below(3000);\r", 1049 | "});\r", 1050 | "" 1051 | ], 1052 | "type": "text/javascript" 1053 | } 1054 | } 1055 | ], 1056 | "request": { 1057 | "method": "GET", 1058 | "header": [], 1059 | "url": { 1060 | "raw": "{{host}}/user/:userId/profile/followings", 1061 | "host": ["{{host}}"], 1062 | "path": ["user", ":userId", "profile", "followings"], 1063 | "variable": [ 1064 | { 1065 | "key": "userId", 1066 | "value": "6090ee7a5a27f23eba53b26c" 1067 | } 1068 | ] 1069 | } 1070 | }, 1071 | "response": [] 1072 | }, 1073 | { 1074 | "name": "Get FriendShip Status", 1075 | "request": { 1076 | "method": "GET", 1077 | "header": [], 1078 | "url": { 1079 | "raw": "{{host}}/user/:userId/friendship/status", 1080 | "host": ["{{host}}"], 1081 | "path": ["user", ":userId", "friendship", "status"], 1082 | "variable": [ 1083 | { 1084 | "key": "userId", 1085 | "value": "608ed6155e3e994e00ef15e0" 1086 | } 1087 | ] 1088 | } 1089 | }, 1090 | "response": [] 1091 | } 1092 | ] 1093 | }, 1094 | { 1095 | "name": "Post", 1096 | "item": [ 1097 | { 1098 | "name": "Create post", 1099 | "event": [ 1100 | { 1101 | "listen": "test", 1102 | "script": { 1103 | "exec": [ 1104 | "\r", 1105 | "pm.test(\"Successful POST request\", function () {\r", 1106 | " pm.expect(pm.response.code).to.be.oneOf([201, 202]);\r", 1107 | "});\r", 1108 | "pm.test(\"Competition should be null\",function(){\r", 1109 | " pm.expect(pm.response.json().competition).to.be.null\r", 1110 | "})" 1111 | ], 1112 | "type": "text/javascript" 1113 | } 1114 | } 1115 | ], 1116 | "request": { 1117 | "method": "POST", 1118 | "header": [], 1119 | "body": { 1120 | "mode": "formdata", 1121 | "formdata": [ 1122 | { 1123 | "key": "description", 1124 | "value": "From Refrencing to embedding saves memeory", 1125 | "type": "text" 1126 | }, 1127 | { 1128 | "key": "media", 1129 | "type": "file", 1130 | "src": "/home/n1/Downloads/60f2eb881d4dde3e9ec5cbbf.mp4" 1131 | }, 1132 | { 1133 | "key": "thumbnail", 1134 | "description": "If not proided server will create itself", 1135 | "type": "file", 1136 | "src": [] 1137 | }, 1138 | { 1139 | "key": "thumbnail_GIF", 1140 | "description": "If not proided server will create GIF itself", 1141 | "type": "file", 1142 | "src": [] 1143 | }, 1144 | { 1145 | "key": "type", 1146 | "value": "PU", 1147 | "description": "Default FR\n\nPR => private \nPU => public\nFR => friends\nHI => hidden or deleted", 1148 | "type": "text" 1149 | } 1150 | ] 1151 | }, 1152 | "url": "{{host}}/post/create" 1153 | }, 1154 | "response": [ 1155 | { 1156 | "name": "Post created successfully", 1157 | "originalRequest": { 1158 | "method": "POST", 1159 | "header": [ 1160 | { 1161 | "key": "Authorization", 1162 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDc4MWI4ZDhjMzQyYTIwOGM5NzQxMDUiLCJpYXQiOjE2MTg0OTYzMTksImV4cCI6MTYxODQ5OTkxOX0.wOSwyFTTyGa3_jDyHexoB8eTY8GkVFPpohQBu8VZ7kI", 1163 | "type": "text" 1164 | } 1165 | ], 1166 | "body": { 1167 | "mode": "formdata", 1168 | "formdata": [ 1169 | { 1170 | "key": "description", 1171 | "value": "This is the 1st post by Nirjal. A dev Test", 1172 | "type": "text" 1173 | }, 1174 | { 1175 | "key": "fileType", 1176 | "value": "VIDEO", 1177 | "type": "text" 1178 | }, 1179 | { 1180 | "key": "media", 1181 | "type": "file", 1182 | "src": "/C:/Users/alphawolfnirjal/Videos/sindhu.mp4" 1183 | } 1184 | ], 1185 | "options": { 1186 | "raw": { 1187 | "language": "json" 1188 | } 1189 | } 1190 | }, 1191 | "url": "localhost:3000/post/create" 1192 | }, 1193 | "status": "OK", 1194 | "code": 200, 1195 | "_postman_previewlanguage": "json", 1196 | "header": [ 1197 | { 1198 | "key": "X-Powered-By", 1199 | "value": "Express" 1200 | }, 1201 | { 1202 | "key": "Content-Type", 1203 | "value": "application/json; charset=utf-8" 1204 | }, 1205 | { 1206 | "key": "Content-Length", 1207 | "value": "260" 1208 | }, 1209 | { 1210 | "key": "ETag", 1211 | "value": "W/\"104-ICRFiFV2W8bhEp756g5Wp+VnsSY\"" 1212 | }, 1213 | { 1214 | "key": "Date", 1215 | "value": "Thu, 15 Apr 2021 14:48:26 GMT" 1216 | }, 1217 | { 1218 | "key": "Connection", 1219 | "value": "keep-alive" 1220 | }, 1221 | { 1222 | "key": "Keep-Alive", 1223 | "value": "timeout=5" 1224 | } 1225 | ], 1226 | "cookie": [], 1227 | "body": "{\n \"views\": 0,\n \"_id\": \"607852398d79cd21280185b7\",\n \"description\": \"This is the 1st post by Nirjal. A dev Test\",\n \"user\": \"60781b8d8c342a208c974105\",\n \"media\": \"607852388d79cd21280185b6\",\n \"created_at\": \"2021-04-15T14:48:25.024Z\",\n \"updated_at\": \"2021-04-15T14:48:25.024Z\",\n \"__v\": 0\n}" 1228 | } 1229 | ] 1230 | }, 1231 | { 1232 | "name": "Create post, add in competition", 1233 | "event": [ 1234 | { 1235 | "listen": "test", 1236 | "script": { 1237 | "exec": [ 1238 | "\r", 1239 | "pm.test(\"Successful POST request\", function () {\r", 1240 | " pm.expect(pm.response.code).to.be.oneOf([201, 202]);\r", 1241 | "});\r", 1242 | "pm.test(\"Competition should be null\",function(){\r", 1243 | " pm.expect(pm.response.json().competition).to.not.be.null;\r", 1244 | "})" 1245 | ], 1246 | "type": "text/javascript" 1247 | } 1248 | } 1249 | ], 1250 | "request": { 1251 | "method": "POST", 1252 | "header": [], 1253 | "body": { 1254 | "mode": "formdata", 1255 | "formdata": [ 1256 | { 1257 | "key": "competition_id", 1258 | "value": "60c9e6f58faaef85c14ae65a", 1259 | "description": "Competition id will resilt in 404 if no competition found", 1260 | "type": "text" 1261 | }, 1262 | { 1263 | "key": "description", 1264 | "value": "#aws uploading try ", 1265 | "type": "text" 1266 | }, 1267 | { 1268 | "key": "media", 1269 | "type": "file", 1270 | "src": "/home/n1/Downloads/60f2eb881d4dde3e9ec5cbbf.mp4" 1271 | }, 1272 | { 1273 | "key": "thumbnail", 1274 | "description": "If not proided server will create itself", 1275 | "type": "file", 1276 | "src": [] 1277 | }, 1278 | { 1279 | "key": "thumbnail_GIF", 1280 | "description": "If not proided server will create GIF itself", 1281 | "type": "file", 1282 | "src": [] 1283 | }, 1284 | { 1285 | "key": "type", 1286 | "value": "PR", 1287 | "description": "Default FR\n\nPR => private \nPU => public\nFR => friends\nHI => hidden or deleted", 1288 | "type": "text" 1289 | } 1290 | ] 1291 | }, 1292 | "url": "{{host}}/post/create" 1293 | }, 1294 | "response": [ 1295 | { 1296 | "name": "Post created successfully", 1297 | "originalRequest": { 1298 | "method": "POST", 1299 | "header": [ 1300 | { 1301 | "key": "Authorization", 1302 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDc4MWI4ZDhjMzQyYTIwOGM5NzQxMDUiLCJpYXQiOjE2MTg0OTYzMTksImV4cCI6MTYxODQ5OTkxOX0.wOSwyFTTyGa3_jDyHexoB8eTY8GkVFPpohQBu8VZ7kI", 1303 | "type": "text" 1304 | } 1305 | ], 1306 | "body": { 1307 | "mode": "formdata", 1308 | "formdata": [ 1309 | { 1310 | "key": "description", 1311 | "value": "This is the 1st post by Nirjal. A dev Test", 1312 | "type": "text" 1313 | }, 1314 | { 1315 | "key": "fileType", 1316 | "value": "VIDEO", 1317 | "type": "text" 1318 | }, 1319 | { 1320 | "key": "media", 1321 | "type": "file", 1322 | "src": "/C:/Users/alphawolfnirjal/Videos/sindhu.mp4" 1323 | } 1324 | ], 1325 | "options": { 1326 | "raw": { 1327 | "language": "json" 1328 | } 1329 | } 1330 | }, 1331 | "url": "localhost:3000/post/create" 1332 | }, 1333 | "status": "OK", 1334 | "code": 200, 1335 | "_postman_previewlanguage": "json", 1336 | "header": [ 1337 | { 1338 | "key": "X-Powered-By", 1339 | "value": "Express" 1340 | }, 1341 | { 1342 | "key": "Content-Type", 1343 | "value": "application/json; charset=utf-8" 1344 | }, 1345 | { 1346 | "key": "Content-Length", 1347 | "value": "260" 1348 | }, 1349 | { 1350 | "key": "ETag", 1351 | "value": "W/\"104-ICRFiFV2W8bhEp756g5Wp+VnsSY\"" 1352 | }, 1353 | { 1354 | "key": "Date", 1355 | "value": "Thu, 15 Apr 2021 14:48:26 GMT" 1356 | }, 1357 | { 1358 | "key": "Connection", 1359 | "value": "keep-alive" 1360 | }, 1361 | { 1362 | "key": "Keep-Alive", 1363 | "value": "timeout=5" 1364 | } 1365 | ], 1366 | "cookie": [], 1367 | "body": "{\n \"views\": 0,\n \"_id\": \"607852398d79cd21280185b7\",\n \"description\": \"This is the 1st post by Nirjal. A dev Test\",\n \"user\": \"60781b8d8c342a208c974105\",\n \"media\": \"607852388d79cd21280185b6\",\n \"created_at\": \"2021-04-15T14:48:25.024Z\",\n \"updated_at\": \"2021-04-15T14:48:25.024Z\",\n \"__v\": 0\n}" 1368 | } 1369 | ] 1370 | }, 1371 | { 1372 | "name": "Get all posts", 1373 | "event": [ 1374 | { 1375 | "listen": "test", 1376 | "script": { 1377 | "exec": [ 1378 | "pm.test(\"Status code is 200\", function () {\r", 1379 | " pm.response.to.have.status(200);\r", 1380 | "});\r", 1381 | "pm.test(\"Body have _id\", function () {\r", 1382 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 1383 | "});\r", 1384 | "" 1385 | ], 1386 | "type": "text/javascript" 1387 | } 1388 | } 1389 | ], 1390 | "request": { 1391 | "auth": { 1392 | "type": "noauth" 1393 | }, 1394 | "method": "GET", 1395 | "header": [], 1396 | "url": { 1397 | "raw": "{{host}}/post/all?plimit=10&pskip=0&user_id=608ed6155e3e994e00ef15e0&comp_id&order=DESC&sort_by=created_at", 1398 | "host": ["{{host}}"], 1399 | "path": ["post", "all"], 1400 | "query": [ 1401 | { 1402 | "key": "plimit", 1403 | "value": "10", 1404 | "description": "default 10" 1405 | }, 1406 | { 1407 | "key": "pskip", 1408 | "value": "0", 1409 | "description": "0" 1410 | }, 1411 | { 1412 | "key": "user_id", 1413 | "value": "608ed6155e3e994e00ef15e0", 1414 | "description": "Any userid" 1415 | }, 1416 | { 1417 | "key": "comp_id", 1418 | "value": null, 1419 | "description": "Any competition" 1420 | }, 1421 | { 1422 | "key": "order", 1423 | "value": "DESC", 1424 | "description": "DESC or ASC\ndefault DESC" 1425 | }, 1426 | { 1427 | "key": "sort_by", 1428 | "value": "created_at", 1429 | "description": "Faste with these fields\nTypes\nlikes\ncreated_at\nupdated_at" 1430 | } 1431 | ] 1432 | }, 1433 | "description": "## All query parameters\n|key | value |Default Value | \n|----------|---------|------|\n| user_id | Get all Posts for that user ||\n| comp_id | Get videos for a competition | |\n| q | Search for description on post||\n| plimit | Number of posts in the response |10|\n| pskip | Skip the number of post specified |0|\n| sort_by | Specify the field you want to sort by |views|\n| order | ASC for ASCENDING any other value means DESCENDING |DESCENDING SORT|" 1434 | }, 1435 | "response": [ 1436 | { 1437 | "name": "Get all posts", 1438 | "originalRequest": { 1439 | "method": "GET", 1440 | "header": [], 1441 | "url": "localhost:3000/post/all" 1442 | }, 1443 | "status": "OK", 1444 | "code": 200, 1445 | "_postman_previewlanguage": "json", 1446 | "header": [ 1447 | { 1448 | "key": "X-Powered-By", 1449 | "value": "Express" 1450 | }, 1451 | { 1452 | "key": "Content-Type", 1453 | "value": "application/json; charset=utf-8" 1454 | }, 1455 | { 1456 | "key": "Content-Length", 1457 | "value": "681" 1458 | }, 1459 | { 1460 | "key": "ETag", 1461 | "value": "W/\"2a9-4gekDd3ld/Yy7RWhtUq3Zf8d/8I\"" 1462 | }, 1463 | { 1464 | "key": "Date", 1465 | "value": "Thu, 15 Apr 2021 15:51:31 GMT" 1466 | }, 1467 | { 1468 | "key": "Connection", 1469 | "value": "keep-alive" 1470 | }, 1471 | { 1472 | "key": "Keep-Alive", 1473 | "value": "timeout=5" 1474 | } 1475 | ], 1476 | "cookie": [], 1477 | "body": "[\n {\n \"views\": 0,\n \"_id\": \"60785a2a1a1a362ae06ee759\",\n \"description\": \"This is the 1st post by Nirjal. A dev Test\",\n \"user\": {\n \"is_admin\": false,\n \"_id\": \"60781b8d8c342a208c974105\",\n \"email\": \"helloworld@gmail.commmm\",\n \"name\": \"Test User\",\n \"bio\": \"Biology\",\n \"phone\": \"1111111111111\",\n \"profile_picture\": \"\\\\public\\\\pp\\\\1618485234567 -- 71SnRYHv-CL._AC_SY450_.jpg\",\n \"created_at\": \"2021-04-15T10:55:09.804Z\",\n \"updated_at\": \"2021-04-15T11:13:54.772Z\",\n \"__v\": 0\n },\n \"media\": {\n \"_id\": \"60785a231a1a362ae06ee758\",\n \"path\": \"public\\\\post\\\\videos\\\\1618500127949 -- sindhu.mp4\",\n \"filetype\": \"VIDEO\",\n \"mimetype\": \"video/mp4\",\n \"encoding\": \"7bit\",\n \"__v\": 0\n },\n \"created_at\": \"2021-04-15T15:22:18.325Z\",\n \"updated_at\": \"2021-04-15T15:22:18.325Z\",\n \"__v\": 0\n }\n]" 1478 | } 1479 | ] 1480 | }, 1481 | { 1482 | "name": "By hashtag", 1483 | "event": [ 1484 | { 1485 | "listen": "test", 1486 | "script": { 1487 | "exec": [ 1488 | "pm.test(\"Status code is 200\", function () {\r", 1489 | " pm.response.to.have.status(200);\r", 1490 | "});\r", 1491 | "pm.test(\"Response time is less than 500ms\", function () {\r", 1492 | " pm.expect(pm.response.responseTime).to.be.below(500);\r", 1493 | " \r", 1494 | "});\r", 1495 | "" 1496 | ], 1497 | "type": "text/javascript" 1498 | } 1499 | } 1500 | ], 1501 | "request": { 1502 | "method": "GET", 1503 | "header": [], 1504 | "url": { 1505 | "raw": "{{host}}/post/hashtag/tag/:hashtag", 1506 | "host": ["{{host}}"], 1507 | "path": ["post", "hashtag", "tag", ":hashtag"], 1508 | "variable": [ 1509 | { 1510 | "key": "hashtag", 1511 | "value": "aws" 1512 | } 1513 | ] 1514 | } 1515 | }, 1516 | "response": [] 1517 | }, 1518 | { 1519 | "name": "Get post by ID", 1520 | "event": [ 1521 | { 1522 | "listen": "test", 1523 | "script": { 1524 | "exec": [ 1525 | "pm.test(\"Status code is 200\", function () {\r", 1526 | " pm.response.to.have.status(200);\r", 1527 | "});\r", 1528 | "pm.test(\"ID required\", function () {\r", 1529 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 1530 | "});" 1531 | ], 1532 | "type": "text/javascript" 1533 | } 1534 | } 1535 | ], 1536 | "request": { 1537 | "auth": { 1538 | "type": "noauth" 1539 | }, 1540 | "method": "GET", 1541 | "header": [], 1542 | "url": { 1543 | "raw": "{{host}}/post/:postId", 1544 | "host": ["{{host}}"], 1545 | "path": ["post", ":postId"], 1546 | "variable": [ 1547 | { 1548 | "key": "postId", 1549 | "value": "60efbef8deeeca077832c811" 1550 | } 1551 | ] 1552 | }, 1553 | "description": "## All query parameters\n|key | value |Default Value | \n|----------|---------|------|\n| climit | Number of comments in the response for that post |10|\n| cskip | Skip the number of comments for the post specified |0|\n| llimit | Number of likes in the response for that post |10|\n| lskip | Skip the likes of post specified |0|" 1554 | }, 1555 | "response": [ 1556 | { 1557 | "name": "Get post by ID", 1558 | "originalRequest": { 1559 | "method": "GET", 1560 | "header": [], 1561 | "url": "localhost:3000/post/60785a2a1a1a362ae06ee759" 1562 | }, 1563 | "status": "OK", 1564 | "code": 200, 1565 | "_postman_previewlanguage": "json", 1566 | "header": [ 1567 | { 1568 | "key": "X-Powered-By", 1569 | "value": "Express" 1570 | }, 1571 | { 1572 | "key": "Content-Type", 1573 | "value": "application/json; charset=utf-8" 1574 | }, 1575 | { 1576 | "key": "Content-Length", 1577 | "value": "679" 1578 | }, 1579 | { 1580 | "key": "ETag", 1581 | "value": "W/\"2a7-YC6b6fSTS+NMvhUr9UUUqor8WQM\"" 1582 | }, 1583 | { 1584 | "key": "Date", 1585 | "value": "Thu, 15 Apr 2021 16:11:38 GMT" 1586 | }, 1587 | { 1588 | "key": "Connection", 1589 | "value": "keep-alive" 1590 | }, 1591 | { 1592 | "key": "Keep-Alive", 1593 | "value": "timeout=5" 1594 | } 1595 | ], 1596 | "cookie": [], 1597 | "body": "{\n \"views\": 0,\n \"_id\": \"60785a2a1a1a362ae06ee759\",\n \"description\": \"This is the 1st post by Nirjal. A dev Test\",\n \"user\": {\n \"is_admin\": false,\n \"_id\": \"60781b8d8c342a208c974105\",\n \"email\": \"helloworld@gmail.commmm\",\n \"name\": \"Test User\",\n \"bio\": \"Biology\",\n \"phone\": \"1111111111111\",\n \"profile_picture\": \"\\\\public\\\\pp\\\\1618485234567 -- 71SnRYHv-CL._AC_SY450_.jpg\",\n \"created_at\": \"2021-04-15T10:55:09.804Z\",\n \"updated_at\": \"2021-04-15T11:13:54.772Z\",\n \"__v\": 0\n },\n \"media\": {\n \"_id\": \"60785a231a1a362ae06ee758\",\n \"path\": \"public\\\\post\\\\videos\\\\1618500127949 -- sindhu.mp4\",\n \"filetype\": \"VIDEO\",\n \"mimetype\": \"video/mp4\",\n \"encoding\": \"7bit\",\n \"__v\": 0\n },\n \"created_at\": \"2021-04-15T15:22:18.325Z\",\n \"updated_at\": \"2021-04-15T15:22:18.325Z\",\n \"__v\": 0\n}" 1598 | } 1599 | ] 1600 | }, 1601 | { 1602 | "name": "Update Video", 1603 | "event": [ 1604 | { 1605 | "listen": "test", 1606 | "script": { 1607 | "exec": [ 1608 | "pm.test(\"Status code is 200\", function () {\r", 1609 | " pm.response.to.have.status(200);\r", 1610 | "});\r", 1611 | "pm.test(\"Response time is less than 1.5 sec\", function () {\r", 1612 | " pm.expect(pm.response.responseTime).to.be.below(1500);\r", 1613 | "});\r", 1614 | "pm.test(\"ID required\", function () {\r", 1615 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 1616 | "});" 1617 | ], 1618 | "type": "text/javascript" 1619 | } 1620 | } 1621 | ], 1622 | "request": { 1623 | "method": "PUT", 1624 | "header": [], 1625 | "body": { 1626 | "mode": "raw", 1627 | "raw": "{\r\n \"description\":\"Update try aws\"\r\n}", 1628 | "options": { 1629 | "raw": { 1630 | "language": "json" 1631 | } 1632 | } 1633 | }, 1634 | "url": { 1635 | "raw": "{{host}}/post/:postID", 1636 | "host": ["{{host}}"], 1637 | "path": ["post", ":postID"], 1638 | "variable": [ 1639 | { 1640 | "key": "postID", 1641 | "value": "60e7f9814a0e3602db5223c6" 1642 | } 1643 | ] 1644 | } 1645 | }, 1646 | "response": [ 1647 | { 1648 | "name": "Updaate Video", 1649 | "originalRequest": { 1650 | "method": "PUT", 1651 | "header": [ 1652 | { 1653 | "key": "Authorization", 1654 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDc4MWI4ZDhjMzQyYTIwOGM5NzQxMDUiLCJpYXQiOjE2MTg1MDMyNDYsImV4cCI6MTYxODUwNjg0Nn0.In_MnBO8RunYPa-Ik92zp2u0tNmFQfhQU08whgVv2a0", 1655 | "type": "text" 1656 | } 1657 | ], 1658 | "body": { 1659 | "mode": "raw", 1660 | "raw": "{\r\n \"description\":\"The description is updated\"\r\n}", 1661 | "options": { 1662 | "raw": { 1663 | "language": "json" 1664 | } 1665 | } 1666 | }, 1667 | "url": "localhost:3000/post/60785a2a1a1a362ae06ee759" 1668 | }, 1669 | "status": "OK", 1670 | "code": 200, 1671 | "_postman_previewlanguage": "json", 1672 | "header": [ 1673 | { 1674 | "key": "X-Powered-By", 1675 | "value": "Express" 1676 | }, 1677 | { 1678 | "key": "Content-Type", 1679 | "value": "application/json; charset=utf-8" 1680 | }, 1681 | { 1682 | "key": "Content-Length", 1683 | "value": "244" 1684 | }, 1685 | { 1686 | "key": "ETag", 1687 | "value": "W/\"f4-7NOPKA3L7GG1JYXhzbnQZPGgpFc\"" 1688 | }, 1689 | { 1690 | "key": "Date", 1691 | "value": "Thu, 15 Apr 2021 16:44:11 GMT" 1692 | }, 1693 | { 1694 | "key": "Connection", 1695 | "value": "keep-alive" 1696 | }, 1697 | { 1698 | "key": "Keep-Alive", 1699 | "value": "timeout=5" 1700 | } 1701 | ], 1702 | "cookie": [], 1703 | "body": "{\n \"views\": 0,\n \"_id\": \"60785a2a1a1a362ae06ee759\",\n \"description\": \"The description is updated\",\n \"user\": \"60781b8d8c342a208c974105\",\n \"media\": \"60785a231a1a362ae06ee758\",\n \"created_at\": \"2021-04-15T15:22:18.325Z\",\n \"updated_at\": \"2021-04-15T16:44:11.419Z\",\n \"__v\": 0\n}" 1704 | } 1705 | ] 1706 | }, 1707 | { 1708 | "name": "Comment a post", 1709 | "event": [ 1710 | { 1711 | "listen": "test", 1712 | "script": { 1713 | "exec": [ 1714 | "pm.test(\"Successful POST request\", function () {\r", 1715 | " pm.expect(pm.response.code).to.be.oneOf([201, 202]);\r", 1716 | "});\r", 1717 | "pm.test(\"ID required\", function () {\r", 1718 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 1719 | "});\r", 1720 | "pm.test(\"Response time is less than 1.5 sec\", function () {\r", 1721 | " pm.expect(pm.response.responseTime).to.be.below(1500);\r", 1722 | "});" 1723 | ], 1724 | "type": "text/javascript" 1725 | } 1726 | } 1727 | ], 1728 | "request": { 1729 | "method": "POST", 1730 | "header": [], 1731 | "body": { 1732 | "mode": "raw", 1733 | "raw": "{\r\n \"body\":\"Nice game\"\r\n}", 1734 | "options": { 1735 | "raw": { 1736 | "language": "json" 1737 | } 1738 | } 1739 | }, 1740 | "url": { 1741 | "raw": "{{host}}/post/:postId/comment", 1742 | "host": ["{{host}}"], 1743 | "path": ["post", ":postId", "comment"], 1744 | "variable": [ 1745 | { 1746 | "key": "postId", 1747 | "value": "60efbef8deeeca077832c811" 1748 | } 1749 | ] 1750 | } 1751 | }, 1752 | "response": [ 1753 | { 1754 | "name": "Create a comment", 1755 | "originalRequest": { 1756 | "method": "POST", 1757 | "header": [ 1758 | { 1759 | "key": "Authorization", 1760 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDcyZmU4MGNkYmQ0NjFiMTQ4MjA2OWIiLCJpYXQiOjE2MTk1MTYwODAsImV4cCI6MTYxOTUxOTY4MH0.8-6sCHUg29oDXrRrVcVNYKBBFQmKDspe455JXYCqFGo", 1761 | "type": "text" 1762 | } 1763 | ], 1764 | "body": { 1765 | "mode": "raw", 1766 | "raw": "{\r\n \"body\":\"Wow sych an amazign view\"\r\n}", 1767 | "options": { 1768 | "raw": { 1769 | "language": "json" 1770 | } 1771 | } 1772 | }, 1773 | "url": "localhost:3000/post/6078765d417db617d03fc72c/comment" 1774 | }, 1775 | "status": "OK", 1776 | "code": 200, 1777 | "_postman_previewlanguage": "json", 1778 | "header": [ 1779 | { 1780 | "key": "X-Powered-By", 1781 | "value": "Express" 1782 | }, 1783 | { 1784 | "key": "Content-Type", 1785 | "value": "application/json; charset=utf-8" 1786 | }, 1787 | { 1788 | "key": "Content-Length", 1789 | "value": "410" 1790 | }, 1791 | { 1792 | "key": "ETag", 1793 | "value": "W/\"19a-O7WcoWeyUEFyn3Zkw+4mT0WsFA0\"" 1794 | }, 1795 | { 1796 | "key": "Date", 1797 | "value": "Tue, 27 Apr 2021 09:39:36 GMT" 1798 | }, 1799 | { 1800 | "key": "Connection", 1801 | "value": "keep-alive" 1802 | }, 1803 | { 1804 | "key": "Keep-Alive", 1805 | "value": "timeout=5" 1806 | } 1807 | ], 1808 | "cookie": [], 1809 | "body": "{\n \"_id\": \"6087dbd762401f23f8f5a050\",\n \"user\": {\n \"is_admin\": false,\n \"_id\": \"6072fe80cdbd461b1482069b\",\n \"email\": \"testuser@gmail.com\",\n \"name\": \"Test User\",\n \"bio\": \"Biology\",\n \"phone\": \"123456789\",\n \"profile_picture\": null,\n \"created_at\": \"2021-04-11T13:49:52.773Z\",\n \"updated_at\": \"2021-04-12T13:49:30.983Z\",\n \"__v\": 0\n },\n \"body\": \"Wow sych an amazign view\",\n \"created_at\": \"2021-04-27T09:39:35.641Z\",\n \"updated_at\": \"2021-04-27T09:39:35.641Z\",\n \"__v\": 0\n}" 1810 | } 1811 | ] 1812 | }, 1813 | { 1814 | "name": "Delete a Post", 1815 | "event": [ 1816 | { 1817 | "listen": "test", 1818 | "script": { 1819 | "exec": [ 1820 | "pm.test(\"Status code is 200\", function () {\r", 1821 | " pm.response.to.have.status(200);\r", 1822 | "});\r", 1823 | "\r", 1824 | "\r", 1825 | "pm.test(\"Response time is less than 1.5 sec\", function () {\r", 1826 | " pm.expect(pm.response.responseTime).to.be.below(1500);\r", 1827 | "});\r", 1828 | "pm.test(\"Delete a post\", function () {\r", 1829 | " pm.expect(pm.response.text()).to.include(\"deleted\");\r", 1830 | "});" 1831 | ], 1832 | "type": "text/javascript" 1833 | } 1834 | } 1835 | ], 1836 | "request": { 1837 | "method": "DELETE", 1838 | "header": [], 1839 | "url": { 1840 | "raw": "{{host}}/post/:postId", 1841 | "host": ["{{host}}"], 1842 | "path": ["post", ":postId"], 1843 | "variable": [ 1844 | { 1845 | "key": "postId", 1846 | "value": "60e7f9814a0e3602db5223c6" 1847 | } 1848 | ] 1849 | } 1850 | }, 1851 | "response": [ 1852 | { 1853 | "name": "Succesful deletion", 1854 | "originalRequest": { 1855 | "method": "DELETE", 1856 | "header": [ 1857 | { 1858 | "key": "Authorization", 1859 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDc4MWI4ZDhjMzQyYTIwOGM5NzQxMDUiLCJpYXQiOjE2MTg1MDMyNDYsImV4cCI6MTYxODUwNjg0Nn0.In_MnBO8RunYPa-Ik92zp2u0tNmFQfhQU08whgVv2a0", 1860 | "type": "text" 1861 | } 1862 | ], 1863 | "url": "localhost:3000/post/60785a2a1a1a362ae06ee759" 1864 | }, 1865 | "status": "OK", 1866 | "code": 200, 1867 | "_postman_previewlanguage": "json", 1868 | "header": [ 1869 | { 1870 | "key": "X-Powered-By", 1871 | "value": "Express" 1872 | }, 1873 | { 1874 | "key": "Content-Type", 1875 | "value": "application/json; charset=utf-8" 1876 | }, 1877 | { 1878 | "key": "Content-Length", 1879 | "value": "244" 1880 | }, 1881 | { 1882 | "key": "ETag", 1883 | "value": "W/\"f4-7NOPKA3L7GG1JYXhzbnQZPGgpFc\"" 1884 | }, 1885 | { 1886 | "key": "Date", 1887 | "value": "Thu, 15 Apr 2021 16:46:50 GMT" 1888 | }, 1889 | { 1890 | "key": "Connection", 1891 | "value": "keep-alive" 1892 | }, 1893 | { 1894 | "key": "Keep-Alive", 1895 | "value": "timeout=5" 1896 | } 1897 | ], 1898 | "cookie": [], 1899 | "body": "{\n \"views\": 0,\n \"_id\": \"60785a2a1a1a362ae06ee759\",\n \"description\": \"The description is updated\",\n \"user\": \"60781b8d8c342a208c974105\",\n \"media\": \"60785a231a1a362ae06ee758\",\n \"created_at\": \"2021-04-15T15:22:18.325Z\",\n \"updated_at\": \"2021-04-15T16:44:11.419Z\",\n \"__v\": 0\n}" 1900 | } 1901 | ] 1902 | }, 1903 | { 1904 | "name": "Delete comment", 1905 | "event": [ 1906 | { 1907 | "listen": "test", 1908 | "script": { 1909 | "exec": [ 1910 | "pm.test(\"Status code is 200\", function () {\r", 1911 | " pm.response.to.have.status(200);\r", 1912 | "});\r", 1913 | "\r", 1914 | "\r", 1915 | "pm.test(\"Response time is less than 1.5 sec\", function () {\r", 1916 | " pm.expect(pm.response.responseTime).to.be.below(1500);\r", 1917 | "});\r", 1918 | "pm.test(\"Delete a post\", function () {\r", 1919 | " pm.expect(pm.response.text()).to.include(\"deleted\");\r", 1920 | "});" 1921 | ], 1922 | "type": "text/javascript" 1923 | } 1924 | } 1925 | ], 1926 | "request": { 1927 | "method": "DELETE", 1928 | "header": [], 1929 | "url": { 1930 | "raw": "{{host}}/post/:postId/delete-comment/comment/:commentID", 1931 | "host": ["{{host}}"], 1932 | "path": [ 1933 | "post", 1934 | ":postId", 1935 | "delete-comment", 1936 | "comment", 1937 | ":commentID" 1938 | ], 1939 | "variable": [ 1940 | { 1941 | "key": "postId", 1942 | "value": "60e7f9814a0e3602db5223c6" 1943 | }, 1944 | { 1945 | "key": "commentID", 1946 | "value": "60e87e1c291184d0e4582b2c" 1947 | } 1948 | ] 1949 | } 1950 | }, 1951 | "response": [ 1952 | { 1953 | "name": "Delete a comment", 1954 | "originalRequest": { 1955 | "method": "DELETE", 1956 | "header": [ 1957 | { 1958 | "key": "Authorization", 1959 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDcyZmU4MGNkYmQ0NjFiMTQ4MjA2OWIiLCJpYXQiOjE2MTk1MTYwODAsImV4cCI6MTYxOTUxOTY4MH0.8-6sCHUg29oDXrRrVcVNYKBBFQmKDspe455JXYCqFGo", 1960 | "type": "text" 1961 | } 1962 | ], 1963 | "url": "localhost:3000/post/6078765d417db617d03fc72c/delete-comment/comment/6087dbd762401f23f8f5a050" 1964 | }, 1965 | "status": "OK", 1966 | "code": 200, 1967 | "_postman_previewlanguage": "json", 1968 | "header": [ 1969 | { 1970 | "key": "X-Powered-By", 1971 | "value": "Express" 1972 | }, 1973 | { 1974 | "key": "Content-Type", 1975 | "value": "application/json; charset=utf-8" 1976 | }, 1977 | { 1978 | "key": "Content-Length", 1979 | "value": "203" 1980 | }, 1981 | { 1982 | "key": "ETag", 1983 | "value": "W/\"cb-E0IMremh/ep05JjkOmhhZHEefuo\"" 1984 | }, 1985 | { 1986 | "key": "Date", 1987 | "value": "Tue, 27 Apr 2021 09:50:20 GMT" 1988 | }, 1989 | { 1990 | "key": "Connection", 1991 | "value": "keep-alive" 1992 | }, 1993 | { 1994 | "key": "Keep-Alive", 1995 | "value": "timeout=5" 1996 | } 1997 | ], 1998 | "cookie": [], 1999 | "body": "{\n \"_id\": \"6087dbd762401f23f8f5a050\",\n \"user\": \"6072fe80cdbd461b1482069b\",\n \"body\": \"(comments in nepali) Kya dammi thau k\",\n \"created_at\": \"2021-04-27T09:39:35.641Z\",\n \"updated_at\": \"2021-04-27T09:47:49.183Z\",\n \"__v\": 0\n}" 2000 | } 2001 | ] 2002 | }, 2003 | { 2004 | "name": "Unlike a post", 2005 | "event": [ 2006 | { 2007 | "listen": "test", 2008 | "script": { 2009 | "exec": [ 2010 | "pm.test(\"Status code is 200\", function () {\r", 2011 | " pm.response.to.have.status(200);\r", 2012 | "});\r", 2013 | "pm.test(\"Unlike a post\", function () {\r", 2014 | " pm.expect(pm.response.text()).to.include(\"Post is unliked\");\r", 2015 | "});" 2016 | ], 2017 | "type": "text/javascript" 2018 | } 2019 | } 2020 | ], 2021 | "request": { 2022 | "method": "POST", 2023 | "header": [], 2024 | "url": { 2025 | "raw": "{{host}}/post/:postId/unlike", 2026 | "host": ["{{host}}"], 2027 | "path": ["post", ":postId", "unlike"], 2028 | "variable": [ 2029 | { 2030 | "key": "postId", 2031 | "value": "60e7f9814a0e3602db5223c6" 2032 | } 2033 | ] 2034 | } 2035 | }, 2036 | "response": [] 2037 | }, 2038 | { 2039 | "name": "Like a post", 2040 | "event": [ 2041 | { 2042 | "listen": "test", 2043 | "script": { 2044 | "exec": [ 2045 | "pm.test(\"Successful POST request\", function () {\r", 2046 | " pm.expect(pm.response.code).to.be.oneOf([201, 202]);\r", 2047 | "});\r", 2048 | "pm.test(\"like a post\", function () {\r", 2049 | " pm.expect(pm.response.text()).to.include(\"The post is liked\");\r", 2050 | "});" 2051 | ], 2052 | "type": "text/javascript" 2053 | } 2054 | } 2055 | ], 2056 | "request": { 2057 | "method": "POST", 2058 | "header": [], 2059 | "url": { 2060 | "raw": "{{host}}/post/:postID/like", 2061 | "host": ["{{host}}"], 2062 | "path": ["post", ":postID", "like"], 2063 | "variable": [ 2064 | { 2065 | "key": "postID", 2066 | "value": "60e7f9814a0e3602db5223c6" 2067 | } 2068 | ] 2069 | } 2070 | }, 2071 | "response": [ 2072 | { 2073 | "name": "Unlike / Deleye alike", 2074 | "originalRequest": { 2075 | "method": "POST", 2076 | "header": [ 2077 | { 2078 | "key": "Authorization", 2079 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDcyZmU4MGNkYmQ0NjFiMTQ4MjA2OWIiLCJpYXQiOjE2MTk1MTYwODAsImV4cCI6MTYxOTUxOTY4MH0.8-6sCHUg29oDXrRrVcVNYKBBFQmKDspe455JXYCqFGo", 2080 | "type": "text" 2081 | } 2082 | ], 2083 | "url": "localhost:3000/post/6078765d417db617d03fc72c/like" 2084 | }, 2085 | "status": "OK", 2086 | "code": 200, 2087 | "_postman_previewlanguage": "json", 2088 | "header": [ 2089 | { 2090 | "key": "X-Powered-By", 2091 | "value": "Express" 2092 | }, 2093 | { 2094 | "key": "Content-Type", 2095 | "value": "application/json; charset=utf-8" 2096 | }, 2097 | { 2098 | "key": "Content-Length", 2099 | "value": "31" 2100 | }, 2101 | { 2102 | "key": "ETag", 2103 | "value": "W/\"1f-UUqVO8JfHnlxM2kkKQG1gHgnyKY\"" 2104 | }, 2105 | { 2106 | "key": "Date", 2107 | "value": "Tue, 27 Apr 2021 09:52:11 GMT" 2108 | }, 2109 | { 2110 | "key": "Connection", 2111 | "value": "keep-alive" 2112 | }, 2113 | { 2114 | "key": "Keep-Alive", 2115 | "value": "timeout=5" 2116 | } 2117 | ], 2118 | "cookie": [], 2119 | "body": "{\n \"success\": \"The post is liked\"\n}" 2120 | } 2121 | ] 2122 | }, 2123 | { 2124 | "name": "Get famous hashtags", 2125 | "event": [ 2126 | { 2127 | "listen": "test", 2128 | "script": { 2129 | "exec": [ 2130 | "pm.test(\"Status code is 200\", function () {\r", 2131 | " pm.response.to.have.status(200);\r", 2132 | "});\r", 2133 | "pm.test(\"Response time is less than 500ms\", function () {\r", 2134 | " pm.expect(pm.response.responseTime).to.be.below(500);\r", 2135 | " \r", 2136 | "});" 2137 | ], 2138 | "type": "text/javascript" 2139 | } 2140 | } 2141 | ], 2142 | "request": { 2143 | "auth": { 2144 | "type": "noauth" 2145 | }, 2146 | "method": "GET", 2147 | "header": [], 2148 | "url": { 2149 | "raw": "{{host}}/post/hashtags?hlimit=20&hskip=0", 2150 | "host": ["{{host}}"], 2151 | "path": ["post", "hashtags"], 2152 | "query": [ 2153 | { 2154 | "key": "hlimit", 2155 | "value": "20" 2156 | }, 2157 | { 2158 | "key": "hskip", 2159 | "value": "0" 2160 | } 2161 | ] 2162 | }, 2163 | "description": "> ###### Default sort by most videos for a tag\n\n## All query parameters\n|key | value |Default Value | \n|----------|---------|------|\n| hlimit | Number of posts in the response |10|\n| hskip | Skip the number of post specified |0|" 2164 | }, 2165 | "response": [] 2166 | }, 2167 | { 2168 | "name": "Increase 1 view", 2169 | "event": [ 2170 | { 2171 | "listen": "test", 2172 | "script": { 2173 | "exec": [ 2174 | "pm.test(\"Increse 1 view\", function () {\r", 2175 | " pm.expect(pm.response.text()).to.include(\"increased\");\r", 2176 | "});\r", 2177 | "pm.test(\"Status code is 200\", function () {\r", 2178 | " pm.response.to.have.status(200);\r", 2179 | "});" 2180 | ], 2181 | "type": "text/javascript" 2182 | } 2183 | } 2184 | ], 2185 | "request": { 2186 | "method": "POST", 2187 | "header": [], 2188 | "url": { 2189 | "raw": "{{host}}/post/:postId/inc/view", 2190 | "host": ["{{host}}"], 2191 | "path": ["post", ":postId", "inc", "view"], 2192 | "variable": [ 2193 | { 2194 | "key": "postId", 2195 | "value": "60e7f9814a0e3602db5223c6" 2196 | } 2197 | ] 2198 | } 2199 | }, 2200 | "response": [] 2201 | } 2202 | ] 2203 | }, 2204 | { 2205 | "name": "Comments", 2206 | "item": [ 2207 | { 2208 | "name": "Update comment", 2209 | "event": [ 2210 | { 2211 | "listen": "test", 2212 | "script": { 2213 | "exec": [ 2214 | "pm.test(\"Status code is 200\", function () {\r", 2215 | " pm.response.to.have.status(200);\r", 2216 | "});\r", 2217 | "\r", 2218 | "pm.test(\"Body have _id\", function () {\r", 2219 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 2220 | "});\r", 2221 | "" 2222 | ], 2223 | "type": "text/javascript" 2224 | } 2225 | } 2226 | ], 2227 | "request": { 2228 | "method": "PUT", 2229 | "header": [], 2230 | "body": { 2231 | "mode": "raw", 2232 | "raw": "{\r\n \"body\":\"(comments in nepali) Kya dammi thau k\"\r\n}", 2233 | "options": { 2234 | "raw": { 2235 | "language": "json" 2236 | } 2237 | } 2238 | }, 2239 | "url": { 2240 | "raw": "{{host}}/comment/:commentId", 2241 | "host": ["{{host}}"], 2242 | "path": ["comment", ":commentId"], 2243 | "variable": [ 2244 | { 2245 | "key": "commentId", 2246 | "value": "60eaf8c4913b4dbc3f6a15b3" 2247 | } 2248 | ] 2249 | } 2250 | }, 2251 | "response": [ 2252 | { 2253 | "name": "Update comment", 2254 | "originalRequest": { 2255 | "method": "PUT", 2256 | "header": [ 2257 | { 2258 | "key": "Authorization", 2259 | "value": "jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDcyZmU4MGNkYmQ0NjFiMTQ4MjA2OWIiLCJpYXQiOjE2MTk1MTYwODAsImV4cCI6MTYxOTUxOTY4MH0.8-6sCHUg29oDXrRrVcVNYKBBFQmKDspe455JXYCqFGo", 2260 | "type": "text" 2261 | } 2262 | ], 2263 | "body": { 2264 | "mode": "raw", 2265 | "raw": "{\r\n \"body\":\"(comments in nepali) Kya dammi thau k\"\r\n}", 2266 | "options": { 2267 | "raw": { 2268 | "language": "json" 2269 | } 2270 | } 2271 | }, 2272 | "url": "localhost:3000/comment/6087dbd762401f23f8f5a050" 2273 | }, 2274 | "status": "OK", 2275 | "code": 200, 2276 | "_postman_previewlanguage": "json", 2277 | "header": [ 2278 | { 2279 | "key": "X-Powered-By", 2280 | "value": "Express" 2281 | }, 2282 | { 2283 | "key": "Content-Type", 2284 | "value": "application/json; charset=utf-8" 2285 | }, 2286 | { 2287 | "key": "Content-Length", 2288 | "value": "203" 2289 | }, 2290 | { 2291 | "key": "ETag", 2292 | "value": "W/\"cb-E0IMremh/ep05JjkOmhhZHEefuo\"" 2293 | }, 2294 | { 2295 | "key": "Date", 2296 | "value": "Tue, 27 Apr 2021 09:47:49 GMT" 2297 | }, 2298 | { 2299 | "key": "Connection", 2300 | "value": "keep-alive" 2301 | }, 2302 | { 2303 | "key": "Keep-Alive", 2304 | "value": "timeout=5" 2305 | } 2306 | ], 2307 | "cookie": [], 2308 | "body": "{\n \"_id\": \"6087dbd762401f23f8f5a050\",\n \"user\": \"6072fe80cdbd461b1482069b\",\n \"body\": \"(comments in nepali) Kya dammi thau k\",\n \"created_at\": \"2021-04-27T09:39:35.641Z\",\n \"updated_at\": \"2021-04-27T09:47:49.183Z\",\n \"__v\": 0\n}" 2309 | } 2310 | ] 2311 | }, 2312 | { 2313 | "name": "Reply to a comment", 2314 | "event": [ 2315 | { 2316 | "listen": "test", 2317 | "script": { 2318 | "exec": [ 2319 | "pm.test(\"Status code is 200\", function () {\r", 2320 | " pm.response.to.have.status(200);\r", 2321 | "});\r", 2322 | "\r", 2323 | "pm.test(\"Body have _id\", function () {\r", 2324 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 2325 | "});\r", 2326 | "" 2327 | ], 2328 | "type": "text/javascript" 2329 | } 2330 | } 2331 | ], 2332 | "request": { 2333 | "method": "POST", 2334 | "header": [], 2335 | "body": { 2336 | "mode": "raw", 2337 | "raw": "{\r\n \"body\":\"chup gandu\"\r\n}", 2338 | "options": { 2339 | "raw": { 2340 | "language": "json" 2341 | } 2342 | } 2343 | }, 2344 | "url": { 2345 | "raw": "{{host}}/comment/reply/:commentId", 2346 | "host": ["{{host}}"], 2347 | "path": ["comment", "reply", ":commentId"], 2348 | "variable": [ 2349 | { 2350 | "key": "commentId", 2351 | "value": "60f16097be16fe24152ec2c9", 2352 | "description": "Messi kai bhalu di maria lai kalu bhaneko xa yesma" 2353 | } 2354 | ] 2355 | } 2356 | }, 2357 | "response": [] 2358 | }, 2359 | { 2360 | "name": "Delete a Reply", 2361 | "event": [ 2362 | { 2363 | "listen": "test", 2364 | "script": { 2365 | "exec": [ 2366 | "pm.test(\"Status code is 200\", function () {\r", 2367 | " pm.response.to.have.status(200);\r", 2368 | "});\r", 2369 | "\r", 2370 | "pm.test(\"Body have _id\", function () {\r", 2371 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 2372 | "});\r", 2373 | "" 2374 | ], 2375 | "type": "text/javascript" 2376 | } 2377 | } 2378 | ], 2379 | "request": { 2380 | "method": "DELETE", 2381 | "header": [], 2382 | "url": { 2383 | "raw": "{{host}}/comment/reply/:replyId", 2384 | "host": ["{{host}}"], 2385 | "path": ["comment", "reply", ":replyId"], 2386 | "variable": [ 2387 | { 2388 | "key": "replyId", 2389 | "value": "60eaf8c4913b4dbc3f6a15b3" 2390 | } 2391 | ] 2392 | } 2393 | }, 2394 | "response": [] 2395 | }, 2396 | { 2397 | "name": "Like a comment or reply", 2398 | "request": { 2399 | "method": "POST", 2400 | "header": [], 2401 | "url": { 2402 | "raw": "{{host}}/comment/:commentId/like", 2403 | "host": ["{{host}}"], 2404 | "path": ["comment", ":commentId", "like"], 2405 | "variable": [ 2406 | { 2407 | "key": "commentId", 2408 | "value": "60f161fef14c7b24a4a78493" 2409 | } 2410 | ] 2411 | }, 2412 | "description": "Both **comment and reply are same**. So this route should work for both" 2413 | }, 2414 | "response": [] 2415 | }, 2416 | { 2417 | "name": "Unlike a comment or reply", 2418 | "request": { 2419 | "method": "POST", 2420 | "header": [], 2421 | "url": { 2422 | "raw": "{{host}}/comment/:commentId/unlike", 2423 | "host": ["{{host}}"], 2424 | "path": ["comment", ":commentId", "unlike"], 2425 | "variable": [ 2426 | { 2427 | "key": "commentId", 2428 | "value": "60f15fe837d9661732f34115" 2429 | } 2430 | ] 2431 | }, 2432 | "description": "Both **comment and reply are same**. So this route should work for both" 2433 | }, 2434 | "response": [] 2435 | }, 2436 | { 2437 | "name": "Get Replies to a comment", 2438 | "request": { 2439 | "method": "GET", 2440 | "header": [], 2441 | "url": { 2442 | "raw": "{{host}}/comment/:commentId/replies?rlimit=10&rskip=0", 2443 | "host": ["{{host}}"], 2444 | "path": ["comment", ":commentId", "replies"], 2445 | "query": [ 2446 | { 2447 | "key": "rlimit", 2448 | "value": "10" 2449 | }, 2450 | { 2451 | "key": "rskip", 2452 | "value": "0" 2453 | } 2454 | ], 2455 | "variable": [ 2456 | { 2457 | "key": "commentId", 2458 | "value": "60f16097be16fe24152ec2c9" 2459 | } 2460 | ] 2461 | }, 2462 | "description": "Both **comment and reply are same**. So this route should work for both" 2463 | }, 2464 | "response": [] 2465 | }, 2466 | { 2467 | "name": "Get likes to a comment", 2468 | "request": { 2469 | "method": "GET", 2470 | "header": [], 2471 | "url": { 2472 | "raw": "{{host}}/comment/:commentId/likes?llimit=10&lskip=0", 2473 | "host": ["{{host}}"], 2474 | "path": ["comment", ":commentId", "likes"], 2475 | "query": [ 2476 | { 2477 | "key": "llimit", 2478 | "value": "10" 2479 | }, 2480 | { 2481 | "key": "lskip", 2482 | "value": "0" 2483 | } 2484 | ], 2485 | "variable": [ 2486 | { 2487 | "key": "commentId", 2488 | "value": "60f161fef14c7b24a4a78493" 2489 | } 2490 | ] 2491 | }, 2492 | "description": "Both **comment and reply are same**. So this route should work for both" 2493 | }, 2494 | "response": [] 2495 | } 2496 | ] 2497 | }, 2498 | { 2499 | "name": "Competition", 2500 | "item": [ 2501 | { 2502 | "name": "Create a competition", 2503 | "event": [ 2504 | { 2505 | "listen": "test", 2506 | "script": { 2507 | "exec": [ 2508 | "pm.test(\"Successful POST request\", function () {\r", 2509 | " pm.expect(pm.response.code).to.be.oneOf([201, 202]);\r", 2510 | "});\r", 2511 | "\r", 2512 | "pm.test(\"Body have _id\", function () {\r", 2513 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 2514 | "});\r", 2515 | "" 2516 | ], 2517 | "type": "text/javascript" 2518 | } 2519 | } 2520 | ], 2521 | "request": { 2522 | "method": "POST", 2523 | "header": [], 2524 | "body": { 2525 | "mode": "formdata", 2526 | "formdata": [ 2527 | { 2528 | "key": "title", 2529 | "value": "New competition", 2530 | "description": "Title of competition", 2531 | "type": "text" 2532 | }, 2533 | { 2534 | "key": "description", 2535 | "value": "This is a new competition. It is a test for file upload. Lets see how it works", 2536 | "description": "Description of competition", 2537 | "type": "text" 2538 | }, 2539 | { 2540 | "key": "startDate", 2541 | "value": "2021-7-15", 2542 | "type": "text" 2543 | }, 2544 | { 2545 | "key": "endDate", 2546 | "value": "2021-7-20", 2547 | "type": "text" 2548 | }, 2549 | { 2550 | "key": "categories[0]", 2551 | "value": "new", 2552 | "type": "text" 2553 | }, 2554 | { 2555 | "key": "categories[1]", 2556 | "value": "competition", 2557 | "type": "text" 2558 | }, 2559 | { 2560 | "key": "categories[2]", 2561 | "value": "file", 2562 | "type": "text" 2563 | }, 2564 | { 2565 | "key": "categories[3]", 2566 | "value": "upload", 2567 | "type": "text" 2568 | }, 2569 | { 2570 | "key": "main_photo", 2571 | "type": "file", 2572 | "src": "/C:/Users/ppuda/Downloads/received_160043772859895.jpeg" 2573 | }, 2574 | { 2575 | "key": "cover_photo", 2576 | "type": "file", 2577 | "src": "/C:/Users/ppuda/Downloads/received_160043772859895.jpeg" 2578 | } 2579 | ] 2580 | }, 2581 | "url": "{{host}}/competition/create" 2582 | }, 2583 | "response": [ 2584 | { 2585 | "name": "Create a competition", 2586 | "originalRequest": { 2587 | "method": "POST", 2588 | "header": [], 2589 | "body": { 2590 | "mode": "raw", 2591 | "raw": "{\r\n \"startDate\":\"2021-05-12\",\r\n \"endDate\":\"2021-12-01\",\r\n \"title\":\"1st competition [Dev Test]\",\r\n \"description\":\"This is a first compedition build and this is a dev test\",\r\n \"categories\":[\"DEV TEST\",\"1st comp\",\"startup\"]\r\n}", 2592 | "options": { 2593 | "raw": { 2594 | "language": "json" 2595 | } 2596 | } 2597 | }, 2598 | "url": "{{host}}/competition/create" 2599 | }, 2600 | "status": "OK", 2601 | "code": 200, 2602 | "_postman_previewlanguage": "json", 2603 | "header": [ 2604 | { 2605 | "key": "X-Powered-By", 2606 | "value": "Express" 2607 | }, 2608 | { 2609 | "key": "Content-Type", 2610 | "value": "application/json; charset=utf-8" 2611 | }, 2612 | { 2613 | "key": "Content-Length", 2614 | "value": "606" 2615 | }, 2616 | { 2617 | "key": "ETag", 2618 | "value": "W/\"25e-ENK47ctCIPcYJUoRg2Kcyz64h1w\"" 2619 | }, 2620 | { 2621 | "key": "Date", 2622 | "value": "Mon, 03 May 2021 08:38:31 GMT" 2623 | }, 2624 | { 2625 | "key": "Connection", 2626 | "value": "keep-alive" 2627 | }, 2628 | { 2629 | "key": "Keep-Alive", 2630 | "value": "timeout=5" 2631 | } 2632 | ], 2633 | "cookie": [], 2634 | "body": "{\n \"posts\": [],\n \"categories\": [\n \"DEV TEST\",\n \"1st comp\",\n \"startup\"\n ],\n \"admins\": [\n {\n \"is_admin\": true,\n \"is_merchant\": false,\n \"_id\": \"608903eb190fa608902390e2\",\n \"email\": \"testuser@gmail.com\",\n \"name\": \"Test User\",\n \"bio\": \"Biology\",\n \"phone\": \"123456789\",\n \"profile_picture\": null,\n \"created_at\": \"2021-04-28T06:42:51.932Z\",\n \"updated_at\": \"2021-04-28T06:45:58.168Z\",\n \"__v\": 0\n }\n ],\n \"moderators\": [],\n \"editors\": [],\n \"_id\": \"608fb687df26e52bb0a1bae4\",\n \"startDate\": \"2021-05-12T00:00:00.000Z\",\n \"endDate\": \"2021-12-01T00:00:00.000Z\",\n \"title\": \"1st competition [Dev Test]\",\n \"description\": \"This is a first compedition build and this is a dev test\",\n \"sponsors\": [],\n \"__v\": 0\n}" 2635 | } 2636 | ] 2637 | }, 2638 | { 2639 | "name": "Get all compeditions", 2640 | "event": [ 2641 | { 2642 | "listen": "test", 2643 | "script": { 2644 | "exec": [ 2645 | "pm.test(\"Successful POST request\", function () {\r", 2646 | " pm.expect(pm.response.code).to.be.oneOf([201, 202]);\r", 2647 | "});\r", 2648 | "\r", 2649 | "\r", 2650 | "" 2651 | ], 2652 | "type": "text/javascript" 2653 | } 2654 | } 2655 | ], 2656 | "request": { 2657 | "auth": { 2658 | "type": "noauth" 2659 | }, 2660 | "method": "GET", 2661 | "header": [], 2662 | "url": "{{host}}/competition/all", 2663 | "description": "## All query parameters\n|key | value |Default Value | \n|----------|---------|------|\n| climit | Number of posts in the response |10|\n| cskip | Skip the number of post specified |0|\n| sort_by | Specify the field you want to sort by |title|\n| order | ASC for ASCENDING any other value means DESCENDING |DESCENDING SORT|\n| title | Search by title | |" 2664 | }, 2665 | "response": [ 2666 | { 2667 | "name": "Get all compeditions", 2668 | "originalRequest": { 2669 | "method": "GET", 2670 | "header": [], 2671 | "url": "{{host}}/competition/all" 2672 | }, 2673 | "status": "OK", 2674 | "code": 200, 2675 | "_postman_previewlanguage": "json", 2676 | "header": [ 2677 | { 2678 | "key": "X-Powered-By", 2679 | "value": "Express" 2680 | }, 2681 | { 2682 | "key": "Content-Type", 2683 | "value": "application/json; charset=utf-8" 2684 | }, 2685 | { 2686 | "key": "Content-Length", 2687 | "value": "369" 2688 | }, 2689 | { 2690 | "key": "ETag", 2691 | "value": "W/\"171-xuK6hdily1TV0GQH8YocDMg6U8s\"" 2692 | }, 2693 | { 2694 | "key": "Date", 2695 | "value": "Mon, 03 May 2021 08:43:56 GMT" 2696 | }, 2697 | { 2698 | "key": "Connection", 2699 | "value": "keep-alive" 2700 | }, 2701 | { 2702 | "key": "Keep-Alive", 2703 | "value": "timeout=5" 2704 | } 2705 | ], 2706 | "cookie": [], 2707 | "body": "[\n {\n \"_id\": \"608fb687df26e52bb0a1bae4\",\n \"posts\": [],\n \"categories\": [\n \"DEV TEST\",\n \"1st comp\",\n \"startup\"\n ],\n \"admins\": [\n \"608903eb190fa608902390e2\"\n ],\n \"moderators\": [],\n \"editors\": [],\n \"startDate\": \"2021-05-12T00:00:00.000Z\",\n \"endDate\": \"2021-12-01T00:00:00.000Z\",\n \"title\": \"1st competition [Dev Test]\",\n \"description\": \"This is a first compedition build and this is a dev test\",\n \"sponsors\": [],\n \"__v\": 0\n }\n]" 2708 | } 2709 | ] 2710 | }, 2711 | { 2712 | "name": "Get competition by ID", 2713 | "event": [ 2714 | { 2715 | "listen": "test", 2716 | "script": { 2717 | "exec": [ 2718 | "pm.test(\"Status code is 200\", function () {\r", 2719 | " pm.response.to.have.status(200);\r", 2720 | "});\r", 2721 | "\r", 2722 | "pm.test(\"Body have _id\", function () {\r", 2723 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 2724 | "});\r", 2725 | "" 2726 | ], 2727 | "type": "text/javascript" 2728 | } 2729 | } 2730 | ], 2731 | "request": { 2732 | "auth": { 2733 | "type": "noauth" 2734 | }, 2735 | "method": "GET", 2736 | "header": [], 2737 | "url": { 2738 | "raw": "{{host}}/competition/:compId", 2739 | "host": ["{{host}}"], 2740 | "path": ["competition", ":compId"], 2741 | "variable": [ 2742 | { 2743 | "key": "compId", 2744 | "value": "60eb0d26913b4dbc3f6a15be", 2745 | "description": "COMPETITION ko _id value" 2746 | } 2747 | ] 2748 | }, 2749 | "description": "## All query parameters\n|key | value |Default Value | \n|----------|---------|------|\n| plimit | Number of posts in the response for that competition |10|\n| pskip | Skip the number of posts for the competition specified |0|" 2750 | }, 2751 | "response": [] 2752 | }, 2753 | { 2754 | "name": "Get all posts for a competition", 2755 | "event": [ 2756 | { 2757 | "listen": "test", 2758 | "script": { 2759 | "exec": [ 2760 | "pm.test(\"Status code is 200\", function () {\r", 2761 | " pm.response.to.have.status(200);\r", 2762 | "});" 2763 | ], 2764 | "type": "text/javascript" 2765 | } 2766 | } 2767 | ], 2768 | "request": { 2769 | "method": "GET", 2770 | "header": [], 2771 | "url": { 2772 | "raw": "{{host}}/post/all?comp_id=60eb0d26913b4dbc3f6a15be", 2773 | "host": ["{{host}}"], 2774 | "path": ["post", "all"], 2775 | "query": [ 2776 | { 2777 | "key": "comp_id", 2778 | "value": "60eb0d26913b4dbc3f6a15be" 2779 | } 2780 | ] 2781 | } 2782 | }, 2783 | "response": [] 2784 | }, 2785 | { 2786 | "name": "Delete Competition", 2787 | "event": [ 2788 | { 2789 | "listen": "test", 2790 | "script": { 2791 | "exec": [ 2792 | "pm.test(\"Status code is 200\", function () {\r", 2793 | " pm.response.to.have.status(200);\r", 2794 | "});" 2795 | ], 2796 | "type": "text/javascript" 2797 | } 2798 | } 2799 | ], 2800 | "request": { 2801 | "method": "DELETE", 2802 | "header": [], 2803 | "url": { 2804 | "raw": "{{host}}/competition/:competitionId", 2805 | "host": ["{{host}}"], 2806 | "path": ["competition", ":competitionId"], 2807 | "variable": [ 2808 | { 2809 | "key": "competitionId", 2810 | "value": "60eb1550913b4dbc3f6a15cb" 2811 | } 2812 | ] 2813 | } 2814 | }, 2815 | "response": [] 2816 | }, 2817 | { 2818 | "name": "Update Compedition", 2819 | "event": [ 2820 | { 2821 | "listen": "test", 2822 | "script": { 2823 | "exec": [ 2824 | "pm.test(\"Status code is 200\", function () {\r", 2825 | " pm.response.to.have.status(200);\r", 2826 | "});" 2827 | ], 2828 | "type": "text/javascript" 2829 | } 2830 | } 2831 | ], 2832 | "request": { 2833 | "method": "PUT", 2834 | "header": [], 2835 | "body": { 2836 | "mode": "formdata", 2837 | "formdata": [ 2838 | { 2839 | "key": "main_photo", 2840 | "type": "file", 2841 | "src": "/C:/Users/ppuda/Downloads/received_160043772859895.jpeg" 2842 | }, 2843 | { 2844 | "key": "cover_photo", 2845 | "type": "file", 2846 | "src": "/C:/Users/ppuda/Downloads/received_160043772859895.jpeg" 2847 | } 2848 | ] 2849 | }, 2850 | "url": { 2851 | "raw": "{{host}}/competition/:compId", 2852 | "host": ["{{host}}"], 2853 | "path": ["competition", ":compId"], 2854 | "variable": [ 2855 | { 2856 | "key": "compId", 2857 | "value": "60eb1584913b4dbc3f6a15cc" 2858 | } 2859 | ] 2860 | } 2861 | }, 2862 | "response": [] 2863 | }, 2864 | { 2865 | "name": "Add a user as a moderator", 2866 | "event": [ 2867 | { 2868 | "listen": "test", 2869 | "script": { 2870 | "exec": [ 2871 | "pm.test(\"Status code is 200\", function () {\r", 2872 | " pm.response.to.have.status(200);\r", 2873 | "});\r", 2874 | "pm.test(\"Sucessfully added user\", function () {\r", 2875 | " pm.expect(pm.response.text()).to.include(\"success\");\r", 2876 | "});\r", 2877 | "" 2878 | ], 2879 | "type": "text/javascript" 2880 | } 2881 | } 2882 | ], 2883 | "request": { 2884 | "method": "POST", 2885 | "header": [], 2886 | "url": { 2887 | "raw": "{{host}}/competition/:compId/ADD/MODERATOR/:userId", 2888 | "host": ["{{host}}"], 2889 | "path": ["competition", ":compId", "ADD", "MODERATOR", ":userId"], 2890 | "variable": [ 2891 | { 2892 | "key": "compId", 2893 | "value": "60eb0eac913b4dbc3f6a15bf" 2894 | }, 2895 | { 2896 | "key": "userId", 2897 | "value": "608903eb190fa608902390e2" 2898 | } 2899 | ] 2900 | } 2901 | }, 2902 | "response": [] 2903 | }, 2904 | { 2905 | "name": "Remove a user as a moderator", 2906 | "event": [ 2907 | { 2908 | "listen": "test", 2909 | "script": { 2910 | "exec": [ 2911 | "pm.test(\"Status code is 200\", function () {\r", 2912 | " pm.response.to.have.status(200);\r", 2913 | "});\r", 2914 | "pm.test(\"Sucessfully removed user\", function () {\r", 2915 | " pm.expect(pm.response.text()).to.include(\"success\");\r", 2916 | "});\r", 2917 | "" 2918 | ], 2919 | "type": "text/javascript" 2920 | } 2921 | } 2922 | ], 2923 | "request": { 2924 | "method": "POST", 2925 | "header": [], 2926 | "url": { 2927 | "raw": "{{host}}/competition/:competitionId/REMOVE/MODERATOR/:userId", 2928 | "host": ["{{host}}"], 2929 | "path": [ 2930 | "competition", 2931 | ":competitionId", 2932 | "REMOVE", 2933 | "MODERATOR", 2934 | ":userId" 2935 | ], 2936 | "variable": [ 2937 | { 2938 | "key": "competitionId", 2939 | "value": "60eb10bb913b4dbc3f6a15c0" 2940 | }, 2941 | { 2942 | "key": "userId", 2943 | "value": "608903eb190fa608902390e2" 2944 | } 2945 | ] 2946 | } 2947 | }, 2948 | "response": [] 2949 | }, 2950 | { 2951 | "name": "Add a user as an admin", 2952 | "event": [ 2953 | { 2954 | "listen": "test", 2955 | "script": { 2956 | "exec": [ 2957 | "pm.test(\"Status code is 200\", function () {\r", 2958 | " pm.response.to.have.status(200);\r", 2959 | "});\r", 2960 | "pm.test(\"Sucessfully added user as admin\", function () {\r", 2961 | " pm.expect(pm.response.text()).to.include(\"success\");\r", 2962 | "});\r", 2963 | "" 2964 | ], 2965 | "type": "text/javascript" 2966 | } 2967 | } 2968 | ], 2969 | "request": { 2970 | "method": "POST", 2971 | "header": [], 2972 | "url": { 2973 | "raw": "{{host}}/competition/:competitionId/ADD/ADMIN/:userId", 2974 | "host": ["{{host}}"], 2975 | "path": [ 2976 | "competition", 2977 | ":competitionId", 2978 | "ADD", 2979 | "ADMIN", 2980 | ":userId" 2981 | ], 2982 | "variable": [ 2983 | { 2984 | "key": "competitionId", 2985 | "value": "60eb10bb913b4dbc3f6a15c0" 2986 | }, 2987 | { 2988 | "key": "userId", 2989 | "value": "608903eb190fa608902390e2" 2990 | } 2991 | ] 2992 | } 2993 | }, 2994 | "response": [] 2995 | }, 2996 | { 2997 | "name": "Remove a user as an admin", 2998 | "event": [ 2999 | { 3000 | "listen": "test", 3001 | "script": { 3002 | "exec": [ 3003 | "pm.test(\"Status code is 200\", function () {\r", 3004 | " pm.response.to.have.status(200);\r", 3005 | "});\r", 3006 | "pm.test(\"Sucessfully removed user as admin\", function () {\r", 3007 | " pm.expect(pm.response.text()).to.include(\"success\");\r", 3008 | "});\r", 3009 | "" 3010 | ], 3011 | "type": "text/javascript" 3012 | } 3013 | } 3014 | ], 3015 | "request": { 3016 | "method": "POST", 3017 | "header": [], 3018 | "url": { 3019 | "raw": "{{host}}/competition/:competitionId/REMOVE/ADMIN/:userId", 3020 | "host": ["{{host}}"], 3021 | "path": [ 3022 | "competition", 3023 | ":competitionId", 3024 | "REMOVE", 3025 | "ADMIN", 3026 | ":userId" 3027 | ], 3028 | "variable": [ 3029 | { 3030 | "key": "competitionId", 3031 | "value": "60eb10bb913b4dbc3f6a15c0" 3032 | }, 3033 | { 3034 | "key": "userId", 3035 | "value": "608903eb190fa608902390e2" 3036 | } 3037 | ] 3038 | } 3039 | }, 3040 | "response": [] 3041 | }, 3042 | { 3043 | "name": "Add a user as an Editor", 3044 | "event": [ 3045 | { 3046 | "listen": "test", 3047 | "script": { 3048 | "exec": [ 3049 | "pm.test(\"Status code is 200\", function () {\r", 3050 | " pm.response.to.have.status(200);\r", 3051 | "});\r", 3052 | "pm.test(\"Sucessfully added user as editor\", function () {\r", 3053 | " pm.expect(pm.response.text()).to.include(\"success\");\r", 3054 | "});\r", 3055 | "" 3056 | ], 3057 | "type": "text/javascript" 3058 | } 3059 | } 3060 | ], 3061 | "request": { 3062 | "method": "POST", 3063 | "header": [], 3064 | "url": { 3065 | "raw": "{{host}}/competition/:competitionId/ADD/EDITOR/:userId", 3066 | "host": ["{{host}}"], 3067 | "path": [ 3068 | "competition", 3069 | ":competitionId", 3070 | "ADD", 3071 | "EDITOR", 3072 | ":userId" 3073 | ], 3074 | "variable": [ 3075 | { 3076 | "key": "competitionId", 3077 | "value": "60eb10bb913b4dbc3f6a15c0" 3078 | }, 3079 | { 3080 | "key": "userId", 3081 | "value": "608903eb190fa608902390e2" 3082 | } 3083 | ] 3084 | } 3085 | }, 3086 | "response": [] 3087 | }, 3088 | { 3089 | "name": "Remove a user as a Editor", 3090 | "event": [ 3091 | { 3092 | "listen": "test", 3093 | "script": { 3094 | "exec": [ 3095 | "pm.test(\"Status code is 200\", function () {\r", 3096 | " pm.response.to.have.status(200);\r", 3097 | "});\r", 3098 | "pm.test(\"Sucessfully removed user as editor\", function () {\r", 3099 | " pm.expect(pm.response.text()).to.include(\"success\");\r", 3100 | "});\r", 3101 | "" 3102 | ], 3103 | "type": "text/javascript" 3104 | } 3105 | } 3106 | ], 3107 | "request": { 3108 | "method": "POST", 3109 | "header": [], 3110 | "url": { 3111 | "raw": "{{host}}/competition/:competitionId/REMOVE/EDITOR/:userId", 3112 | "host": ["{{host}}"], 3113 | "path": [ 3114 | "competition", 3115 | ":competitionId", 3116 | "REMOVE", 3117 | "EDITOR", 3118 | ":userId" 3119 | ], 3120 | "variable": [ 3121 | { 3122 | "key": "competitionId", 3123 | "value": "60eb10bb913b4dbc3f6a15c0" 3124 | }, 3125 | { 3126 | "key": "userId", 3127 | "value": "608903eb190fa608902390e2" 3128 | } 3129 | ] 3130 | } 3131 | }, 3132 | "response": [] 3133 | }, 3134 | { 3135 | "name": "Remove a post from a competition", 3136 | "event": [ 3137 | { 3138 | "listen": "test", 3139 | "script": { 3140 | "exec": [ 3141 | "pm.test(\"Status code is 200\", function () {\r", 3142 | " pm.response.to.have.status(200);\r", 3143 | "});" 3144 | ], 3145 | "type": "text/javascript" 3146 | } 3147 | } 3148 | ], 3149 | "request": { 3150 | "method": "POST", 3151 | "header": [], 3152 | "url": { 3153 | "raw": "{{host}}/competition/:compId/remove-post/:postId", 3154 | "host": ["{{host}}"], 3155 | "path": ["competition", ":compId", "remove-post", ":postId"], 3156 | "variable": [ 3157 | { 3158 | "key": "compId", 3159 | "value": "60eb15c0913b4dbc3f6a15cd", 3160 | "description": "Competition _id" 3161 | }, 3162 | { 3163 | "key": "postId", 3164 | "value": "60eb15f7913b4dbc3f6a15ce", 3165 | "description": "Post _id" 3166 | } 3167 | ] 3168 | } 3169 | }, 3170 | "response": [] 3171 | }, 3172 | { 3173 | "name": "Add Sponser", 3174 | "event": [ 3175 | { 3176 | "listen": "test", 3177 | "script": { 3178 | "exec": [ 3179 | "pm.test(\"Status code is 200\", function () {\r", 3180 | " pm.response.to.have.status(200);\r", 3181 | "});\r", 3182 | "pm.test(\"Sponser added \", function () {\r", 3183 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 3184 | "});\r", 3185 | "" 3186 | ], 3187 | "type": "text/javascript" 3188 | } 3189 | } 3190 | ], 3191 | "request": { 3192 | "method": "POST", 3193 | "header": [], 3194 | "body": { 3195 | "mode": "raw", 3196 | "raw": "{\r\n \"companyID\":\"60903f29b1d4500438efe98b\",\r\n \"sponser_type\":\"Technical Support\"\r\n}", 3197 | "options": { 3198 | "raw": { 3199 | "language": "json" 3200 | } 3201 | } 3202 | }, 3203 | "url": { 3204 | "raw": "{{host}}/competition/:competitionId/add/sponser", 3205 | "host": ["{{host}}"], 3206 | "path": ["competition", ":competitionId", "add", "sponser"], 3207 | "variable": [ 3208 | { 3209 | "key": "competitionId", 3210 | "value": "60eb10bb913b4dbc3f6a15c0" 3211 | } 3212 | ] 3213 | } 3214 | }, 3215 | "response": [] 3216 | }, 3217 | { 3218 | "name": "Remove Sponser", 3219 | "event": [ 3220 | { 3221 | "listen": "test", 3222 | "script": { 3223 | "exec": [ 3224 | "pm.test(\"Status code is 200\", function () {\r", 3225 | " pm.response.to.have.status(200);\r", 3226 | "});\r", 3227 | "pm.test(\"Sponser added \", function () {\r", 3228 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 3229 | "});\r", 3230 | "" 3231 | ], 3232 | "type": "text/javascript" 3233 | } 3234 | } 3235 | ], 3236 | "request": { 3237 | "method": "POST", 3238 | "header": [], 3239 | "body": { 3240 | "mode": "raw", 3241 | "raw": "{\r\n \"sponserID\":\"60c9e7138faaef85c14ae65b\"\r\n}", 3242 | "options": { 3243 | "raw": { 3244 | "language": "json" 3245 | } 3246 | } 3247 | }, 3248 | "url": { 3249 | "raw": "{{host}}/competition/:competitionId/remove/sponser", 3250 | "host": ["{{host}}"], 3251 | "path": ["competition", ":competitionId", "remove", "sponser"], 3252 | "variable": [ 3253 | { 3254 | "key": "competitionId", 3255 | "value": "60eb10bb913b4dbc3f6a15c0" 3256 | } 3257 | ] 3258 | } 3259 | }, 3260 | "response": [] 3261 | }, 3262 | { 3263 | "name": "Update sponser", 3264 | "event": [ 3265 | { 3266 | "listen": "test", 3267 | "script": { 3268 | "exec": [ 3269 | "pm.test(\"Status code is 200\", function () {\r", 3270 | " pm.response.to.have.status(200);\r", 3271 | "});\r", 3272 | "\r", 3273 | "pm.test(\"Sponser updated by new id \", function () {\r", 3274 | " pm.expect(pm.response.text()).to.include(\"_id\");\r", 3275 | "});\r", 3276 | "" 3277 | ], 3278 | "type": "text/javascript" 3279 | } 3280 | } 3281 | ], 3282 | "request": { 3283 | "method": "PUT", 3284 | "header": [], 3285 | "body": { 3286 | "mode": "raw", 3287 | "raw": "{\r\n \"sponser_type\":\"2nd etdchnical Partner\"\r\n}", 3288 | "options": { 3289 | "raw": { 3290 | "language": "json" 3291 | } 3292 | } 3293 | }, 3294 | "url": { 3295 | "raw": "{{host}}/competition/:competitionId/update/sponser/:sponserId", 3296 | "host": ["{{host}}"], 3297 | "path": [ 3298 | "competition", 3299 | ":competitionId", 3300 | "update", 3301 | "sponser", 3302 | ":sponserId" 3303 | ], 3304 | "variable": [ 3305 | { 3306 | "key": "competitionId", 3307 | "value": "60eb10bb913b4dbc3f6a15c0" 3308 | }, 3309 | { 3310 | "key": "sponserId", 3311 | "value": "60eb1354913b4dbc3f6a15c4" 3312 | } 3313 | ] 3314 | } 3315 | }, 3316 | "response": [] 3317 | }, 3318 | { 3319 | "name": "Calculate Winners", 3320 | "request": { 3321 | "method": "POST", 3322 | "header": [], 3323 | "body": { 3324 | "mode": "raw", 3325 | "raw": "[\r\n {\r\n \"name\":\"Most Likes\",\r\n \"count\":3,\r\n \"prizes\":[\r\n \"Rs 3500\",\r\n \"Rs 3000\",\r\n \"Rs 2000\"\r\n ]\r\n },\r\n {\r\n \"name\":\"Most Comments\",\r\n \"count\":2,\r\n \"prizes\":[\r\n \"Rs 500\",\r\n \"Rs 100\"\r\n ]\r\n }\r\n]", 3326 | "options": { 3327 | "raw": { 3328 | "language": "json" 3329 | } 3330 | } 3331 | }, 3332 | "url": { 3333 | "raw": "{{host}}/competition/:compId/calculate/winners", 3334 | "host": ["{{host}}"], 3335 | "path": ["competition", ":compId", "calculate", "winners"], 3336 | "variable": [ 3337 | { 3338 | "key": "compId", 3339 | "value": "60c9e6f58faaef85c14ae65a" 3340 | } 3341 | ] 3342 | } 3343 | }, 3344 | "response": [] 3345 | }, 3346 | { 3347 | "name": "Add Awards for a competition", 3348 | "request": { 3349 | "method": "PUT", 3350 | "header": [], 3351 | "body": { 3352 | "mode": "raw", 3353 | "raw": "{\n \"name\":\"Most Liked [updated]\",\n \"description\":\"Winner le Mero asirbaad pauxau\"\n}", 3354 | "options": { 3355 | "raw": { 3356 | "language": "json" 3357 | } 3358 | } 3359 | }, 3360 | "url": { 3361 | "raw": "{{host}}/competition/:compId/award/:awardId", 3362 | "host": ["{{host}}"], 3363 | "path": ["competition", ":compId", "award", ":awardId"], 3364 | "variable": [ 3365 | { 3366 | "key": "compId", 3367 | "value": "60c9e6f58faaef85c14ae65a" 3368 | }, 3369 | { 3370 | "key": "awardId", 3371 | "value": "60f44f1cf1d7e2176f8ddfd2" 3372 | } 3373 | ] 3374 | } 3375 | }, 3376 | "response": [] 3377 | }, 3378 | { 3379 | "name": "Update Award for a competition", 3380 | "request": { 3381 | "method": "POST", 3382 | "header": [], 3383 | "body": { 3384 | "mode": "raw", 3385 | "raw": "{\n \"name\":\"Most Liked\",\n \"description\":\"As the name suggests most liked means that the post in this comeptition with most likes wins TVS tyre signed cricket bat\"\n}", 3386 | "options": { 3387 | "raw": { 3388 | "language": "json" 3389 | } 3390 | } 3391 | }, 3392 | "url": { 3393 | "raw": "{{host}}/competition/:compId/add/award", 3394 | "host": ["{{host}}"], 3395 | "path": ["competition", ":compId", "add", "award"], 3396 | "variable": [ 3397 | { 3398 | "key": "compId", 3399 | "value": "60c9e6f58faaef85c14ae65a" 3400 | } 3401 | ] 3402 | } 3403 | }, 3404 | "response": [] 3405 | }, 3406 | { 3407 | "name": "Remove Award for a competition", 3408 | "request": { 3409 | "method": "DELETE", 3410 | "header": [], 3411 | "body": { 3412 | "mode": "raw", 3413 | "raw": "{\n \"name\":\"Most Liked\",\n \"description\":\"As the name suggests most liked means that the post in this comeptition with most likes wins TVS tyre signed cricket bat\"\n}", 3414 | "options": { 3415 | "raw": { 3416 | "language": "json" 3417 | } 3418 | } 3419 | }, 3420 | "url": { 3421 | "raw": "{{host}}/competition/:compId/remove/award/:award_id", 3422 | "host": ["{{host}}"], 3423 | "path": [ 3424 | "competition", 3425 | ":compId", 3426 | "remove", 3427 | "award", 3428 | ":award_id" 3429 | ], 3430 | "variable": [ 3431 | { 3432 | "key": "compId", 3433 | "value": "60c9e6f58faaef85c14ae65a" 3434 | }, 3435 | { 3436 | "key": "award_id", 3437 | "value": "60f44601caf9e40e90c4f4f8" 3438 | } 3439 | ] 3440 | } 3441 | }, 3442 | "response": [] 3443 | } 3444 | ] 3445 | }, 3446 | { 3447 | "name": "Company", 3448 | "item": [ 3449 | { 3450 | "name": "Get all companies", 3451 | "request": { 3452 | "auth": { 3453 | "type": "noauth" 3454 | }, 3455 | "method": "GET", 3456 | "header": [], 3457 | "url": "{{host}}/company/all" 3458 | }, 3459 | "response": [] 3460 | }, 3461 | { 3462 | "name": "Create a company", 3463 | "request": { 3464 | "method": "POST", 3465 | "header": [], 3466 | "body": { 3467 | "mode": "formdata", 3468 | "formdata": [ 3469 | { 3470 | "key": "name", 3471 | "value": "MongoDb", 3472 | "type": "text" 3473 | }, 3474 | { 3475 | "key": "contact", 3476 | "value": "98412221121", 3477 | "type": "text" 3478 | }, 3479 | { 3480 | "key": "company_image", 3481 | "type": "file", 3482 | "src": "/C:/Users/alphawolfnirjal/Pictures/MongoDB-logo.png" 3483 | }, 3484 | { 3485 | "key": "address", 3486 | "value": "New York, New York, United States", 3487 | "type": "text" 3488 | }, 3489 | { 3490 | "key": "links[0][name]", 3491 | "value": "Facebook", 3492 | "type": "text" 3493 | }, 3494 | { 3495 | "key": "links[0][url]", 3496 | "value": "fb.com/MongoDB", 3497 | "type": "text" 3498 | }, 3499 | { 3500 | "key": "links[1][name]", 3501 | "value": "Insta", 3502 | "type": "text" 3503 | }, 3504 | { 3505 | "key": "links[1][url]", 3506 | "value": "instagram.com/monogdb", 3507 | "type": "text" 3508 | } 3509 | ] 3510 | }, 3511 | "url": "{{host}}/company/create" 3512 | }, 3513 | "response": [] 3514 | }, 3515 | { 3516 | "name": "Delete a company", 3517 | "request": { 3518 | "method": "DELETE", 3519 | "header": [], 3520 | "url": { 3521 | "raw": "{{host}}/company/:companyId", 3522 | "host": ["{{host}}"], 3523 | "path": ["company", ":companyId"], 3524 | "variable": [ 3525 | { 3526 | "key": "companyId", 3527 | "value": "60e7028d7df1862abcffa366" 3528 | } 3529 | ] 3530 | } 3531 | }, 3532 | "response": [] 3533 | }, 3534 | { 3535 | "name": "Get companies by ID", 3536 | "request": { 3537 | "auth": { 3538 | "type": "noauth" 3539 | }, 3540 | "method": "GET", 3541 | "header": [], 3542 | "url": { 3543 | "raw": "{{host}}/company/:companyId", 3544 | "host": ["{{host}}"], 3545 | "path": ["company", ":companyId"], 3546 | "variable": [ 3547 | { 3548 | "key": "companyId", 3549 | "value": "60903f29b1d4500438efe98b" 3550 | } 3551 | ] 3552 | } 3553 | }, 3554 | "response": [] 3555 | }, 3556 | { 3557 | "name": "Update Company", 3558 | "request": { 3559 | "method": "PUT", 3560 | "header": [], 3561 | "body": { 3562 | "mode": "formdata", 3563 | "formdata": [ 3564 | { 3565 | "key": "company_image", 3566 | "type": "file", 3567 | "src": "/C:/Users/alphawolfnirjal/Pictures/MongoDB-logo.png" 3568 | } 3569 | ] 3570 | }, 3571 | "url": "{{host}}/company/60903f19b1d4500438efe988" 3572 | }, 3573 | "response": [] 3574 | } 3575 | ] 3576 | }, 3577 | { 3578 | "name": "Report", 3579 | "item": [ 3580 | { 3581 | "name": "Report a post", 3582 | "request": { 3583 | "method": "POST", 3584 | "header": [], 3585 | "body": { 3586 | "mode": "raw", 3587 | "raw": "{\r\n \"type\":\"Sexually Inappropiate\" \r\n}", 3588 | "options": { 3589 | "raw": { 3590 | "language": "json" 3591 | } 3592 | } 3593 | }, 3594 | "url": { 3595 | "raw": "{{host}}/report/:postId", 3596 | "host": ["{{host}}"], 3597 | "path": ["report", ":postId"], 3598 | "variable": [ 3599 | { 3600 | "key": "postId", 3601 | "value": "60f064d3bbc8953c783efa36" 3602 | } 3603 | ] 3604 | } 3605 | }, 3606 | "response": [] 3607 | }, 3608 | { 3609 | "name": "By type", 3610 | "request": { 3611 | "method": "GET", 3612 | "header": [], 3613 | "url": "{{host}}/report/type/Sexually Inappropiate" 3614 | }, 3615 | "response": [] 3616 | }, 3617 | { 3618 | "name": "All open requets", 3619 | "request": { 3620 | "method": "GET", 3621 | "header": [], 3622 | "url": { 3623 | "raw": "{{host}}/report/is-open?rlimit=10&rskip=0", 3624 | "host": ["{{host}}"], 3625 | "path": ["report", "is-open"], 3626 | "query": [ 3627 | { 3628 | "key": "rlimit", 3629 | "value": "10" 3630 | }, 3631 | { 3632 | "key": "rskip", 3633 | "value": "0" 3634 | } 3635 | ] 3636 | } 3637 | }, 3638 | "response": [] 3639 | }, 3640 | { 3641 | "name": "Get one report", 3642 | "request": { 3643 | "auth": { 3644 | "type": "noauth" 3645 | }, 3646 | "method": "GET", 3647 | "header": [], 3648 | "url": { 3649 | "raw": "{{host}}/report/:reportId", 3650 | "host": ["{{host}}"], 3651 | "path": ["report", ":reportId"], 3652 | "variable": [ 3653 | { 3654 | "key": "reportId", 3655 | "value": "60aa01b8dde1f01f0007ae87", 3656 | "description": "Report id" 3657 | } 3658 | ] 3659 | } 3660 | }, 3661 | "response": [] 3662 | }, 3663 | { 3664 | "name": "Close a report", 3665 | "request": { 3666 | "method": "GET", 3667 | "header": [], 3668 | "url": { 3669 | "raw": "{{host}}/report/:reportId/close", 3670 | "host": ["{{host}}"], 3671 | "path": ["report", ":reportId", "close"], 3672 | "variable": [ 3673 | { 3674 | "key": "reportId", 3675 | "value": "60e7031cd7598f16c8e6c25d" 3676 | } 3677 | ] 3678 | } 3679 | }, 3680 | "response": [] 3681 | }, 3682 | { 3683 | "name": "Get all requests from one time to another", 3684 | "request": { 3685 | "method": "GET", 3686 | "header": [], 3687 | "url": { 3688 | "raw": "{{host}}/report/time-stamps?startDate=05-22-2021&endDate=07-30-2021", 3689 | "host": ["{{host}}"], 3690 | "path": ["report", "time-stamps"], 3691 | "query": [ 3692 | { 3693 | "key": "startDate", 3694 | "value": "05-22-2021", 3695 | "description": "Required" 3696 | }, 3697 | { 3698 | "key": "endDate", 3699 | "value": "07-30-2021", 3700 | "description": "Required" 3701 | } 3702 | ] 3703 | } 3704 | }, 3705 | "response": [] 3706 | }, 3707 | { 3708 | "name": "Hide the post", 3709 | "request": { 3710 | "method": "POST", 3711 | "header": [], 3712 | "url": { 3713 | "raw": "{{host}}/report/:reportId/hide-post", 3714 | "host": ["{{host}}"], 3715 | "path": ["report", ":reportId", "hide-post"], 3716 | "variable": [ 3717 | { 3718 | "key": "reportId", 3719 | "value": "60e7031cd7598f16c8e6c25d" 3720 | } 3721 | ] 3722 | } 3723 | }, 3724 | "response": [] 3725 | } 3726 | ] 3727 | }, 3728 | { 3729 | "name": "Beta Features", 3730 | "item": [ 3731 | { 3732 | "name": "Get a followers for userId [NEW]", 3733 | "request": { 3734 | "method": "GET", 3735 | "header": [], 3736 | "url": { 3737 | "raw": "{{host}}/alpha/followers-for/:userId", 3738 | "host": ["{{host}}"], 3739 | "path": ["alpha", "followers-for", ":userId"], 3740 | "variable": [ 3741 | { 3742 | "key": "userId", 3743 | "value": "608903eb190fa608902390e2", 3744 | "description": "Test User ko" 3745 | } 3746 | ] 3747 | } 3748 | }, 3749 | "response": [] 3750 | }, 3751 | { 3752 | "name": "Get a followings for userId [NEW] Copy", 3753 | "request": { 3754 | "method": "GET", 3755 | "header": [], 3756 | "url": { 3757 | "raw": "{{host}}/alpha/followings-for/:userId", 3758 | "host": ["{{host}}"], 3759 | "path": ["alpha", "followings-for", ":userId"], 3760 | "variable": [ 3761 | { 3762 | "key": "userId", 3763 | "value": "6090ee7a5a27f23eba53b26c", 3764 | "description": "Dipesh dai" 3765 | } 3766 | ] 3767 | } 3768 | }, 3769 | "response": [] 3770 | }, 3771 | { 3772 | "name": "Get Followers with friend", 3773 | "request": { 3774 | "method": "GET", 3775 | "header": [], 3776 | "url": { 3777 | "raw": "{{host}}/alpha/followers/:userId", 3778 | "host": ["{{host}}"], 3779 | "path": ["alpha", "followers", ":userId"], 3780 | "variable": [ 3781 | { 3782 | "key": "userId", 3783 | "value": "6090ee7a5a27f23eba53b26c", 3784 | "description": "specify kosko followers" 3785 | } 3786 | ] 3787 | } 3788 | }, 3789 | "response": [] 3790 | }, 3791 | { 3792 | "name": "Get Followings with friend", 3793 | "request": { 3794 | "method": "GET", 3795 | "header": [], 3796 | "url": { 3797 | "raw": "{{host}}/alpha/followings/:userId", 3798 | "host": ["{{host}}"], 3799 | "path": ["alpha", "followings", ":userId"], 3800 | "variable": [ 3801 | { 3802 | "key": "userId", 3803 | "value": "6090ee7a5a27f23eba53b26c", 3804 | "description": "specify kosko followings" 3805 | } 3806 | ] 3807 | } 3808 | }, 3809 | "response": [] 3810 | } 3811 | ] 3812 | }, 3813 | { 3814 | "name": "Extra Routes", 3815 | "item": [ 3816 | { 3817 | "name": "Get count of objects in db", 3818 | "request": { 3819 | "auth": { 3820 | "type": "noauth" 3821 | }, 3822 | "method": "GET", 3823 | "header": [], 3824 | "url": "{{host}}/stats/db/count" 3825 | }, 3826 | "response": [] 3827 | } 3828 | ] 3829 | }, 3830 | { 3831 | "name": "Firebase", 3832 | "item": [ 3833 | { 3834 | "name": "Add new token", 3835 | "request": { 3836 | "method": "POST", 3837 | "header": [], 3838 | "body": { 3839 | "mode": "raw", 3840 | "raw": "{\r\n \"token\":\"fgjbU0fWSDGdLuU_FKqMAd:APA91bFXlohl5Apnsi2pehQ4wzNBpAbNXPmx75J1x4AEWF3xL0Go_AUGgKrEkLHjSiYV8bkzCLPXW_hZaIYe_UdnyJ0gJl8qF-3-9aEqpKEvulZeCAv5nf3aM5KK04ngn_o-mGQKU6t1\"\r\n}", 3841 | "options": { 3842 | "raw": { 3843 | "language": "json" 3844 | } 3845 | } 3846 | }, 3847 | "url": "{{host}}/fcm/create-token" 3848 | }, 3849 | "response": [] 3850 | }, 3851 | { 3852 | "name": "Send Notification", 3853 | "request": { 3854 | "method": "POST", 3855 | "header": [], 3856 | "body": { 3857 | "mode": "raw", 3858 | "raw": "{\r\n \"title\":\"Kamao Nepal\",\r\n \"body\":\"Test User started following you\"\r\n}", 3859 | "options": { 3860 | "raw": { 3861 | "language": "json" 3862 | } 3863 | } 3864 | }, 3865 | "url": "{{host}}/fcm/send-test", 3866 | "description": "Sends notification to all the devices og loggedin user" 3867 | }, 3868 | "response": [] 3869 | }, 3870 | { 3871 | "name": "Delete Notification", 3872 | "request": { 3873 | "method": "DELETE", 3874 | "header": [], 3875 | "body": { 3876 | "mode": "raw", 3877 | "raw": "{\r\n \"token\":\"some existing token\"\r\n}", 3878 | "options": { 3879 | "raw": { 3880 | "language": "json" 3881 | } 3882 | } 3883 | }, 3884 | "url": "{{host}}/fcm/delete-token" 3885 | }, 3886 | "response": [] 3887 | } 3888 | ] 3889 | } 3890 | ], 3891 | "auth": { 3892 | "type": "bearer", 3893 | "bearer": { 3894 | "token": "{{testuser 30 days}}" 3895 | } 3896 | }, 3897 | "event": [ 3898 | { 3899 | "listen": "prerequest", 3900 | "script": { 3901 | "type": "text/javascript", 3902 | "exec": [""] 3903 | } 3904 | }, 3905 | { 3906 | "listen": "test", 3907 | "script": { 3908 | "type": "text/javascript", 3909 | "exec": [""] 3910 | } 3911 | } 3912 | ], 3913 | "variable": [ 3914 | { 3915 | "key": "host", 3916 | "value": "localhost:3001" 3917 | }, 3918 | { 3919 | "key": "testuser 30 days", 3920 | "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDg5MDNlYjE5MGZhNjA4OTAyMzkwZTIiLCJpYXQiOjE2MjU4MzI5MTksImV4cCI6MTYyODQyNDkxOX0.RmOC3eGuYexlwWsdNq6Z72hVVsVk-5saXJfMTzWObDk" 3921 | }, 3922 | { 3923 | "key": "prabesh 30 days", 3924 | "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDhlZDYxNTVlM2U5OTRlMDBlZjE1ZTAiLCJpYXQiOjE2MjU4MzI5NjAsImV4cCI6MTYyODQyNDk2MH0.elSJ0Z8U_ZF3dgV7uP-V2ma37Mrj1flNJCnJidVkVUE" 3925 | }, 3926 | { 3927 | "value": "" 3928 | } 3929 | ] 3930 | } 3931 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | const assert = require("assert"); 2 | --------------------------------------------------------------------------------