[
  {
    "path": ".circleci/config.yml",
    "content": "version: 2\n\naliases:\n  - &restore-cache\n    restore_cache:\n      name: Restore Yarn Package Cache\n      keys:\n        - yarn-packages-{{ checksum \"yarn.lock\" }}\n  - &install-deps\n    run:\n      name: Install dependencies\n      command: yarn\n  - &build-packages\n    run:\n      name: Build\n      command: npm run build\n\njobs:\n  build:\n    working_directory: ~/nest\n    docker:\n      - image: cimg/node:20.3\n    steps:\n      - checkout\n      - restore_cache:\n          name: Restore Yarn Package Cache\n          keys:\n            - yarn-packages-{{ checksum \"yarn.lock\" }}\n      - run:\n          name: Install dependencies\n          command: yarn\n      - save_cache:\n          name: Save Yarn Package Cache\n          key: yarn-packages-{{ checksum \"yarn.lock\" }}\n          paths:\n            - ~/.cache/yarn\n      - run:\n          name: Build\n          command: npm run build\n\n  unit_tests:\n    working_directory: ~/nest\n    docker:\n      - image: cimg/node:20.3\n    steps:\n      - checkout\n      - restore_cache:\n          name: Restore Yarn Package Cache\n          keys:\n            - yarn-packages-{{ checksum \"yarn.lock\" }}\n      - run:\n          name: Install dependencies\n          command: yarn\n      - save_cache:\n          name: Save Yarn Package Cache\n          key: yarn-packages-{{ checksum \"yarn.lock\" }}\n          paths:\n            - ~/.cache/yarn\n      - run:\n          name: Tests\n          command: npm run test\n\nworkflows:\n  version: 2\n  build-and-test:\n    jobs:\n      - build\n      - unit_tests:\n          requires:\n            - build\n"
  },
  {
    "path": ".commitlintrc.json",
    "content": "{\n  \"extends\": [\"@commitlint/config-angular\"],\n  \"rules\": {\n    \"subject-case\": [\n      2,\n      \"always\",\n      [\"sentence-case\", \"start-case\", \"pascal-case\", \"upper-case\", \"lower-case\"]\n    ],\n    \"type-enum\": [\n      2,\n      \"always\",\n      [\n        \"build\",\n        \"chore\",\n        \"ci\",\n        \"docs\",\n        \"feat\",\n        \"fix\",\n        \"perf\",\n        \"refactor\",\n        \"revert\",\n        \"style\",\n        \"test\",\n        \"sample\"\n      ]\n    ]\n  }\n}\n"
  },
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n  parser: '@typescript-eslint/parser',\n  parserOptions: {\n    project: 'tsconfig.json',\n    sourceType: 'module'\n  },\n  plugins: ['@typescript-eslint/eslint-plugin'],\n  extends: [\n    'plugin:@typescript-eslint/eslint-recommended',\n    'plugin:@typescript-eslint/recommended',\n    'prettier'\n  ],\n  root: true,\n  env: {\n    node: true,\n    jest: true\n  },\n  rules: {\n    '@typescript-eslint/interface-name-prefix': 'off',\n    '@typescript-eslint/explicit-function-return-type': 'off',\n    '@typescript-eslint/no-explicit-any': 'off'\n  }\n};\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "<!--\nPLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.\n\nISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.\n-->\n\n## I'm submitting a...\n<!-- \nPlease search GitHub for a similar issue or PR before submitting.\nCheck one of the following options with \"x\" -->\n<pre><code>\n[ ] Regression <!--(a behavior that used to work and stopped working in a new release)-->\n[ ] Bug report\n[ ] Feature request\n[ ] Documentation issue or request\n[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.\n</code></pre>\n\n## Current behavior\n<!-- Describe how the issue manifests. -->\n\n\n## Expected behavior\n<!-- Describe what the desired behavior would be. -->\n\n\n## Minimal reproduction of the problem with instructions\n<!-- Please share a repo, a gist, or step-by-step instructions. -->\n\n## What is the motivation / use case for changing the behavior?\n<!-- Describe the motivation or the concrete use case. -->\n\n\n## Environment\n\n<pre><code>\nNest version: X.Y.Z\n<!-- Check whether this is still an issue in the most recent Nest version -->\n \nFor Tooling issues:\n- Node version: XX  <!-- run `node --version` -->\n- Platform:  <!-- Mac, Linux, Windows -->\n\nOthers:\n<!-- Anything else relevant?  Operating system version, IDE, package manager, ... -->\n</code></pre>\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "## PR Checklist\nPlease check if your PR fulfills the following requirements:\n\n- [ ] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md\n- [ ] Tests for the changes have been added (for bug fixes / features)\n- [ ] Docs have been added / updated (for bug fixes / features)\n\n\n## PR Type\nWhat kind of change does this PR introduce?\n\n<!-- Please check the one that applies to this PR using \"x\". -->\n- [ ] Bugfix\n- [ ] Feature\n- [ ] Code style update (formatting, local variables)\n- [ ] Refactoring (no functional changes, no api changes)\n- [ ] Build related changes\n- [ ] CI related changes\n- [ ] Other... Please describe:\n\n## What is the current behavior?\n<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->\n\nIssue Number: N/A\n\n\n## What is the new behavior?\n\n\n## Does this PR introduce a breaking change?\n- [ ] Yes\n- [ ] No\n\n<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->\n\n\n## Other information\n"
  },
  {
    "path": ".gitignore",
    "content": "# dependencies\n/node_modules\n\n# IDE\n/.idea\n/.awcache\n/.vscode\n\n# misc\nnpm-debug.log\n.DS_Store\n\n# tests\n/test\n/coverage\n/.nyc_output\n\n# source\ndist\n\n# schematics\nschematics/install/*.js\nschematics/install/*.d.ts\nschematics/install/express-engine/*.js\nschematics/install/express-engine/*.d.ts"
  },
  {
    "path": ".npmignore",
    "content": "# source\nlib\n/index.ts\npackage-lock.json\ntslint.json\n.prettierrc\n\n# schematics\nschematics/install/*.ts\nschematics/install/express-engine/*.ts\n\n# misc\n.DS_Store"
  },
  {
    "path": ".prettierignore",
    "content": "schematics/install/files/**/*.ts"
  },
  {
    "path": ".prettierrc",
    "content": "{\n  \"trailingComma\": \"none\",\n  \"singleQuote\": true\n}"
  },
  {
    "path": ".release-it.json",
    "content": "{\n  \"git\": {\n    \"commitMessage\": \"chore(): release v${version}\"\n  },\n  \"github\": {\n    \"release\": true\n  }\n}\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to Nest\n\nWe would love for you to contribute to Nest and help make it even better than it is\ntoday! As a contributor, here are the guidelines we would like you to follow:\n\n - [Code of Conduct](#coc)\n - [Question or Problem?](#question)\n - [Issues and Bugs](#issue)\n - [Feature Requests](#feature)\n - [Submission Guidelines](#submit)\n - [Coding Rules](#rules)\n - [Commit Message Guidelines](#commit)\n <!-- - [Signing the CLA](#cla) -->\n\n<!-- ## <a name=\"coc\"></a> Code of Conduct\nHelp us keep Nest open and inclusive. Please read and follow our [Code of Conduct][coc]. -->\n\n## <a name=\"question\"></a> Got a Question or Problem?\n\n**Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests.** You've got much better chances of getting your question answered on [Stack Overflow](https://stackoverflow.com/questions/tagged/nestjs) where the questions should be tagged with tag `nestjs`.\n\nStack Overflow is a much better place to ask questions since:\n\n<!-- - there are thousands of people willing to help on Stack Overflow [maybe one day] -->\n- questions and answers stay available for public viewing so your question / answer might help someone else\n- Stack Overflow's voting system assures that the best answers are prominently visible.\n\nTo save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow.\n\nIf you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter].\n\n## <a name=\"issue\"></a> Found a Bug?\nIf you find a bug in the source code, you can help us by\n[submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can\n[submit a Pull Request](#submit-pr) with a fix.\n\n## <a name=\"feature\"></a> Missing a Feature?\nYou can *request* a new feature by [submitting an issue](#submit-issue) to our GitHub\nRepository. If you would like to *implement* a new feature, please submit an issue with\na proposal for your work first, to be sure that we can use it.\nPlease consider what kind of change it is:\n\n* For a **Major Feature**, first open an issue and outline your proposal so that it can be\ndiscussed. This will also allow us to better coordinate our efforts, prevent duplication of work,\nand help you to craft the change so that it is successfully accepted into the project. For your issue name, please prefix your proposal with `[discussion]`, for example \"[discussion]: your feature idea\".\n* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).\n\n## <a name=\"submit\"></a> Submission Guidelines\n\n### <a name=\"submit-issue\"></a> Submitting an Issue\n\nBefore you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available.\n\nWe want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs we will systematically ask you to provide a minimal reproduction scenario using a repository or [Gist](https://gist.github.com/). Having a live, reproducible scenario gives us wealth of important information without going back & forth to you with additional questions like:\n\n- version of NestJS used\n- 3rd-party libraries and their versions\n- and most importantly - a use-case that fails\n\n<!--\n// TODO we need to create a playground, similar to plunkr\n\nA minimal reproduce scenario using a repository or Gist allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem. If neither of these are not a suitable way to demonstrate the problem (for example for issues related to our npm packaging), please create a standalone git repository demonstrating the problem. -->\n\n<!-- We will be insisting on a minimal reproduce scenario in order to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience users often find coding problems themselves while preparing a minimal plunk. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we really need to isolate the problem before we can fix it. -->\n\nUnfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced.\n\nYou can file new issues by filling out our [new issue form](https://github.com/nestjs/nest/issues/new).\n\n\n### <a name=\"submit-pr\"></a> Submitting a Pull Request (PR)\nBefore you submit your Pull Request (PR) consider the following guidelines:\n\n1. Search [GitHub](https://github.com/nestjs/nest/pulls) for an open or closed PR\n  that relates to your submission. You don't want to duplicate effort.\n<!-- 1. Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs.\n  We cannot accept code without this. -->\n1. Fork the nestjs/nest repo.\n1. Make your changes in a new git branch:\n\n     ```shell\n     git checkout -b my-fix-branch master\n     ```\n\n1. Create your patch, **including appropriate test cases**.\n1. Follow our [Coding Rules](#rules).\n1. Run the full Nest test suite, as described in the [developer documentation][dev-doc],\n  and ensure that all tests pass.\n1. Commit your changes using a descriptive commit message that follows our\n  [commit message conventions](#commit). Adherence to these conventions\n  is necessary because release notes are automatically generated from these messages.\n\n     ```shell\n     git commit -a\n     ```\n    Note: the optional commit `-a` command line option will automatically \"add\" and \"rm\" edited files.\n\n1. Push your branch to GitHub:\n\n    ```shell\n    git push origin my-fix-branch\n    ```\n\n1. In GitHub, send a pull request to `nestjs:master`.\n* If we suggest changes then:\n  * Make the required updates.\n  * Re-run the Nest test suites to ensure tests are still passing.\n  * Rebase your branch and force push to your GitHub repository (this will update your Pull Request):\n\n    ```shell\n    git rebase master -i\n    git push -f\n    ```\n\nThat's it! Thank you for your contribution!\n\n#### After your pull request is merged\n\nAfter your pull request is merged, you can safely delete your branch and pull the changes\nfrom the main (upstream) repository:\n\n* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:\n\n    ```shell\n    git push origin --delete my-fix-branch\n    ```\n\n* Check out the master branch:\n\n    ```shell\n    git checkout master -f\n    ```\n\n* Delete the local branch:\n\n    ```shell\n    git branch -D my-fix-branch\n    ```\n\n* Update your master with the latest upstream version:\n\n    ```shell\n    git pull --ff upstream master\n    ```\n\n## <a name=\"rules\"></a> Coding Rules\nTo ensure consistency throughout the source code, keep these rules in mind as you are working:\n\n* All features or bug fixes **must be tested** by one or more specs (unit-tests).\n<!--\n// We're working on auto-documentation.\n* All public API methods **must be documented**. (Details TBC). -->\n* We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at\n  **100 characters**. An automated formatter is available, see\n  [DEVELOPER.md](docs/DEVELOPER.md#clang-format).\n\n## <a name=\"commit\"></a> Commit Message Guidelines\n\nWe have very precise rules over how our git commit messages can be formatted.  This leads to **more\nreadable messages** that are easy to follow when looking through the **project history**.  But also,\nwe use the git commit messages to **generate the Nest change log**.\n\n### Commit Message Format\nEach commit message consists of a **header**, a **body** and a **footer**.  The header has a special\nformat that includes a **type**, a **scope** and a **subject**:\n\n```\n<type>(<scope>): <subject>\n<BLANK LINE>\n<body>\n<BLANK LINE>\n<footer>\n```\n\nThe **header** is mandatory and the **scope** of the header is optional.\n\nAny line of the commit message cannot be longer 100 characters! This allows the message to be easier\nto read on GitHub as well as in various git tools.\n\nFooter should contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) if any.\n\nSamples: (even more [samples](https://github.com/nestjs/nest/commits/master))\n\n```\ndocs(changelog) update change log to beta.5\n```\n```\nfix(@nestjs/core) need to depend on latest rxjs and zone.js\n\nThe version in our package.json gets copied to the one we publish, and users need the latest of these.\n```\n\n### Revert\nIf the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.\n\n### Type\nMust be one of the following:\n\n* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)\n* **chore**: Updating tasks etc; no production code change\n* **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)\n* **docs**: Documentation only changes\n* **feat**: A new feature\n* **fix**: A bug fix\n* **perf**: A code change that improves performance\n* **refactor**: A code change that neither fixes a bug nor adds a feature\n* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)\n* **test**: Adding missing tests or correcting existing tests\n\n\n### Subject\nThe subject contains succinct description of the change:\n\n* use the imperative, present tense: \"change\" not \"changed\" nor \"changes\"\n* don't capitalize first letter\n* no dot (.) at the end\n\n### Body\nJust as in the **subject**, use the imperative, present tense: \"change\" not \"changed\" nor \"changes\".\nThe body should include the motivation for the change and contrast this with previous behavior.\n\n### Footer\nThe footer should contain any information about **Breaking Changes** and is also the place to\nreference GitHub issues that this commit **Closes**.\n\n**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.\n\nA detailed explanation can be found in this [document][commit-message-format].\n\n<!-- ## <a name=\"cla\"></a> Signing the CLA\n\nPlease sign our Contributor License Agreement (CLA) before sending pull requests. For any code\nchanges to be accepted, the CLA must be signed. It's a quick process, we promise!\n\n* For individuals we have a [simple click-through form][individual-cla].\n* For corporations we'll need you to\n  [print, sign and one of scan+email, fax or mail the form][corporate-cla]. -->\n\n\n<!-- [angular-group]: https://groups.google.com/forum/#!forum/angular -->\n<!-- [coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md -->\n[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#\n[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html\n[dev-doc]: https://github.com/nestjs/nest/blob/master/docs/DEVELOPER.md\n[github]: https://github.com/nestjs/nest\n[gitter]: https://gitter.im/nestjs/nest\n[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html\n[js-style-guide]: https://google.github.io/styleguide/jsguide.html\n[jsfiddle]: http://jsfiddle.net\n[plunker]: http://plnkr.co/edit\n[runnable]: http://runnable.com\n<!-- [stackoverflow]: http://stackoverflow.com/questions/tagged/angular -->\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017-2021 Kamil Mysliwiec <https://kamilmysliwiec.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "<p align=\"center\">\n  <a href=\"http://nestjs.com/\" target=\"blank\"><img src=\"https://nestjs.com/img/logo_text.svg\" width=\"320\" alt=\"Nest Logo\" /></a>\n</p>\n\n[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master\n[travis-url]: https://travis-ci.org/nestjs/nest\n[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux\n[linux-url]: https://travis-ci.org/nestjs/nest\n\n  <p align=\"center\">A progressive <a href=\"http://nodejs.org\" target=\"blank\">Node.js</a> framework for building efficient and scalable server-side applications.</p>\n    <p align=\"center\">\n<a href=\"https://www.npmjs.com/~nestjscore\"><img src=\"https://img.shields.io/npm/v/@nestjs/core.svg\" alt=\"NPM Version\" /></a>\n<a href=\"https://www.npmjs.com/~nestjscore\"><img src=\"https://img.shields.io/npm/l/@nestjs/core.svg\" alt=\"Package License\" /></a>\n<a href=\"https://www.npmjs.com/~nestjscore\"><img src=\"https://img.shields.io/npm/dm/@nestjs/core.svg\" alt=\"NPM Downloads\" /></a>\n<a href=\"https://coveralls.io/github/nestjs/nest?branch=master\"><img src=\"https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5\" alt=\"Coverage\" /></a>\n<a href=\"https://discord.gg/G7Qnnhy\" target=\"_blank\"><img src=\"https://img.shields.io/badge/discord-online-brightgreen.svg\" alt=\"Discord\"/></a>\n<a href=\"https://opencollective.com/nest#backer\"><img src=\"https://opencollective.com/nest/backers/badge.svg\" alt=\"Backers on Open Collective\" /></a>\n<a href=\"https://opencollective.com/nest#sponsor\"><img src=\"https://opencollective.com/nest/sponsors/badge.svg\" alt=\"Sponsors on Open Collective\" /></a>\n  <a href=\"https://paypal.me/kamilmysliwiec\"><img src=\"https://img.shields.io/badge/Donate-PayPal-dc3d53.svg\"/></a>\n  <a href=\"https://twitter.com/nestframework\"><img src=\"https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow\"></a>\n</p>\n  <!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)\n  [![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->\n\n## Description\n\n[Azure Functions](https://code.visualstudio.com/tutorials/functions-extension/getting-started) HTTP module for [Nest](https://github.com/nestjs/nest).\n\n## Installation\n\nUsing the Nest CLI:\n\n```bash\n$ nest add @nestjs/azure-func-http\n```\n\nExample output:\n\n```bash\n✔ Installation in progress... ☕\nCREATE /.funcignore (66 bytes)\nCREATE /host.json (23 bytes)\nCREATE /local.settings.json (116 bytes)\nCREATE /proxies.json (72 bytes)\nCREATE /main/function.json (294 bytes)\nCREATE /main/index.ts (287 bytes)\nCREATE /main/sample.dat (23 bytes)\nCREATE /src/main.azure.ts (321 bytes)\nUPDATE /package.json (1827 bytes)\n```\n\n## Tutorial\n\nYou can read more about this integration [here](https://trilon.io/blog/deploy-nestjs-azure-functions).\n\n## Native routing\n\nIf you don't need the compatibility with `express` library, you can use a native routing instead:\n\n```typescript\nconst app = await NestFactory.create(AppModule, new AzureHttpRouter());\n```\n\n`AzureHttpRouter` is exported from `@nestjs/azure-func-http`. Since `AzureHttpRouter` doesn't use `express` underneath, the routing itself is much faster.\n\n## Additional options\n\nYou can pass additional flags to customize the post-install schematic. For example, if your base application directory is different than `src`, use `--rootDir` flag:\n\n```bash\n$ nest add @nestjs/azure-func-http --rootDir app\n```\n\nOther available flags:\n\n- `rootModuleFileName` - the name of the root module file, default: `app.module`\n- `rootModuleClassName` - the name of the root module class, default: `AppModule`\n- `skipInstall` - skip installing dependencies, default: `false`\n\n## Support\n\nNest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).\n\n## Stay in touch\n\n- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)\n- Website - [https://nestjs.com](https://nestjs.com/)\n- Twitter - [@nestframework](https://twitter.com/nestframework)\n\n## License\n\nNest is [MIT licensed](LICENSE).\n"
  },
  {
    "path": "index.d.ts",
    "content": "export * from './dist';\n"
  },
  {
    "path": "index.js",
    "content": "\"use strict\";\nfunction __export(m) {\n    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}\nexports.__esModule = true;\n__export(require(\"./dist\"));\n"
  },
  {
    "path": "index.ts",
    "content": "export * from './dist';\n"
  },
  {
    "path": "jest.json",
    "content": "  \n{\n    \"moduleFileExtensions\": [\"js\", \"ts\"],\n    \"rootDir\": \".\",\n    \"testEnvironment\": \"node\",\n    \"testRegex\": \".(test|spec).ts$\",\n    \"transform\": {\n      \"^.+\\\\.(t|j)s$\": \"ts-jest\"\n    },\n    \"coverageDirectory\": \"./coverage\",\n    \"verbose\": true,\n    \"bail\": true,\n    \"testPathIgnorePatterns\": [\"/node_modules/\", \"files\"]\n  }"
  },
  {
    "path": "lib/adapter/azure-adapter.ts",
    "content": "import { AzureRequest } from './azure-request';\nimport { AzureReply } from './azure-reply';\n\nexport function createHandlerAdapter(handler) {\n  return context => {\n    context.res = context.res || {};\n    const req = new AzureRequest(context);\n    const res = new AzureReply(context);\n    handler(req, res);\n  };\n}\n"
  },
  {
    "path": "lib/adapter/azure-reply.ts",
    "content": "import { OutgoingMessage } from 'http';\n\nexport class AzureReply extends OutgoingMessage {\n  private readonly _headerSent: boolean;\n  private readonly outputData: { data: any }[];\n  statusCode?: number;\n\n  constructor(context: Record<string, any>) {\n    super();\n\n    // Avoid issues when data is streamed out\n    this._headerSent = true;\n\n    this.writeHead = this.writeHead.bind(this, context);\n    this.end = this.finish.bind(this, context);\n  }\n\n  writeHead(\n    context: Record<string, any>,\n    statusCode: number,\n    statusMessage: string,\n    headers: Record<string, any>\n  ) {\n    if (statusCode) {\n      this.statusCode = statusCode;\n    }\n    if (headers) {\n      const keys = Object.keys(headers);\n      for (const key of keys) {\n        this.setHeader(key, headers[key]);\n      }\n    }\n\n    context.res.status = this.statusCode;\n    context.res.headers = this.getHeaders() || {};\n  }\n\n  finish(context: Record<string, any>, body: Record<string, any> | undefined) {\n    // If data was streamed out, get it back to body\n    if (body === undefined && this.outputData.length > 0) {\n      body = Buffer.concat(\n        this.outputData.map(o =>\n          Buffer.isBuffer(o.data) ? o.data : Buffer.from(o.data)\n        )\n      );\n    }\n\n    context.res.status = this.statusCode;\n    context.res.body = body;\n    context.done();\n  }\n}\n"
  },
  {
    "path": "lib/adapter/azure-request.ts",
    "content": "import { Readable } from 'stream';\n\nexport class AzureRequest extends Readable {\n  readonly url: string;\n  readonly context: Record<string, any>;\n  readonly originalUrl: string;\n  readonly headers: Record<string, any>;\n  readonly body: any;\n\n  constructor(context: Record<string, any>) {\n    super();\n\n    Object.assign(this, context.req);\n    this.context = context;\n    this.url = this.originalUrl;\n    this.headers = this.headers || {};\n\n    // Recreate original request stream from body\n    const body = Buffer.isBuffer(context.req.body)\n      ? context.req.body\n      : context.req.rawBody;\n\n    if (body !== null && body !== undefined) {\n      this.push(body);\n    }\n    // Close the stream\n    this.push(null);\n  }\n}\n"
  },
  {
    "path": "lib/adapter/index.ts",
    "content": "export * from './azure-adapter';\nexport * from './azure-reply';\nexport * from './azure-request';\n"
  },
  {
    "path": "lib/azure-http.adapter.ts",
    "content": "/* eslint-disable @typescript-eslint/ban-types */\nimport { Context, HttpRequest } from '@azure/functions';\nimport { HttpServer, INestApplication } from '@nestjs/common';\nimport { createHandlerAdapter } from './adapter/azure-adapter';\nimport { AzureHttpRouter } from './router';\n\nlet handler: Function;\n\nexport class AzureHttpAdapterStatic {\n  handle(\n    createApp: () => Promise<INestApplication>,\n    context: Context,\n    req: HttpRequest\n  ) {\n    if (handler) {\n      return handler(context, req);\n    }\n    this.createHandler(createApp).then((fn) => fn(context, req));\n  }\n\n  private async createHandler(\n    createApp: () => Promise<\n      Omit<INestApplication, 'startAllMicroservicesAsync' | 'listenAsync'>\n    >\n  ) {\n    const app = await createApp();\n    const adapter = app.getHttpAdapter();\n    if (this.hasGetTypeMethod(adapter) && adapter.getType() === 'azure-http') {\n      return (adapter as any as AzureHttpRouter).handle.bind(adapter);\n    }\n    const instance = app.getHttpAdapter().getInstance();\n    handler = createHandlerAdapter(instance);\n    return handler;\n  }\n\n  private hasGetTypeMethod(\n    adapter: HttpServer<any, any>\n  ): adapter is HttpServer & { getType: Function } {\n    return !!(adapter as any).getType;\n  }\n}\n\nexport const AzureHttpAdapter = new AzureHttpAdapterStatic();\n"
  },
  {
    "path": "lib/index.ts",
    "content": "export * from './azure-http.adapter';\nexport * from './router';\nexport * from './adapter';\n"
  },
  {
    "path": "lib/router/azure-http.router.ts",
    "content": "/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable @typescript-eslint/no-empty-function */\nimport {\n  HttpStatus,\n  InternalServerErrorException,\n  NotImplementedException,\n  RequestMethod,\n  VersioningOptions\n} from '@nestjs/common';\nimport { VersionValue } from '@nestjs/common/interfaces';\nimport { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';\nimport { AbstractHttpAdapter } from '@nestjs/core';\nimport { RouterMethodFactory } from '@nestjs/core/helpers/router-method-factory';\nimport * as cors from 'cors';\nimport TRouter from 'trouter';\nimport { AzureReply, AzureRequest } from '../adapter';\n\nexport class AzureHttpRouter extends AbstractHttpAdapter {\n  private readonly routerMethodFactory = new RouterMethodFactory();\n\n  constructor() {\n    super(new TRouter());\n  }\n\n  public handle(context: Record<string, any>, request: any) {\n    const req = context.req;\n    const originalUrl = req.originalUrl as string;\n    const path = new URL(originalUrl).pathname;\n\n    const { params, handlers } = this.instance.find(req.method, path);\n    req.params = params;\n\n    if (handlers.length === 0) {\n      return this.handleNotFound(context, req.method, originalUrl);\n    }\n    const azureRequest = new AzureRequest(context);\n    const azureReply = new AzureReply(context);\n    const nextRoute = (i = 0) =>\n      handlers[i] &&\n      handlers[i](azureRequest, azureReply, () => nextRoute(i + 1));\n    nextRoute();\n  }\n\n  public handleNotFound(\n    context: Record<string, any>,\n    method: string,\n    originalUrl: string\n  ) {\n    context.res.status = HttpStatus.NOT_FOUND;\n    context.res.body = {\n      statusCode: HttpStatus.NOT_FOUND,\n      error: `Cannot ${method} ${originalUrl}`\n    };\n    context.done();\n    return;\n  }\n\n  public enableCors(options: CorsOptions) {\n    this.use(cors(options));\n  }\n\n  public reply(response: any, body: any, statusCode?: number) {\n    response.writeHead(statusCode);\n    response.end(body);\n  }\n\n  public status(response: any, statusCode: number) {\n    response.statusCode = statusCode;\n  }\n\n  public end(response: any, message?: string) {\n    return response.end(message);\n  }\n\n  public getHttpServer<T = any>(): T {\n    return this.instance as T;\n  }\n\n  public getInstance<T = any>(): T {\n    return this.instance as T;\n  }\n\n  public isHeadersSent(response: any): boolean {\n    return response.headersSent;\n  }\n\n  public setHeader(response: any, name: string, value: string) {\n    return response.setHeader(name, value);\n  }\n\n  public getRequestMethod(request: any): string {\n    return request.method;\n  }\n\n  public getRequestUrl(request: any): string {\n    return request.url;\n  }\n\n  public getRequestHostname(request: any): string {\n    return request.hostname;\n  }\n\n  public createMiddlewareFactory(\n    requestMethod: RequestMethod\n  ): (path: string, callback: Function) => any {\n    return this.routerMethodFactory\n      .get(this.instance, requestMethod)\n      .bind(this.instance);\n  }\n\n  public getType(): string {\n    return 'azure-http';\n  }\n\n  public applyVersionFilter(\n    handler: Function,\n    version: VersionValue,\n    versioningOptions: VersioningOptions\n  ) {\n    throw new NotImplementedException();\n    return (req, res, next) => {\n      return () => {};\n    };\n  }\n\n  public listen(port: any, ...args: any[]) {}\n  public render(response: any, view: string, options: any) {}\n  public redirect(response: any, statusCode: number, url: string) {}\n  public close() {}\n  public initHttpServer() {}\n  public useStaticAssets(options: any) {}\n  public setViewEngine(options: any) {}\n  public registerParserMiddleware() {}\n  public setNotFoundHandler(handler: Function) {}\n  public setErrorHandler(handler: Function) {}\n}\n"
  },
  {
    "path": "lib/router/index.ts",
    "content": "export * from './azure-http.router';\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"@nestjs/azure-func-http\",\n  \"version\": \"0.10.0\",\n  \"description\": \"Nest - modern, fast, powerful node.js web framework (@azure-func-http)\",\n  \"author\": \"Kamil Mysliwiec\",\n  \"license\": \"MIT\",\n  \"scripts\": {\n    \"build\": \"npm run build:lib && npm run build:schematics\",\n    \"build:lib\": \"tsc -p tsconfig.json\",\n    \"build:schematics\": \"tsc -p tsconfig.schematics.json\",\n    \"lint\": \"eslint --ext ts --fix lib\",\n    \"format\": \"prettier --write \\\"lib/**/*.ts\\\"\",\n    \"precommit\": \"lint-staged\",\n    \"prepublish:npm\": \"npm run build\",\n    \"publish:npm\": \"npm publish --access public\",\n    \"prepublish:next\": \"npm run build\",\n    \"publish:next\": \"npm publish --access public --tag next\",\n    \"prerelease\": \"npm run build\",\n    \"release\": \"release-it\",\n    \"test\": \"jest -w 1 --no-cache --config jest.json\",\n    \"test:dev\": \"NODE_ENV=test npm run -s test -- --watchAll\"\n  },\n  \"peerDependencies\": {\n    \"@azure/functions\": \"^1.0.3 || ^2.0.0 || ^3.0.0\",\n    \"@nestjs/common\": \"^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0\",\n    \"@nestjs/core\": \"^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0\",\n    \"reflect-metadata\": \"^0.1.13\"\n  },\n  \"devDependencies\": {\n    \"@angular-devkit/schematics\": \"^16.0.0\",\n    \"@azure/functions\": \"3.5.1\",\n    \"@commitlint/cli\": \"19.6.1\",\n    \"@commitlint/config-angular\": \"19.7.0\",\n    \"@nestjs/common\": \"10.2.7\",\n    \"@nestjs/core\": \"10.2.7\",\n    \"@nestjs/schematics\": \"10.0.2\",\n    \"@types/node\": \"22.10.7\",\n    \"@types/jest\": \"29.5.14\",\n    \"@typescript-eslint/eslint-plugin\": \"7.18.0\",\n    \"@typescript-eslint/parser\": \"7.18.0\",\n    \"@schematics/angular\": \"16.2.16\",\n    \"eslint\": \"8.57.1\",\n    \"eslint-config-prettier\": \"10.0.1\",\n    \"eslint-plugin-import\": \"2.31.0\",\n    \"husky\": \"9.1.7\",\n    \"lint-staged\": \"15.4.1\",\n    \"prettier\": \"3.4.2\",\n    \"release-it\": \"17.1.1\",\n    \"typescript\": \"5.7.3\",\n    \"jest\": \"29.7.0\",\n    \"ts-jest\": \"29.2.5\"\n  },\n  \"dependencies\": {\n    \"cors\": \"2.8.5\",\n    \"jsonc-parser\": \"^3.2.0\",\n    \"trouter\": \"3.2.1\"\n  },\n  \"schematics\": \"./schematics/collection.json\",\n  \"lint-staged\": {\n    \"*.ts\": [\n      \"prettier --write\"\n    ]\n  },\n  \"husky\": {\n    \"hooks\": {\n      \"pre-commit\": \"lint-staged\",\n      \"commit-msg\": \"commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS\"\n    }\n  }\n}\n"
  },
  {
    "path": "renovate.json",
    "content": "{\n  \"semanticCommits\": true,\n  \"packageRules\": [{\n    \"depTypeList\": [\"devDependencies\"],\n    \"automerge\": true\n  }],\n  \"extends\": [\n    \"config:base\"\n  ]\n}\n"
  },
  {
    "path": "schematics/collection.json",
    "content": "{\n  \"$schema\": \"../node_modules/@angular-devkit/schematics/collection-schema.json\",\n  \"schematics\": {\n    \"nest-add\": {\n      \"description\": \"Adds Azure Functions HTTP template to the application without affecting any app files\",\n      \"factory\": \"./install\",\n      \"schema\": \"./install/schema.json\",\n      \"aliases\": [\"nest-azure-shell\"]\n    }\n  }\n}\n"
  },
  {
    "path": "schematics/install/files/project/.funcignore",
    "content": "*.js.map\n*.ts\n.git*\n.vscode\nlocal.settings.json\ntest\ntsconfig.json"
  },
  {
    "path": "schematics/install/files/project/__project__/function.json",
    "content": "{\n  \"bindings\": [\n    {\n      \"authLevel\": \"anonymous\",\n      \"type\": \"httpTrigger\",\n      \"direction\": \"in\",\n      \"name\": \"req\",\n      \"route\": \"<%= getProjectName() %>/{*segments}\"\n    },\n    {\n      \"type\": \"http\",\n      \"direction\": \"out\",\n      \"name\": \"res\"\n    }\n  ],\n  \"scriptFile\": \"../dist/<%= getProjectName() %>/index.js\"\n}\n"
  },
  {
    "path": "schematics/install/files/project/__project__/index.ts",
    "content": "import { Context, HttpRequest } from '@azure/functions';\nimport { AzureHttpAdapter } from '@nestjs/azure-func-http';\nimport { createApp } from '../apps/<%= getProjectName() %>/src/main.azure';\n\nexport default function(context: Context, req: HttpRequest): void {\n  AzureHttpAdapter.handle(createApp, context, req);\n}\n"
  },
  {
    "path": "schematics/install/files/project/__project__/webpack.config.js",
    "content": "module.exports = function (options) {\n  return {\n    ...options,\n    entry: __dirname + '/index.ts',\n    output: {\n      libraryTarget: 'commonjs2',\n      filename: '<%= getProjectName() %>/index.js'\n    }\n  };\n};\n"
  },
  {
    "path": "schematics/install/files/project/__sourceRoot__/main.azure.ts",
    "content": "import { INestApplication } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\nimport { <%= getRootModuleName() %> } from './<%= getRootModulePath() %>';\n\nexport async function createApp(): Promise<INestApplication> {\n  const app = await NestFactory.create(<%= getRootModuleName() %>);\n  app.setGlobalPrefix('api/<%= getProjectName() %>');\n\n  await app.init();\n  return app;\n}\n"
  },
  {
    "path": "schematics/install/files/project/host.json",
    "content": "{\n  \"version\": \"2.0\"\n}\n"
  },
  {
    "path": "schematics/install/files/project/local.settings.json",
    "content": "{\n  \"IsEncrypted\": false,\n  \"Values\": {\n    \"AzureWebJobsStorage\": \"\",\n    \"FUNCTIONS_WORKER_RUNTIME\": \"node\"\n  }\n}\n"
  },
  {
    "path": "schematics/install/files/project/proxies.json",
    "content": "{\n  \"$schema\": \"http://json.schemastore.org/proxies\",\n  \"proxies\": {}\n}\n"
  },
  {
    "path": "schematics/install/files/root/.funcignore",
    "content": "*.js.map\n*.ts\n.git*\n.vscode\nlocal.settings.json\ntest\ntsconfig.json"
  },
  {
    "path": "schematics/install/files/root/__rootDir__/main.azure.ts",
    "content": "import { INestApplication } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\nimport { <%= getRootModuleName() %> } from './<%= getRootModulePath() %>';\n\nexport async function createApp(): Promise<INestApplication> {\n  const app = await NestFactory.create(<%= getRootModuleName() %>);\n  app.setGlobalPrefix('api');\n  \n  await app.init();\n  return app;\n}\n"
  },
  {
    "path": "schematics/install/files/root/host.json",
    "content": "{\n  \"version\": \"2.0\"\n}\n"
  },
  {
    "path": "schematics/install/files/root/local.settings.json",
    "content": "{\n  \"IsEncrypted\": false,\n  \"Values\": {\n    \"AzureWebJobsStorage\": \"\",\n    \"FUNCTIONS_WORKER_RUNTIME\": \"node\"\n  }\n}\n"
  },
  {
    "path": "schematics/install/files/root/main/function.json",
    "content": "{\n  \"bindings\": [\n    {\n      \"authLevel\": \"anonymous\",\n      \"type\": \"httpTrigger\",\n      \"direction\": \"in\",\n      \"name\": \"req\",\n      \"route\": \"{*segments}\"\n    },\n    {\n      \"type\": \"http\",\n      \"direction\": \"out\",\n      \"name\": \"res\"\n    }\n  ],\n  \"scriptFile\": \"../dist/main/index.js\"\n}\n"
  },
  {
    "path": "schematics/install/files/root/main/index.ts",
    "content": "import { Context, HttpRequest } from '@azure/functions';\nimport { AzureHttpAdapter } from '@nestjs/azure-func-http';\nimport { createApp } from '../<%= getRootDirectory() %>/main.azure';\n\nexport default function(context: Context, req: HttpRequest): void {\n  AzureHttpAdapter.handle(createApp, context, req);\n}\n"
  },
  {
    "path": "schematics/install/files/root/proxies.json",
    "content": "{\n  \"$schema\": \"http://json.schemastore.org/proxies\",\n  \"proxies\": {}\n}\n"
  },
  {
    "path": "schematics/install/index.test.ts",
    "content": "import { FileEntry, Tree } from '@angular-devkit/schematics';\nimport {\n  SchematicTestRunner,\n  UnitTestTree\n} from '@angular-devkit/schematics/testing';\nimport * as path from 'path';\nimport { Schema } from './schema';\n\nconst getFileContent = (tree: UnitTestTree, path: string): string => {\n  const fileEntry: FileEntry = tree.get(path);\n  if (!fileEntry) {\n    throw new Error(`The file does not exist.`);\n  }\n  return fileEntry.content.toString();\n};\ndescribe('Schematic Tests Nest Add', () => {\n  let nestTree: Tree;\n\n  const runner: SchematicTestRunner = new SchematicTestRunner(\n    'azure-func-http',\n    path.join(process.cwd(), 'schematics/collection.json')\n  );\n\n  beforeEach(async () => {\n    nestTree = await createTestNest(runner);\n  });\n\n  describe('Test for default setup', () => {\n    it('should add azure func for default setup', async () => {\n      const options: Schema = {\n        skipInstall: true,\n        rootModuleFileName: 'app.module',\n        rootModuleClassName: 'AppModule'\n      };\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const files: string[] = tree.files;\n      expect(files).toEqual([\n        '/.eslintrc.js',\n        '/.prettierrc',\n        '/README.md',\n        '/nest-cli.json',\n        '/package.json',\n        '/tsconfig.build.json',\n        '/tsconfig.json',\n        '/.funcignore',\n        '/host.json',\n        '/local.settings.json',\n        '/proxies.json',\n        '/src/app.controller.spec.ts',\n        '/src/app.controller.ts',\n        '/src/app.module.ts',\n        '/src/app.service.ts',\n        '/src/main.ts',\n        '/src/main.azure.ts',\n        '/test/app.e2e-spec.ts',\n        '/test/jest-e2e.json',\n        '/main/function.json',\n        '/main/index.ts',\n        '/main/sample.dat'\n      ]);\n    });\n\n    it('should have a nest-cli.json for default app', async () => {\n      const options: Schema = {\n        sourceRoot: 'src',\n        skipInstall: true,\n        rootDir: 'src',\n        rootModuleFileName: 'app.module',\n        rootModuleClassName: 'AppModule'\n      };\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const fileContent = getFileContent(tree, '/nest-cli.json');\n      expect(fileContent).toContain(`\"sourceRoot\": \"src\"`);\n    });\n\n    it('should import the app.module int main azure file for default app', async () => {\n      const options: Schema = {\n        sourceRoot: 'src',\n        skipInstall: true,\n        rootDir: 'src',\n        rootModuleFileName: 'app.module',\n        rootModuleClassName: 'AppModule'\n      };\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const fileContent = getFileContent(tree, '/src/main.azure.ts');\n\n      expect(fileContent).toContain(\n        `import { AppModule } from './app.module';`\n      );\n    });\n\n    it('should have the root dir for index file in main azure dir for default app', async () => {\n      const options: Schema = {\n        sourceRoot: 'src',\n        skipInstall: true,\n        rootDir: 'src',\n        rootModuleFileName: 'app.module',\n        rootModuleClassName: 'AppModule'\n      };\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const fileContent = getFileContent(tree, '/main/index.ts');\n\n      expect(fileContent).toContain(\n        `import { createApp } from '../src/main.azure';`\n      );\n    });\n\n    it('should not import the webpack config for a default app', async () => {\n      const options: Schema = {\n        sourceRoot: 'src',\n        skipInstall: true,\n        rootDir: 'src',\n        rootModuleFileName: 'app.module',\n        rootModuleClassName: 'AppModule'\n      };\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const fileContent = tree.get('webpack.config.js');\n\n      expect(fileContent).toBeNull();\n    });\n  });\n\n  describe('Tests for monorepo', () => {\n    it('should add azure-func for monorepo app', async () => {\n      const projectName = 'azure-2';\n      const options: Schema = {\n        skipInstall: true,\n        project: projectName,\n        rootDir: `apps/${projectName}`,\n        sourceRoot: `apps/${projectName}/src`\n      };\n\n      await runner.runExternalSchematic(\n        '@nestjs/schematics',\n        'sub-app',\n        {\n          name: projectName\n        },\n        nestTree\n      );\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const files: string[] = tree.files;\n      expect(files).toEqual([\n        '/.eslintrc.js',\n        '/.prettierrc',\n        '/README.md',\n        '/nest-cli.json',\n        '/package.json',\n        '/tsconfig.build.json',\n        '/tsconfig.json',\n        '/.funcignore',\n        '/host.json',\n        '/local.settings.json',\n        '/proxies.json',\n        '/src/app.controller.spec.ts',\n        '/src/app.controller.ts',\n        '/src/app.module.ts',\n        '/src/app.service.ts',\n        '/src/main.ts',\n        '/test/app.e2e-spec.ts',\n        '/test/jest-e2e.json',\n        '/apps/nestjs-azure-func-http/tsconfig.app.json',\n        `/apps/${projectName}/tsconfig.app.json`,\n        `/apps/${projectName}/src/main.ts`,\n        `/apps/${projectName}/src/${projectName}.controller.spec.ts`,\n        `/apps/${projectName}/src/${projectName}.controller.ts`,\n        `/apps/${projectName}/src/${projectName}.module.ts`,\n        `/apps/${projectName}/src/${projectName}.service.ts`,\n        `/apps/${projectName}/src/main.azure.ts`,\n        `/apps/${projectName}/test/jest-e2e.json`,\n        `/apps/${projectName}/test/app.e2e-spec.ts`,\n        `/${projectName}/function.json`,\n        `/${projectName}/index.ts`,\n        `/${projectName}/sample.dat`,\n        `/${projectName}/webpack.config.js`\n      ]);\n    });\n\n    it('should have a nest-cli.json for monorepo app', async () => {\n      const projectName = 'azure-2';\n      const options: Schema = {\n        skipInstall: true,\n        project: projectName,\n        sourceRoot: `apps/${projectName}/src`\n      };\n\n      await runner.runExternalSchematic(\n        '@nestjs/schematics',\n        'sub-app',\n        {\n          name: projectName\n        },\n        nestTree\n      );\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const fileContent = getFileContent(tree, '/nest-cli.json');\n      const parsedFile = JSON.parse(fileContent);\n      expect(parsedFile.projects[projectName].sourceRoot).toEqual(\n        `apps/${projectName}/src`\n      );\n    });\n\n    it('should import the app.module int main azure file for monorepo app', async () => {\n      const projectName = 'azure-2';\n      const options: Schema = {\n        skipInstall: true,\n        project: projectName,\n        sourceRoot: `apps/${projectName}/src`\n      };\n\n      await runner.runExternalSchematic(\n        '@nestjs/schematics',\n        'sub-app',\n        {\n          name: projectName\n        },\n        nestTree\n      );\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const fileContent = getFileContent(\n        tree,\n        `/apps/${projectName}/src/main.azure.ts`\n      );\n\n      expect(fileContent).toContain(\n        `import { AppModule } from './app.module';`\n      );\n    });\n\n    it('should have the root dir for index file in main azure dir for monorepo app', async () => {\n      const projectName = 'azure-2';\n      const options: Schema = {\n        skipInstall: true,\n        project: projectName,\n        sourceRoot: `apps/${projectName}/src`\n      };\n\n      await runner.runExternalSchematic(\n        '@nestjs/schematics',\n        'sub-app',\n        {\n          name: projectName\n        },\n        nestTree\n      );\n\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n      const fileContent = getFileContent(tree, `/${projectName}/index.ts`);\n\n      expect(fileContent).toContain(\n        `import { createApp } from '../apps/${projectName}/src/main.azure';`\n      );\n    });\n\n    it('should import the webpack config for monorepo app', async () => {\n      const projectName = 'azure-2';\n      const options: Schema = {\n        skipInstall: true,\n        project: projectName,\n        rootDir: `apps/${projectName}`,\n        sourceRoot: `apps/${projectName}/src`\n      };\n\n      await runner.runExternalSchematic(\n        '@nestjs/schematics',\n        'sub-app',\n        {\n          name: projectName\n        },\n        nestTree\n      );\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n\n      const fileContent = getFileContent(\n        tree,\n        `/${projectName}/webpack.config.js`\n      );\n      expect(fileContent).toContain(`filename: '${projectName}/index.js'`);\n    });\n\n    it('should add a custom webpack config to the compilerOptions for monorepo app', async () => {\n      const projectName = 'azure-2';\n      const options: Schema = {\n        skipInstall: true,\n        project: projectName,\n        sourceRoot: `apps/${projectName}/src`\n      };\n\n      await runner.runExternalSchematic(\n        '@nestjs/schematics',\n        'sub-app',\n        {\n          name: projectName\n        },\n        nestTree\n      );\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n\n      const fileContent = getFileContent(tree, 'nest-cli.json');\n      const parsedFile = JSON.parse(fileContent);\n      const compilerOptions = parsedFile.projects[projectName].compilerOptions;\n      expect(compilerOptions).toEqual({\n        tsConfigPath: `apps/${projectName}/tsconfig.app.json`,\n        webpack: true,\n        webpackConfigPath: `${projectName}/webpack.config.js`\n      });\n    });\n\n    it('should the scriptFile of functions to sub dir for monorepo app', async () => {\n      const projectName = 'azure-2';\n      const options: Schema = {\n        skipInstall: true,\n        project: projectName,\n        rootDir: `apps.${projectName}`,\n        sourceRoot: `apps/${projectName}/src`\n      };\n\n      await runner.runExternalSchematic(\n        '@nestjs/schematics',\n        'sub-app',\n        {\n          name: projectName\n        },\n        nestTree\n      );\n      const tree = await runner.runSchematic('nest-add', options, nestTree);\n\n      const fileContent = getFileContent(tree, `${projectName}/function.json`);\n      const parsedFile = JSON.parse(fileContent);\n      expect(parsedFile.scriptFile).toEqual(`../dist/${projectName}/index.js`);\n    });\n  });\n\n  async function createTestNest(\n    runner: SchematicTestRunner,\n    tree?: Tree\n  ): Promise<UnitTestTree> {\n    return await runner.runExternalSchematic(\n      '@nestjs/schematics',\n      'application',\n      {\n        name: 'newproject',\n        directory: '.'\n      },\n      tree\n    );\n  }\n});\n"
  },
  {
    "path": "schematics/install/index.ts",
    "content": "import { strings } from '@angular-devkit/core';\nimport { parse as parseJson } from 'jsonc-parser';\nimport {\n  apply,\n  chain,\n  FileEntry,\n  forEach,\n  mergeWith,\n  noop,\n  Rule,\n  SchematicContext,\n  SchematicsException,\n  template,\n  Tree,\n  url\n} from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport {\n  addPackageJsonDependency,\n  NodeDependencyType\n} from '@schematics/angular/utility/dependencies';\nimport { Schema as AzureOptions } from './schema';\n\ntype UpdateJsonFn<T> = (obj: T) => T | void;\n\nfunction addDependenciesAndScripts(): Rule {\n  return (host: Tree) => {\n    addPackageJsonDependency(host, {\n      type: NodeDependencyType.Default,\n      name: '@azure/functions',\n      version: '^1.0.3'\n    });\n    const pkgPath = '/package.json';\n    const buffer = host.read(pkgPath);\n    if (buffer === null) {\n      throw new SchematicsException('Could not find package.json');\n    }\n\n    const pkg = JSON.parse(buffer.toString());\n    pkg.scripts['start:azure'] = 'npm run build && func host start';\n\n    host.overwrite(pkgPath, JSON.stringify(pkg, null, 2));\n    return host;\n  };\n}\n\nfunction updateJsonFile<T>(\n  host: Tree,\n  path: string,\n  callback: UpdateJsonFn<T>\n): Tree {\n  const source = host.read(path);\n  if (source) {\n    const sourceText = source.toString('utf-8');\n    const json = parseJson(sourceText);\n    callback(json as {} as T);\n    host.overwrite(path, JSON.stringify(json, null, 2));\n  }\n  return host;\n}\nconst applyProjectName = (projectName, host) => {\n  if (projectName) {\n    let nestCliFileExists = host.exists('nest-cli.json');\n\n    if (nestCliFileExists) {\n      updateJsonFile(\n        host,\n        'nest-cli.json',\n        (optionsFile: Record<string, any>) => {\n          if (optionsFile.projects[projectName].compilerOptions) {\n            optionsFile.projects[projectName].compilerOptions = {\n              ...optionsFile.projects[projectName].compilerOptions,\n              ...{\n                webpack: true,\n                webpackConfigPath: `${projectName}/webpack.config.js`\n              }\n            };\n          }\n        }\n      );\n    }\n  }\n};\n\nconst rootFiles = [\n  '/.funcignore',\n  '/host.json',\n  '/local.settings.json',\n  '/proxies.json'\n];\n\nconst validateExistingRootFiles = (host: Tree, file: FileEntry) => {\n  return rootFiles.includes(file.path) && host.exists(file.path);\n};\n\nexport default function (options: AzureOptions): Rule {\n  return (host: Tree, context: SchematicContext) => {\n    if (!options.skipInstall) {\n      context.addTask(new NodePackageInstallTask());\n    }\n    const defaultSourceRoot =\n      options.project !== undefined ? options.sourceRoot : options.rootDir;\n    const rootSource = apply(\n      options.project ? url('./files/project') : url('./files/root'),\n      [\n        template({\n          ...strings,\n          ...(options as AzureOptions),\n          rootDir: options.rootDir,\n          sourceRoot: defaultSourceRoot,\n          getRootDirectory: () => options.rootDir,\n          getProjectName: () => options.project,\n          stripTsExtension: (s: string) => s.replace(/\\.ts$/, ''),\n          getRootModuleName: () => options.rootModuleClassName,\n          getRootModulePath: () => options.rootModuleFileName\n        }),\n        forEach((file: FileEntry) => {\n          if (validateExistingRootFiles(host, file)) return null;\n          return file;\n        })\n      ]\n    );\n\n    return chain([\n      (tree, context) =>\n        options.project\n          ? applyProjectName(options.project, host)\n          : noop()(tree, context),\n      addDependenciesAndScripts(),\n      mergeWith(rootSource)\n    ]);\n  };\n}\n"
  },
  {
    "path": "schematics/install/schema.json",
    "content": "{\n  \"$schema\": \"http://json-schema.org/schema\",\n  \"$id\": \"SchematicsNestEngineInstall\",\n  \"title\": \"Nest Engine Install Options Schema\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"rootDir\": {\n      \"type\": \"string\",\n      \"description\": \"Application root directory.\",\n      \"default\": \"src\"\n    },\n    \"rootModuleFileName\": {\n      \"type\": \"string\",\n      \"format\": \"path\",\n      \"description\": \"The name of the root module file (without extension)\",\n      \"default\": \"app.module\"\n    },\n    \"rootModuleClassName\": {\n      \"type\": \"string\",\n      \"description\": \"The name of the root module class.\",\n      \"default\": \"AppModule\"\n    },\n    \"skipInstall\": {\n      \"description\": \"Skip installing dependency packages.\",\n      \"type\": \"boolean\",\n      \"default\": false\n    },\n    \"sourceRoot\": {\n      \"type\": \"string\",\n      \"description\": \"The source root directory.\"\n    },\n    \"project\": {\n      \"type\": \"string\",\n      \"description\": \"The project where generate the azure files.\"\n    }\n  },\n  \"required\": []\n}\n"
  },
  {
    "path": "schematics/install/schema.ts",
    "content": "export interface Schema {\n  /**\n   * Application root directory\n   */\n  rootDir?: string;\n  /**\n   * The name of the root module file\n   */\n  rootModuleFileName?: string;\n  /**\n   * The name of the root module class.\n   */\n  rootModuleClassName?: string;\n  /**\n   * Skip installing dependency packages.\n   */\n  skipInstall?: boolean;\n  /**\n   * .\n   */\n  sourceRoot?: string;\n  /**\n   * The project where generate the azure files.\n   */\n  project?: string;\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"declaration\": true,\n    \"noImplicitAny\": false,\n    \"removeComments\": true,\n    \"noLib\": false,\n    \"emitDecoratorMetadata\": true,\n    \"experimentalDecorators\": true,\n    \"target\": \"ES2021\",\n    \"sourceMap\": false,\n    \"outDir\": \"./dist\",\n    \"skipLibCheck\": true\n  },\n  \"include\": [\"lib/**/*\", \"../index.ts\"],\n  \"exclude\": [\"node_modules\", \"**/*.spec.ts\"]\n}\n"
  },
  {
    "path": "tsconfig.schematics.json",
    "content": "{\n  \"compilerOptions\": {\n    \"rootDir\": \"schematics\",\n    \"outDir\": \"./schematics\"\n  },\n  \"extends\": \"./tsconfig.json\",\n  \"include\": [\"schematics/**/*\"],\n  \"exclude\": [\"node_modules\", \"**/*.spec.ts\", \"./schematics/install/files/**\"]\n}\n"
  }
]