├── .circleci ├── config.yml └── install-wrk.sh ├── .commitlintrc.json ├── .eslintignore ├── .eslintrc.js ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── Bug_report.yml │ ├── Feature_request.yml │ ├── Regression.yml │ ├── Suggestion_improve_performance.yml │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml ├── lock.yml └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .npmignore ├── .prettierignore ├── .prettierrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Readme.md ├── SECURITY.md ├── benchmarks ├── all_output.txt ├── express.js ├── fastify.js ├── nest-fastify.js ├── nest.js └── nest │ ├── app.controller.d.ts │ ├── app.controller.js │ ├── app.controller.js.map │ ├── app.module.d.ts │ ├── app.module.js │ ├── app.module.js.map │ ├── main.d.ts │ └── main.js.map ├── gulpfile.js ├── hooks └── mocha-init-hook.ts ├── integration ├── auto-mock │ ├── src │ │ ├── bar.service.ts │ │ └── foo.service.ts │ ├── test │ │ └── bar.service.spec.ts │ └── tsconfig.json ├── cors │ ├── e2e │ │ ├── express.spec.ts │ │ └── fastify.spec.ts │ ├── src │ │ ├── app.controller.ts │ │ └── app.module.ts │ └── tsconfig.json ├── discovery │ ├── e2e │ │ └── discover-by-meta.spec.ts │ ├── src │ │ ├── app.module.ts │ │ ├── decorators │ │ │ ├── non-applied.decorator.ts │ │ │ └── webhook.decorators.ts │ │ ├── my-webhook │ │ │ ├── cleanup.webhook.ts │ │ │ ├── flush.webhook.ts │ │ │ └── my-webhook.module.ts │ │ └── webhooks.explorer.ts │ └── tsconfig.json ├── docker-compose.yml ├── graphql-code-first │ ├── e2e │ │ ├── code-first.spec.ts │ │ ├── guards-filters.spec.ts │ │ └── pipes.spec.ts │ ├── schema.gql │ ├── src │ │ ├── app.module.ts │ │ ├── common │ │ │ ├── filters │ │ │ │ └── unauthorized.filter.ts │ │ │ ├── guards │ │ │ │ └── auth.guard.ts │ │ │ ├── interceptors │ │ │ │ └── data.interceptor.ts │ │ │ └── scalars │ │ │ │ └── date.scalar.ts │ │ ├── main.ts │ │ └── recipes │ │ │ ├── dto │ │ │ ├── new-recipe.input.ts │ │ │ └── recipes.args.ts │ │ │ ├── models │ │ │ └── recipe.ts │ │ │ ├── recipes.module.ts │ │ │ ├── recipes.resolver.ts │ │ │ └── recipes.service.ts │ └── tsconfig.json ├── graphql-schema-first │ ├── e2e │ │ ├── graphql-async-class.spec.ts │ │ ├── graphql-async-existing.spec.ts │ │ ├── graphql-async.spec.ts │ │ ├── graphql-request-scoped.spec.ts │ │ └── graphql.spec.ts │ ├── src │ │ ├── app.module.ts │ │ ├── async-options-class.module.ts │ │ ├── async-options-existing.module.ts │ │ ├── async-options.module.ts │ │ ├── cats │ │ │ ├── cats-request-scoped.service.ts │ │ │ ├── cats.guard.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.resolvers.ts │ │ │ ├── cats.service.ts │ │ │ ├── cats.types.graphql │ │ │ └── interfaces │ │ │ │ └── cat.interface.ts │ │ ├── common │ │ │ └── scalars │ │ │ │ └── date.scalar.ts │ │ ├── config.module.ts │ │ ├── config.service.ts │ │ └── main.ts │ └── tsconfig.json ├── hello-world │ ├── e2e │ │ ├── exceptions.spec.ts │ │ ├── exclude-middleware-fastify.spec.ts │ │ ├── exclude-middleware.spec.ts │ │ ├── express-instance.spec.ts │ │ ├── express-multiple.spec.ts │ │ ├── fastify-adapter.spec.ts │ │ ├── fastify-multiple.spec.ts │ │ ├── guards.spec.ts │ │ ├── hello-world.spec.ts │ │ ├── interceptors.spec.ts │ │ ├── local-pipes.spec.ts │ │ ├── middleware-class.spec.ts │ │ ├── middleware-execute-order.spec.ts │ │ ├── middleware-fastify.spec.ts │ │ ├── middleware-run-match-route.ts │ │ ├── middleware-with-versioning.spec.ts │ │ ├── middleware.spec.ts │ │ ├── router-module-middleware.spec.ts │ │ └── router-module.spec.ts │ ├── src │ │ ├── app.module.ts │ │ ├── errors │ │ │ └── errors.controller.ts │ │ ├── hello │ │ │ ├── dto │ │ │ │ └── test.dto.ts │ │ │ ├── hello.controller.ts │ │ │ ├── hello.module.ts │ │ │ ├── hello.service.ts │ │ │ └── users │ │ │ │ ├── user-by-id.pipe.ts │ │ │ │ └── users.service.ts │ │ ├── host-array │ │ │ ├── dto │ │ │ │ └── test.dto.ts │ │ │ ├── host-array.controller.ts │ │ │ ├── host-array.module.ts │ │ │ ├── host-array.service.ts │ │ │ └── users │ │ │ │ ├── user-by-id.pipe.ts │ │ │ │ └── users.service.ts │ │ └── host │ │ │ ├── dto │ │ │ └── test.dto.ts │ │ │ ├── host.controller.ts │ │ │ ├── host.module.ts │ │ │ ├── host.service.ts │ │ │ └── users │ │ │ ├── user-by-id.pipe.ts │ │ │ └── users.service.ts │ └── tsconfig.json ├── hooks │ ├── e2e │ │ ├── before-app-shutdown.spec.ts │ │ ├── enable-shutdown-hook.spec.ts │ │ ├── lifecycle-hook-order.spec.ts │ │ ├── on-app-boostrap.spec.ts │ │ ├── on-app-shutdown.spec.ts │ │ ├── on-module-destroy.spec.ts │ │ └── on-module-init.spec.ts │ ├── src │ │ └── enable-shutdown-hooks-main.ts │ └── tsconfig.json ├── injector │ ├── e2e │ │ ├── circular-custom-providers.spec.ts │ │ ├── circular-modules.spec.ts │ │ ├── circular-property-injection.spec.ts │ │ ├── circular-structure-dynamic-modules.spec.ts │ │ ├── circular.spec.ts │ │ ├── core-injectables.spec.ts │ │ ├── default-values.spec.ts │ │ ├── injector.spec.ts │ │ ├── introspection.spec.ts │ │ ├── multiple-providers.spec.ts │ │ ├── optional-factory-provider-dep.spec.ts │ │ ├── property-injection.spec.ts │ │ └── scoped-instances.spec.ts │ ├── src │ │ ├── app.module.ts │ │ ├── circular-modules │ │ │ ├── circular.module.ts │ │ │ ├── circular.service.ts │ │ │ ├── input.module.ts │ │ │ └── input.service.ts │ │ ├── circular-properties │ │ │ ├── circular-properties.module.ts │ │ │ ├── circular.service.ts │ │ │ ├── input-properties.module.ts │ │ │ └── input.service.ts │ │ ├── circular-structure-dynamic-module │ │ │ ├── circular.module.ts │ │ │ └── input.service.ts │ │ ├── circular │ │ │ ├── circular.module.ts │ │ │ ├── circular.service.ts │ │ │ └── input.service.ts │ │ ├── core-injectables │ │ │ └── core-injectables.module.ts │ │ ├── defaults │ │ │ ├── core.service.ts │ │ │ ├── defaults.module.ts │ │ │ └── defaults.service.ts │ │ ├── dynamic │ │ │ └── dynamic.module.ts │ │ ├── exports │ │ │ ├── exports.module.ts │ │ │ └── exports.service.ts │ │ ├── inject │ │ │ ├── core.service.ts │ │ │ ├── inject-same-name.module.ts │ │ │ ├── inject.module.ts │ │ │ └── inject.service.ts │ │ ├── multiple-providers │ │ │ ├── a.module.ts │ │ │ ├── b.module.ts │ │ │ ├── c.module.ts │ │ │ └── multiple-providers.module.ts │ │ ├── properties │ │ │ ├── dependency.service.ts │ │ │ ├── properties.module.ts │ │ │ └── properties.service.ts │ │ ├── scoped │ │ │ ├── scoped.controller.ts │ │ │ ├── scoped.module.ts │ │ │ ├── scoped.service.ts │ │ │ ├── transient.service.ts │ │ │ ├── transient2.service.ts │ │ │ └── transient3.service.ts │ │ └── self-injection │ │ │ └── self-injection-provider.module.ts │ └── tsconfig.json ├── inspector │ ├── e2e │ │ ├── fixtures │ │ │ ├── post-init-graph.json │ │ │ └── pre-init-graph.json │ │ └── graph-inspector.spec.ts │ ├── src │ │ ├── app-v1.controller.ts │ │ ├── app-v2.controller.ts │ │ ├── app.module.ts │ │ ├── cats │ │ │ ├── cats.controller.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.service.ts │ │ │ ├── dto │ │ │ │ └── create-cat.dto.ts │ │ │ └── interfaces │ │ │ │ └── cat.interface.ts │ │ ├── chat │ │ │ ├── chat.gateway.ts │ │ │ ├── chat.module.ts │ │ │ ├── chat.service.ts │ │ │ ├── dto │ │ │ │ ├── create-chat.dto.ts │ │ │ │ └── update-chat.dto.ts │ │ │ └── entities │ │ │ │ └── chat.entity.ts │ │ ├── circular-hello │ │ │ ├── dto │ │ │ │ └── test.dto.ts │ │ │ ├── guards │ │ │ │ └── request-scoped.guard.ts │ │ │ ├── hello.controller.ts │ │ │ ├── hello.module.ts │ │ │ ├── hello.service.ts │ │ │ ├── interceptors │ │ │ │ └── logging.interceptor.ts │ │ │ └── users │ │ │ │ ├── user-by-id.pipe.ts │ │ │ │ └── users.service.ts │ │ ├── circular-modules │ │ │ ├── circular.module.ts │ │ │ ├── circular.service.ts │ │ │ ├── input.module.ts │ │ │ └── input.service.ts │ │ ├── common │ │ │ ├── filters │ │ │ │ └── http-exception.filter.ts │ │ │ ├── guards │ │ │ │ └── roles.guard.ts │ │ │ ├── interceptors │ │ │ │ └── timeout.interceptor.ts │ │ │ ├── middleware │ │ │ │ └── logger.middleware.ts │ │ │ └── pipes │ │ │ │ └── parse-int.pipe.ts │ │ ├── core │ │ │ ├── core.module.ts │ │ │ └── interceptors │ │ │ │ ├── logging.interceptor.ts │ │ │ │ └── transform.interceptor.ts │ │ ├── database │ │ │ ├── database.controller.ts │ │ │ ├── database.module.ts │ │ │ ├── database.service.ts │ │ │ ├── dto │ │ │ │ ├── create-database.dto.ts │ │ │ │ └── update-database.dto.ts │ │ │ └── entities │ │ │ │ └── database.entity.ts │ │ ├── defaults │ │ │ ├── core.service.ts │ │ │ ├── defaults.module.ts │ │ │ └── defaults.service.ts │ │ ├── dogs │ │ │ ├── dogs.controller.ts │ │ │ ├── dogs.module.ts │ │ │ ├── dogs.service.ts │ │ │ ├── dto │ │ │ │ ├── create-dog.dto.ts │ │ │ │ └── update-dog.dto.ts │ │ │ └── entities │ │ │ │ └── dog.entity.ts │ │ ├── durable │ │ │ ├── durable-context-id.strategy.ts │ │ │ ├── durable.controller.ts │ │ │ ├── durable.module.ts │ │ │ └── durable.service.ts │ │ ├── external-svc │ │ │ ├── dto │ │ │ │ ├── create-external-svc.dto.ts │ │ │ │ └── update-external-svc.dto.ts │ │ │ ├── entities │ │ │ │ └── external-svc.entity.ts │ │ │ ├── external-svc.controller.ts │ │ │ ├── external-svc.module.ts │ │ │ └── external-svc.service.ts │ │ ├── properties │ │ │ ├── dependency.service.ts │ │ │ ├── properties.module.ts │ │ │ └── properties.service.ts │ │ ├── request-chain │ │ │ ├── helper │ │ │ │ ├── helper.module.ts │ │ │ │ └── helper.service.ts │ │ │ ├── interceptors │ │ │ │ └── logging.interceptor.ts │ │ │ ├── request-chain.controller.ts │ │ │ ├── request-chain.module.ts │ │ │ └── request-chain.service.ts │ │ └── users │ │ │ ├── dto │ │ │ ├── create-user.dto.ts │ │ │ └── update-user.dto.ts │ │ │ ├── entities │ │ │ └── user.entity.ts │ │ │ ├── users.controller.ts │ │ │ ├── users.module.ts │ │ │ └── users.service.ts │ └── tsconfig.json ├── lazy-modules │ ├── e2e │ │ ├── lazy-import-global-modules.spec.ts │ │ └── lazy-import-transient-providers.spec.ts │ └── src │ │ ├── app.module.ts │ │ ├── eager.module.ts │ │ ├── global.module.ts │ │ ├── lazy.controller.ts │ │ ├── lazy.module.ts │ │ ├── main.ts │ │ ├── transient.module.ts │ │ └── transient.service.ts ├── microservices │ ├── e2e │ │ ├── broadcast-mqtt.spec.ts │ │ ├── broadcast-nats.spec.ts │ │ ├── broadcast-redis.spec.ts │ │ ├── concurrent-kafka.spec.ts │ │ ├── disconnected-client.spec.ts │ │ ├── math-grpc.spec.ts │ │ ├── mqtt-record-builder.spec.ts │ │ ├── orders-grpc.spec.ts │ │ ├── sum-kafka.spec.ts │ │ ├── sum-mqtt.spec.ts │ │ ├── sum-nats.spec.ts │ │ ├── sum-redis.spec.ts │ │ ├── sum-rmq.spec.ts │ │ ├── sum-rpc-tls.spec.ts │ │ └── sum-rpc.spec.ts │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── disconnected.controller.ts │ │ ├── grpc-advanced │ │ │ ├── advanced.grpc.controller.ts │ │ │ └── proto │ │ │ │ ├── common │ │ │ │ ├── item_types.proto │ │ │ │ └── shipment_types.proto │ │ │ │ ├── orders │ │ │ │ ├── message.proto │ │ │ │ └── service.proto │ │ │ │ └── root.proto │ │ ├── grpc │ │ │ ├── grpc.controller.ts │ │ │ ├── math.proto │ │ │ └── math2.proto │ │ ├── kafka-concurrent │ │ │ ├── dto │ │ │ │ └── sum.dto.ts │ │ │ ├── kafka-concurrent.controller.ts │ │ │ └── kafka-concurrent.messages.controller.ts │ │ ├── kafka │ │ │ ├── dtos │ │ │ │ ├── business.dto.ts │ │ │ │ └── user.dto.ts │ │ │ ├── entities │ │ │ │ ├── business.entity.ts │ │ │ │ └── user.entity.ts │ │ │ ├── kafka.controller.ts │ │ │ └── kafka.messages.controller.ts │ │ ├── main.ts │ │ ├── mqtt │ │ │ ├── mqtt-broadcast.controller.ts │ │ │ └── mqtt.controller.ts │ │ ├── nats │ │ │ ├── nats-broadcast.controller.ts │ │ │ ├── nats.controller.ts │ │ │ └── nats.service.ts │ │ ├── redis │ │ │ ├── redis-broadcast.controller.ts │ │ │ └── redis.controller.ts │ │ ├── rmq │ │ │ ├── rmq-broadcast.controller.ts │ │ │ └── rmq.controller.ts │ │ └── tcp-tls │ │ │ ├── app.controller.ts │ │ │ ├── app.module.ts │ │ │ ├── ca.cert.pem │ │ │ └── privkey.pem │ └── tsconfig.json ├── module-utils │ ├── src │ │ ├── integration.module-definition.ts │ │ ├── integration.module.ts │ │ └── interfaces │ │ │ └── integration-module-options.interface.ts │ ├── test │ │ └── integration-module.spec.ts │ └── tsconfig.json ├── mongoose │ ├── e2e │ │ ├── async-class-options.spec.ts │ │ ├── async-existing-options.spec.ts │ │ ├── async-options.spec.ts │ │ └── mongoose.spec.ts │ ├── src │ │ ├── app.module.ts │ │ ├── async-class-options.module.ts │ │ ├── async-existing-options.module.ts │ │ ├── async-options.module.ts │ │ ├── cats │ │ │ ├── cats.controller.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.service.ts │ │ │ ├── dto │ │ │ │ └── create-cat.dto.ts │ │ │ ├── interfaces │ │ │ │ └── cat.interface.ts │ │ │ └── schemas │ │ │ │ └── cat.schema.ts │ │ └── main.ts │ └── tsconfig.json ├── mosquitto.conf ├── nest-application │ ├── app-locals │ │ ├── e2e │ │ │ └── express.spec.ts │ │ ├── src │ │ │ ├── app.controller.ts │ │ │ └── app.module.ts │ │ └── tsconfig.json │ ├── get-url │ │ ├── e2e │ │ │ ├── express.spec.ts │ │ │ ├── fastify.spec.ts │ │ │ └── utils.ts │ │ ├── src │ │ │ ├── app.controller.ts │ │ │ ├── app.module.ts │ │ │ └── app.service.ts │ │ └── tsconfig.json │ ├── global-prefix │ │ ├── e2e │ │ │ └── global-prefix.spec.ts │ │ ├── src │ │ │ ├── app.controller.ts │ │ │ └── app.module.ts │ │ └── tsconfig.json │ ├── listen │ │ ├── e2e │ │ │ ├── express.spec.ts │ │ │ └── fastify.spec.ts │ │ └── src │ │ │ ├── app.controller.ts │ │ │ ├── app.module.ts │ │ │ └── app.service.ts │ ├── raw-body │ │ ├── e2e │ │ │ ├── express.spec.ts │ │ │ └── fastify.spec.ts │ │ ├── src │ │ │ ├── express.controller.ts │ │ │ ├── express.module.ts │ │ │ ├── fastify.controller.ts │ │ │ └── fastify.module.ts │ │ └── tsconfig.json │ ├── sse │ │ ├── e2e │ │ │ ├── express.spec.ts │ │ │ └── fastify.spec.ts │ │ ├── src │ │ │ ├── app.controller.ts │ │ │ └── app.module.ts │ │ └── tsconfig.json │ └── use-body-parser │ │ ├── e2e │ │ ├── express.spec.ts │ │ └── fastify.spec.ts │ │ ├── src │ │ ├── app.controller.ts │ │ └── app.module.ts │ │ └── tsconfig.json ├── repl │ ├── e2e │ │ └── repl.spec.ts │ ├── src │ │ ├── app.module.ts │ │ └── users │ │ │ ├── dto │ │ │ ├── create-user.dto.ts │ │ │ └── update-user.dto.ts │ │ │ ├── entities │ │ │ └── user.entity.ts │ │ │ ├── users.controller.ts │ │ │ ├── users.module.ts │ │ │ ├── users.repository.ts │ │ │ └── users.service.ts │ └── tsconfig.json ├── scopes │ ├── e2e │ │ ├── circular-request-scope.spec.ts │ │ ├── circular-transient-scope.spec.ts │ │ ├── durable-providers.spec.ts │ │ ├── inject-inquirer.spec.ts │ │ ├── msvc-request-scope.spec.ts │ │ ├── request-modules-scope.spec.ts │ │ ├── request-scope.spec.ts │ │ ├── resolve-scoped.spec.ts │ │ └── transient-scope.spec.ts │ ├── src │ │ ├── app.module.ts │ │ ├── circular-hello │ │ │ ├── dto │ │ │ │ └── test.dto.ts │ │ │ ├── guards │ │ │ │ └── request-scoped.guard.ts │ │ │ ├── hello.controller.ts │ │ │ ├── hello.module.ts │ │ │ ├── hello.service.ts │ │ │ ├── interceptors │ │ │ │ └── logging.interceptor.ts │ │ │ └── users │ │ │ │ ├── user-by-id.pipe.ts │ │ │ │ └── users.service.ts │ │ ├── circular-transient │ │ │ ├── dto │ │ │ │ └── test.dto.ts │ │ │ ├── guards │ │ │ │ └── request-scoped.guard.ts │ │ │ ├── hello.controller.ts │ │ │ ├── hello.module.ts │ │ │ ├── hello.service.ts │ │ │ ├── interceptors │ │ │ │ └── logging.interceptor.ts │ │ │ ├── test.controller.ts │ │ │ └── users │ │ │ │ ├── user-by-id.pipe.ts │ │ │ │ └── users.service.ts │ │ ├── durable │ │ │ ├── durable-context-id.strategy.ts │ │ │ ├── durable.controller.ts │ │ │ ├── durable.guard.ts │ │ │ ├── durable.module.ts │ │ │ ├── durable.service.ts │ │ │ └── non-durable.service.ts │ │ ├── hello │ │ │ ├── dto │ │ │ │ └── test.dto.ts │ │ │ ├── guards │ │ │ │ └── request-scoped.guard.ts │ │ │ ├── hello.controller.ts │ │ │ ├── hello.module.ts │ │ │ ├── hello.service.ts │ │ │ ├── interceptors │ │ │ │ └── logging.interceptor.ts │ │ │ └── users │ │ │ │ ├── user-by-id.pipe.ts │ │ │ │ └── users.service.ts │ │ ├── inject-inquirer │ │ │ ├── hello-request │ │ │ │ ├── hello-request.service.ts │ │ │ │ └── request-logger.service.ts │ │ │ ├── hello-transient │ │ │ │ ├── hello-transient.service.ts │ │ │ │ └── transient-logger.service.ts │ │ │ ├── hello.controller.ts │ │ │ └── hello.module.ts │ │ ├── main.ts │ │ ├── msvc │ │ │ ├── dto │ │ │ │ └── test.dto.ts │ │ │ ├── guards │ │ │ │ └── request-scoped.guard.ts │ │ │ ├── hello.controller.ts │ │ │ ├── hello.module.ts │ │ │ ├── hello.service.ts │ │ │ ├── http.controller.ts │ │ │ ├── interceptors │ │ │ │ └── logging.interceptor.ts │ │ │ └── users │ │ │ │ └── users.service.ts │ │ ├── request-chain │ │ │ ├── helper │ │ │ │ ├── helper.module.ts │ │ │ │ └── helper.service.ts │ │ │ ├── interceptors │ │ │ │ └── logging.interceptor.ts │ │ │ ├── request-chain.controller.ts │ │ │ ├── request-chain.module.ts │ │ │ └── request-chain.service.ts │ │ ├── resolve-scoped │ │ │ ├── logger.provider.ts │ │ │ ├── logger.service.ts │ │ │ └── request-logger.service.ts │ │ └── transient │ │ │ ├── dto │ │ │ └── test.dto.ts │ │ │ ├── guards │ │ │ └── request-scoped.guard.ts │ │ │ ├── hello.controller.ts │ │ │ ├── hello.module.ts │ │ │ ├── hello.service.ts │ │ │ ├── interceptors │ │ │ └── logging.interceptor.ts │ │ │ ├── test.controller.ts │ │ │ └── users │ │ │ ├── user-by-id.pipe.ts │ │ │ └── users.service.ts │ └── tsconfig.json ├── send-files │ ├── e2e │ │ ├── express.spec.ts │ │ ├── fastify.spec.ts │ │ └── utils.ts │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ └── non-file.ts │ └── tsconfig.json ├── testing-module-override │ ├── e2e │ │ ├── circular-dependency │ │ │ ├── a.module.ts │ │ │ └── b.module.ts │ │ └── modules-override.spec.ts │ └── tsconfig.json ├── typeorm │ ├── e2e │ │ ├── typeorm-async-class.spec.ts │ │ ├── typeorm-async-existing.spec.ts │ │ ├── typeorm-async-options.spec.ts │ │ ├── typeorm-async.spec.ts │ │ └── typeorm.spec.ts │ ├── ormconfig.json │ ├── src │ │ ├── app-async.module.ts │ │ ├── app.module.ts │ │ ├── async-class-options.module.ts │ │ ├── async-existing-options.module.ts │ │ ├── async-options.module.ts │ │ ├── database.module.ts │ │ ├── main.ts │ │ └── photo │ │ │ ├── photo.controller.ts │ │ │ ├── photo.entity.ts │ │ │ ├── photo.module.ts │ │ │ └── photo.service.ts │ └── tsconfig.json ├── versioning │ ├── e2e │ │ ├── custom-versioning-fastify.spec.ts │ │ ├── custom-versioning.spec.ts │ │ ├── default-versioning.spec.ts │ │ ├── header-versioning-fastify.spec.ts │ │ ├── header-versioning.spec.ts │ │ ├── media-type-versioning-fastify.spec.ts │ │ ├── media-type-versioning.spec.ts │ │ ├── uri-versioning-fastify.spec.ts │ │ └── uri-versioning.spec.ts │ ├── src │ │ ├── app-v1.controller.ts │ │ ├── app-v2.controller.ts │ │ ├── app.module.ts │ │ ├── main.ts │ │ ├── middleware.controller.ts │ │ ├── multiple-middleware.controller.ts │ │ ├── multiple.controller.ts │ │ ├── neutral-middleware.controller.ts │ │ ├── neutral.controller.ts │ │ ├── no-versioning.controller.ts │ │ ├── override-partial.controller.ts │ │ └── override.controller.ts │ └── tsconfig.json └── websockets │ ├── e2e │ ├── error-gateway.spec.ts │ ├── gateway-ack.spec.ts │ ├── gateway.spec.ts │ └── ws-gateway.spec.ts │ ├── src │ ├── ack.gateway.ts │ ├── app.gateway.ts │ ├── app.module.ts │ ├── core.gateway.ts │ ├── error.gateway.ts │ ├── example-path.gateway.ts │ ├── namespace.gateway.ts │ ├── request.filter.ts │ ├── request.interceptor.ts │ ├── server.gateway.ts │ ├── ws-path.gateway.ts │ └── ws-path2.gateway.ts │ └── tsconfig.json ├── lerna.json ├── package-lock.json ├── package.json ├── packages ├── common │ ├── PACKAGE.md │ ├── Readme.md │ ├── constants.ts │ ├── decorators │ │ ├── core │ │ │ ├── apply-decorators.ts │ │ │ ├── bind.decorator.ts │ │ │ ├── catch.decorator.ts │ │ │ ├── controller.decorator.ts │ │ │ ├── dependencies.decorator.ts │ │ │ ├── exception-filters.decorator.ts │ │ │ ├── index.ts │ │ │ ├── inject.decorator.ts │ │ │ ├── injectable.decorator.ts │ │ │ ├── optional.decorator.ts │ │ │ ├── set-metadata.decorator.ts │ │ │ ├── use-guards.decorator.ts │ │ │ ├── use-interceptors.decorator.ts │ │ │ ├── use-pipes.decorator.ts │ │ │ └── version.decorator.ts │ │ ├── http │ │ │ ├── create-route-param-metadata.decorator.ts │ │ │ ├── header.decorator.ts │ │ │ ├── http-code.decorator.ts │ │ │ ├── index.ts │ │ │ ├── redirect.decorator.ts │ │ │ ├── render.decorator.ts │ │ │ ├── request-mapping.decorator.ts │ │ │ ├── route-params.decorator.ts │ │ │ └── sse.decorator.ts │ │ ├── index.ts │ │ └── modules │ │ │ ├── global.decorator.ts │ │ │ ├── index.ts │ │ │ └── module.decorator.ts │ ├── enums │ │ ├── http-status.enum.ts │ │ ├── index.ts │ │ ├── request-method.enum.ts │ │ ├── route-paramtypes.enum.ts │ │ ├── shutdown-signal.enum.ts │ │ └── version-type.enum.ts │ ├── exceptions │ │ ├── bad-gateway.exception.ts │ │ ├── bad-request.exception.ts │ │ ├── conflict.exception.ts │ │ ├── forbidden.exception.ts │ │ ├── gateway-timeout.exception.ts │ │ ├── gone.exception.ts │ │ ├── http-version-not-supported.exception.ts │ │ ├── http.exception.ts │ │ ├── im-a-teapot.exception.ts │ │ ├── index.ts │ │ ├── internal-server-error.exception.ts │ │ ├── method-not-allowed.exception.ts │ │ ├── misdirected.exception.ts │ │ ├── not-acceptable.exception.ts │ │ ├── not-found.exception.ts │ │ ├── not-implemented.exception.ts │ │ ├── payload-too-large.exception.ts │ │ ├── precondition-failed.exception.ts │ │ ├── request-timeout.exception.ts │ │ ├── service-unavailable.exception.ts │ │ ├── unauthorized.exception.ts │ │ ├── unprocessable-entity.exception.ts │ │ └── unsupported-media-type.exception.ts │ ├── file-stream │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ ├── streamable-handler-response.interface.ts │ │ │ └── streamable-options.interface.ts │ │ └── streamable-file.ts │ ├── index.ts │ ├── interfaces │ │ ├── abstract.interface.ts │ │ ├── controllers │ │ │ ├── controller-metadata.interface.ts │ │ │ ├── controller.interface.ts │ │ │ └── index.ts │ │ ├── exceptions │ │ │ ├── exception-filter-metadata.interface.ts │ │ │ ├── exception-filter.interface.ts │ │ │ ├── index.ts │ │ │ ├── rpc-exception-filter-metadata.interface.ts │ │ │ ├── rpc-exception-filter.interface.ts │ │ │ └── ws-exception-filter.interface.ts │ │ ├── external │ │ │ ├── class-transform-options.interface.ts │ │ │ ├── cors-options.interface.ts │ │ │ ├── https-options.interface.ts │ │ │ ├── transformer-package.interface.ts │ │ │ ├── validation-error.interface.ts │ │ │ ├── validator-options.interface.ts │ │ │ └── validator-package.interface.ts │ │ ├── features │ │ │ ├── arguments-host.interface.ts │ │ │ ├── can-activate.interface.ts │ │ │ ├── custom-route-param-factory.interface.ts │ │ │ ├── execution-context.interface.ts │ │ │ ├── nest-interceptor.interface.ts │ │ │ ├── paramtype.interface.ts │ │ │ └── pipe-transform.interface.ts │ │ ├── global-prefix-options.interface.ts │ │ ├── hooks │ │ │ ├── before-application-shutdown.interface.ts │ │ │ ├── index.ts │ │ │ ├── on-application-bootstrap.interface.ts │ │ │ ├── on-application-shutdown.interface.ts │ │ │ ├── on-destroy.interface.ts │ │ │ └── on-init.interface.ts │ │ ├── http │ │ │ ├── http-exception-body.interface.ts │ │ │ ├── http-redirect-response.interface.ts │ │ │ ├── http-server.interface.ts │ │ │ ├── index.ts │ │ │ ├── message-event.interface.ts │ │ │ └── raw-body-request.interface.ts │ │ ├── index.ts │ │ ├── injectable.interface.ts │ │ ├── microservices │ │ │ ├── nest-hybrid-application-options.interface.ts │ │ │ └── nest-microservice-options.interface.ts │ │ ├── middleware │ │ │ ├── index.ts │ │ │ ├── middleware-config-proxy.interface.ts │ │ │ ├── middleware-configuration.interface.ts │ │ │ ├── middleware-consumer.interface.ts │ │ │ └── nest-middleware.interface.ts │ │ ├── modules │ │ │ ├── dynamic-module.interface.ts │ │ │ ├── forward-reference.interface.ts │ │ │ ├── index.ts │ │ │ ├── injection-token.interface.ts │ │ │ ├── introspection-result.interface.ts │ │ │ ├── module-metadata.interface.ts │ │ │ ├── nest-module.interface.ts │ │ │ ├── optional-factory-dependency.interface.ts │ │ │ └── provider.interface.ts │ │ ├── nest-application-context-options.interface.ts │ │ ├── nest-application-context.interface.ts │ │ ├── nest-application-options.interface.ts │ │ ├── nest-application.interface.ts │ │ ├── nest-microservice.interface.ts │ │ ├── scope-options.interface.ts │ │ ├── type.interface.ts │ │ ├── version-options.interface.ts │ │ └── websockets │ │ │ └── web-socket-adapter.interface.ts │ ├── module-utils │ │ ├── configurable-module.builder.ts │ │ ├── constants.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── configurable-module-async-options.interface.ts │ │ │ ├── configurable-module-cls.interface.ts │ │ │ ├── configurable-module-host.interface.ts │ │ │ └── index.ts │ │ └── utils │ │ │ ├── generate-options-injection-token.util.ts │ │ │ ├── get-injection-providers.util.ts │ │ │ └── index.ts │ ├── package.json │ ├── pipes │ │ ├── default-value.pipe.ts │ │ ├── file │ │ │ ├── file-type.validator.ts │ │ │ ├── file-validator.interface.ts │ │ │ ├── index.ts │ │ │ ├── interfaces │ │ │ │ ├── file.interface.ts │ │ │ │ └── index.ts │ │ │ ├── max-file-size.validator.ts │ │ │ ├── parse-file-options.interface.ts │ │ │ ├── parse-file-pipe.builder.ts │ │ │ └── parse-file.pipe.ts │ │ ├── index.ts │ │ ├── parse-array.pipe.ts │ │ ├── parse-bool.pipe.ts │ │ ├── parse-enum.pipe.ts │ │ ├── parse-float.pipe.ts │ │ ├── parse-int.pipe.ts │ │ ├── parse-uuid.pipe.ts │ │ └── validation.pipe.ts │ ├── serializer │ │ ├── class-serializer.constants.ts │ │ ├── class-serializer.interceptor.ts │ │ ├── class-serializer.interfaces.ts │ │ ├── decorators │ │ │ ├── index.ts │ │ │ └── serialize-options.decorator.ts │ │ └── index.ts │ ├── services │ │ ├── console-logger.service.ts │ │ ├── index.ts │ │ ├── logger.service.ts │ │ └── utils │ │ │ ├── index.ts │ │ │ └── is-log-level-enabled.util.ts │ ├── test │ │ ├── decorators │ │ │ ├── apply-decorators.spec.ts │ │ │ ├── bind.decorator.spec.ts │ │ │ ├── catch.decorator.spec.ts │ │ │ ├── controller.decorator.spec.ts │ │ │ ├── create-param-decorator.spec.ts │ │ │ ├── dependencies.decorator.spec.ts │ │ │ ├── exception-filters.decorator.spec.ts │ │ │ ├── global.decorator.spec.ts │ │ │ ├── header.decorator.spec.ts │ │ │ ├── http-code.decorator.spec.ts │ │ │ ├── inject.decorator.spec.ts │ │ │ ├── injectable.decorator.spec.ts │ │ │ ├── module.decorator.spec.ts │ │ │ ├── redirect.decorator.spec.ts │ │ │ ├── render.decorator.spec.ts │ │ │ ├── request-mapping.decorator.spec.ts │ │ │ ├── route-params.decorator.spec.ts │ │ │ ├── set-metadata.decorator.spec.ts │ │ │ ├── sse.decorator.spec.ts │ │ │ ├── use-guards.decorator.spec.ts │ │ │ ├── use-interceptors.decorator.spec.ts │ │ │ ├── use-pipes.decorator.spec.ts │ │ │ └── version.decorator.spec.ts │ │ ├── exceptions │ │ │ └── http.exception.spec.ts │ │ ├── file-stream │ │ │ └── streamable-file.spec.ts │ │ ├── module-utils │ │ │ ├── configurable-module.builder.spec.ts │ │ │ └── utils │ │ │ │ └── get-injection-providers.util.spec.ts │ │ ├── pipes │ │ │ ├── default-value.pipe.spec.ts │ │ │ ├── file │ │ │ │ ├── file-type.validator.spec.ts │ │ │ │ ├── max-file-size.validator.spec.ts │ │ │ │ ├── parse-file-pipe.builder.spec.ts │ │ │ │ └── parse-file.pipe.spec.ts │ │ │ ├── parse-array.pipe.spec.ts │ │ │ ├── parse-bool.pipe.spec.ts │ │ │ ├── parse-enum.pipe.spec.ts │ │ │ ├── parse-float.pipe.spec.ts │ │ │ ├── parse-int.pipe.spec.ts │ │ │ ├── parse-uuid.pipe.spec.ts │ │ │ └── validation.pipe.spec.ts │ │ ├── services │ │ │ ├── logger.service.spec.ts │ │ │ └── utils │ │ │ │ └── is-log-level-enabled.util.spec.ts │ │ ├── tsconfig.json │ │ └── utils │ │ │ ├── forward-ref.util.spec.ts │ │ │ ├── load-package.util.spec.ts │ │ │ ├── merge-with-values.util.spec.ts │ │ │ ├── random-string-generator.util.spec.ts │ │ │ ├── select-exception-filter-metadata.util.spec.ts │ │ │ ├── shared.utils.spec.ts │ │ │ └── validate-each.util.spec.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── utils │ │ ├── assign-custom-metadata.util.ts │ │ ├── cli-colors.util.ts │ │ ├── extend-metadata.util.ts │ │ ├── forward-ref.util.ts │ │ ├── http-error-by-code.util.ts │ │ ├── index.ts │ │ ├── load-package.util.ts │ │ ├── merge-with-values.util.ts │ │ ├── random-string-generator.util.ts │ │ ├── select-exception-filter-metadata.util.ts │ │ ├── shared.utils.ts │ │ ├── validate-each.util.ts │ │ └── validate-module-keys.util.ts ├── core │ ├── PACKAGE.md │ ├── Readme.md │ ├── adapters │ │ ├── http-adapter.ts │ │ └── index.ts │ ├── application-config.ts │ ├── constants.ts │ ├── discovery │ │ ├── discoverable-meta-host-collection.ts │ │ ├── discovery-module.ts │ │ ├── discovery-service.ts │ │ └── index.ts │ ├── errors │ │ ├── exception-handler.ts │ │ ├── exceptions-zone.ts │ │ ├── exceptions │ │ │ ├── circular-dependency.exception.ts │ │ │ ├── index.ts │ │ │ ├── invalid-class-module.exception.ts │ │ │ ├── invalid-class-scope.exception.ts │ │ │ ├── invalid-class.exception.ts │ │ │ ├── invalid-exception-filter.exception.ts │ │ │ ├── invalid-middleware-configuration.exception.ts │ │ │ ├── invalid-middleware.exception.ts │ │ │ ├── invalid-module.exception.ts │ │ │ ├── runtime.exception.ts │ │ │ ├── undefined-dependency.exception.ts │ │ │ ├── undefined-forwardref.exception.ts │ │ │ ├── undefined-module.exception.ts │ │ │ ├── unknown-dependencies.exception.ts │ │ │ ├── unknown-element.exception.ts │ │ │ ├── unknown-export.exception.ts │ │ │ ├── unknown-module.exception.ts │ │ │ └── unknown-request-mapping.exception.ts │ │ └── messages.ts │ ├── exceptions │ │ ├── base-exception-filter-context.ts │ │ ├── base-exception-filter.ts │ │ ├── exceptions-handler.ts │ │ ├── external-exception-filter-context.ts │ │ ├── external-exception-filter.ts │ │ ├── external-exceptions-handler.ts │ │ └── index.ts │ ├── guards │ │ ├── constants.ts │ │ ├── guards-consumer.ts │ │ ├── guards-context-creator.ts │ │ └── index.ts │ ├── helpers │ │ ├── context-creator.ts │ │ ├── context-id-factory.ts │ │ ├── context-utils.ts │ │ ├── execution-context-host.ts │ │ ├── external-context-creator.ts │ │ ├── external-proxy.ts │ │ ├── get-class-scope.ts │ │ ├── handler-metadata-storage.ts │ │ ├── http-adapter-host.ts │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── external-handler-metadata.interface.ts │ │ │ ├── index.ts │ │ │ └── params-metadata.interface.ts │ │ ├── is-durable.ts │ │ ├── load-adapter.ts │ │ ├── messages.ts │ │ ├── optional-require.ts │ │ ├── rethrow.ts │ │ └── router-method-factory.ts │ ├── hooks │ │ ├── before-app-shutdown.hook.ts │ │ ├── index.ts │ │ ├── on-app-bootstrap.hook.ts │ │ ├── on-app-shutdown.hook.ts │ │ ├── on-module-destroy.hook.ts │ │ └── on-module-init.hook.ts │ ├── index.ts │ ├── injector │ │ ├── abstract-instance-resolver.ts │ │ ├── compiler.ts │ │ ├── constants.ts │ │ ├── container.ts │ │ ├── helpers │ │ │ ├── provider-classifier.ts │ │ │ ├── silent-logger.ts │ │ │ └── transient-instances.ts │ │ ├── index.ts │ │ ├── injector.ts │ │ ├── inquirer │ │ │ ├── index.ts │ │ │ ├── inquirer-constants.ts │ │ │ └── inquirer-providers.ts │ │ ├── instance-links-host.ts │ │ ├── instance-loader.ts │ │ ├── instance-wrapper.ts │ │ ├── internal-core-module │ │ │ ├── index.ts │ │ │ ├── internal-core-module-factory.ts │ │ │ └── internal-core-module.ts │ │ ├── internal-providers-storage.ts │ │ ├── lazy-module-loader │ │ │ ├── lazy-module-loader-options.interface.ts │ │ │ └── lazy-module-loader.ts │ │ ├── module-ref.ts │ │ ├── module-token-factory.ts │ │ ├── module.ts │ │ ├── modules-container.ts │ │ └── settlement-signal.ts │ ├── inspector │ │ ├── deterministic-uuid-registry.ts │ │ ├── graph-inspector.ts │ │ ├── index.ts │ │ ├── initialize-on-preview.allowlist.ts │ │ ├── interfaces │ │ │ ├── edge.interface.ts │ │ │ ├── enhancer-metadata-cache-entry.interface.ts │ │ │ ├── entrypoint.interface.ts │ │ │ ├── extras.interface.ts │ │ │ ├── node.interface.ts │ │ │ ├── serialized-graph-json.interface.ts │ │ │ └── serialized-graph-metadata.interface.ts │ │ ├── noop-graph-inspector.ts │ │ ├── partial-graph.host.ts │ │ ├── serialized-graph.ts │ │ └── uuid-factory.ts │ ├── interceptors │ │ ├── index.ts │ │ ├── interceptors-consumer.ts │ │ └── interceptors-context-creator.ts │ ├── interfaces │ │ ├── module-definition.interface.ts │ │ └── module-override.interface.ts │ ├── metadata-scanner.ts │ ├── middleware │ │ ├── builder.ts │ │ ├── container.ts │ │ ├── index.ts │ │ ├── middleware-module.ts │ │ ├── resolver.ts │ │ ├── route-info-path-extractor.ts │ │ ├── routes-mapper.ts │ │ └── utils.ts │ ├── nest-application-context.ts │ ├── nest-application.ts │ ├── nest-factory.ts │ ├── package.json │ ├── pipes │ │ ├── index.ts │ │ ├── params-token-factory.ts │ │ ├── pipes-consumer.ts │ │ └── pipes-context-creator.ts │ ├── repl │ │ ├── assign-to-object.util.ts │ │ ├── constants.ts │ │ ├── index.ts │ │ ├── native-functions │ │ │ ├── debug-repl-fn.ts │ │ │ ├── get-relp-fn.ts │ │ │ ├── help-repl-fn.ts │ │ │ ├── index.ts │ │ │ ├── methods-repl-fn.ts │ │ │ ├── resolve-repl-fn.ts │ │ │ └── select-relp-fn.ts │ │ ├── repl-context.ts │ │ ├── repl-function.ts │ │ ├── repl-logger.ts │ │ ├── repl-native-commands.ts │ │ ├── repl.interfaces.ts │ │ └── repl.ts │ ├── router │ │ ├── index.ts │ │ ├── interfaces │ │ │ ├── exceptions-filter.interface.ts │ │ │ ├── exclude-route-metadata.interface.ts │ │ │ ├── index.ts │ │ │ ├── resolver.interface.ts │ │ │ ├── route-params-factory.interface.ts │ │ │ ├── route-path-metadata.interface.ts │ │ │ └── routes.interface.ts │ │ ├── paths-explorer.ts │ │ ├── request │ │ │ ├── index.ts │ │ │ ├── request-constants.ts │ │ │ └── request-providers.ts │ │ ├── route-params-factory.ts │ │ ├── route-path-factory.ts │ │ ├── router-exception-filters.ts │ │ ├── router-execution-context.ts │ │ ├── router-explorer.ts │ │ ├── router-module.ts │ │ ├── router-proxy.ts │ │ ├── router-response-controller.ts │ │ ├── routes-resolver.ts │ │ ├── sse-stream.ts │ │ └── utils │ │ │ ├── exclude-route.util.ts │ │ │ ├── flatten-route-paths.util.ts │ │ │ └── index.ts │ ├── scanner.ts │ ├── services │ │ ├── index.ts │ │ └── reflector.service.ts │ ├── test │ │ ├── application-config.spec.ts │ │ ├── errors │ │ │ └── test │ │ │ │ ├── exception-handler.spec.ts │ │ │ │ ├── exceptions-zone.spec.ts │ │ │ │ └── messages.spec.ts │ │ ├── exceptions │ │ │ ├── base-exception-filter.spec.ts │ │ │ ├── exceptions-handler.spec.ts │ │ │ ├── external-exception-filter-context.spec.ts │ │ │ └── external-exceptions-handler.spec.ts │ │ ├── guards │ │ │ ├── guards-consumer.spec.ts │ │ │ └── guards-context-creator.spec.ts │ │ ├── helpers │ │ │ ├── application-ref-host.spec.ts │ │ │ ├── context-id-factory.spec.ts │ │ │ ├── context-utils.spec.ts │ │ │ ├── execution-context-host.spec.ts │ │ │ ├── external-context-creator.spec.ts │ │ │ ├── external-proxy.spec.ts │ │ │ └── router-method-factory.spec.ts │ │ ├── hooks │ │ │ ├── before-app-shutdown.hook.spec.ts │ │ │ ├── on-app-bootstrap.hook.spec.ts │ │ │ ├── on-app-shutdown.hook.spec.ts │ │ │ ├── on-module-destroy.hook.spec.ts │ │ │ └── on-module-init.hook.spec.ts │ │ ├── injector │ │ │ ├── compiler.spec.ts │ │ │ ├── container.spec.ts │ │ │ ├── helpers │ │ │ │ └── provider-classifier.spec.ts │ │ │ ├── injector.spec.ts │ │ │ ├── instance-loader.spec.ts │ │ │ ├── instance-wrapper.spec.ts │ │ │ ├── internal-core-module │ │ │ │ └── internal-core-module-factory.spec.ts │ │ │ ├── lazy-module-loader │ │ │ │ └── lazy-module-loader.spec.ts │ │ │ ├── module-token-factory.spec.ts │ │ │ └── module.spec.ts │ │ ├── inspector │ │ │ ├── graph-inspector.spec.ts │ │ │ └── serialized-graph.spec.ts │ │ ├── interceptors │ │ │ ├── interceptors-consumer.spec.ts │ │ │ └── interceptors-context-creator.spec.ts │ │ ├── metadata-scanner.spec.ts │ │ ├── middleware │ │ │ ├── builder.spec.ts │ │ │ ├── container.spec.ts │ │ │ ├── middleware-module.spec.ts │ │ │ ├── resolver.spec.ts │ │ │ ├── route-info-path-extractor.spec.ts │ │ │ ├── routes-mapper.spec.ts │ │ │ └── utils.spec.ts │ │ ├── nest-application-context.spec.ts │ │ ├── nest-application.spec.ts │ │ ├── pipes │ │ │ ├── params-token-factory.spec.ts │ │ │ ├── pipes-consumer.spec.ts │ │ │ └── pipes-context-creator.spec.ts │ │ ├── repl │ │ │ ├── assign-to-object.util.spec.ts │ │ │ ├── native-functions │ │ │ │ ├── debug-repl-fn.spec.ts │ │ │ │ ├── get-repl-fn.spec.ts │ │ │ │ ├── help-repl-fn.spec.ts │ │ │ │ ├── methods-repl-fn.spec.ts │ │ │ │ ├── resolve-repl-fn.spec.ts │ │ │ │ └── select-repl-fn.spec.ts │ │ │ └── repl-context.spec.ts │ │ ├── router │ │ │ ├── paths-explorer.spec.ts │ │ │ ├── route-params-factory.spec.ts │ │ │ ├── route-path-factory.spec.ts │ │ │ ├── router-exception-filters.spec.ts │ │ │ ├── router-execution-context.spec.ts │ │ │ ├── router-explorer.spec.ts │ │ │ ├── router-module.spec.ts │ │ │ ├── router-proxy.spec.ts │ │ │ ├── router-response-controller.spec.ts │ │ │ ├── routes-resolver.spec.ts │ │ │ ├── sse-stream.spec.ts │ │ │ └── utils │ │ │ │ └── flat-routes.spec.ts │ │ ├── scanner.spec.ts │ │ ├── services │ │ │ └── reflector.service.spec.ts │ │ ├── tsconfig.json │ │ └── utils │ │ │ ├── noop-adapter.spec.ts │ │ │ └── string.cleaner.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── index.ts ├── microservices │ ├── Readme.md │ ├── client │ │ ├── client-grpc.ts │ │ ├── client-kafka.ts │ │ ├── client-mqtt.ts │ │ ├── client-nats.ts │ │ ├── client-proxy-factory.ts │ │ ├── client-proxy.ts │ │ ├── client-redis.ts │ │ ├── client-rmq.ts │ │ ├── client-tcp.ts │ │ ├── constants.ts │ │ └── index.ts │ ├── constants.ts │ ├── container.ts │ ├── context │ │ ├── exception-filters-context.ts │ │ ├── request-context-host.ts │ │ ├── rpc-context-creator.ts │ │ ├── rpc-metadata-constants.ts │ │ └── rpc-proxy.ts │ ├── ctx-host │ │ ├── base-rpc.context.ts │ │ ├── index.ts │ │ ├── kafka.context.ts │ │ ├── mqtt.context.ts │ │ ├── nats.context.ts │ │ ├── redis.context.ts │ │ ├── rmq.context.ts │ │ └── tcp.context.ts │ ├── decorators │ │ ├── client.decorator.ts │ │ ├── ctx.decorator.ts │ │ ├── event-pattern.decorator.ts │ │ ├── grpc-service.decorator.ts │ │ ├── index.ts │ │ ├── message-pattern.decorator.ts │ │ └── payload.decorator.ts │ ├── deserializers │ │ ├── identity.deserializer.ts │ │ ├── incoming-request.deserializer.ts │ │ ├── incoming-response.deserializer.ts │ │ ├── index.ts │ │ ├── kafka-request.deserializer.ts │ │ ├── kafka-response.deserializer.ts │ │ ├── nats-request-json.deserializer.ts │ │ └── nats-response-json.deserializer.ts │ ├── enums │ │ ├── index.ts │ │ ├── kafka-headers.enum.ts │ │ ├── pattern-handler.enum.ts │ │ ├── rpc-paramtype.enum.ts │ │ └── transport.enum.ts │ ├── errors │ │ ├── corrupted-packet-length.exception.ts │ │ ├── empty-response.exception.ts │ │ ├── invalid-grpc-message-decorator.exception.ts │ │ ├── invalid-grpc-package-definition-missing-package-definition.exception.ts │ │ ├── invalid-grpc-package-definition-mutex.exception.ts │ │ ├── invalid-grpc-package.exception.ts │ │ ├── invalid-grpc-service.exception.ts │ │ ├── invalid-json-format.exception.ts │ │ ├── invalid-kafka-client-topic.exception.ts │ │ ├── invalid-message.exception.ts │ │ ├── invalid-proto-definition.exception.ts │ │ └── net-socket-closed.exception.ts │ ├── exceptions │ │ ├── base-rpc-exception-filter.ts │ │ ├── index.ts │ │ ├── kafka-retriable-exception.ts │ │ ├── rpc-exception.ts │ │ └── rpc-exceptions-handler.ts │ ├── external │ │ ├── grpc-options.interface.ts │ │ ├── kafka.interface.ts │ │ ├── mqtt-client.interface.ts │ │ ├── mqtt-options.interface.ts │ │ ├── nats-client.interface.ts │ │ ├── redis.interface.ts │ │ └── rmq-url.interface.ts │ ├── factories │ │ └── rpc-params-factory.ts │ ├── helpers │ │ ├── grpc-helpers.ts │ │ ├── index.ts │ │ ├── json-socket.ts │ │ ├── kafka-logger.ts │ │ ├── kafka-parser.ts │ │ ├── kafka-reply-partition-assigner.ts │ │ └── tcp-socket.ts │ ├── index.ts │ ├── interfaces │ │ ├── client-grpc.interface.ts │ │ ├── client-metadata.interface.ts │ │ ├── closeable.interface.ts │ │ ├── custom-transport-strategy.interface.ts │ │ ├── deserializer.interface.ts │ │ ├── index.ts │ │ ├── message-handler.interface.ts │ │ ├── microservice-configuration.interface.ts │ │ ├── microservice-entrypoint-metadata.interface.ts │ │ ├── packet.interface.ts │ │ ├── pattern-metadata.interface.ts │ │ ├── pattern.interface.ts │ │ ├── request-context.interface.ts │ │ └── serializer.interface.ts │ ├── listener-metadata-explorer.ts │ ├── listeners-controller.ts │ ├── microservices-module.ts │ ├── module │ │ ├── clients.module.ts │ │ ├── index.ts │ │ └── interfaces │ │ │ ├── clients-module.interface.ts │ │ │ └── index.ts │ ├── nest-microservice.ts │ ├── package.json │ ├── record-builders │ │ ├── index.ts │ │ ├── mqtt.record-builder.ts │ │ ├── nats.record-builder.ts │ │ └── rmq.record-builder.ts │ ├── serializers │ │ ├── identity.serializer.ts │ │ ├── index.ts │ │ ├── kafka-request.serializer.ts │ │ ├── mqtt-record.serializer.ts │ │ ├── nats-record.serializer.ts │ │ └── rmq-record.serializer.ts │ ├── server │ │ ├── index.ts │ │ ├── server-factory.ts │ │ ├── server-grpc.ts │ │ ├── server-kafka.ts │ │ ├── server-mqtt.ts │ │ ├── server-nats.ts │ │ ├── server-redis.ts │ │ ├── server-rmq.ts │ │ ├── server-tcp.ts │ │ └── server.ts │ ├── test │ │ ├── client │ │ │ ├── client-grpc.spec.ts │ │ │ ├── client-kafka.spec.ts │ │ │ ├── client-mqtt.spec.ts │ │ │ ├── client-nats.spec.ts │ │ │ ├── client-proxy-factory.spec.ts │ │ │ ├── client-proxy.spec.ts │ │ │ ├── client-redis.spec.ts │ │ │ ├── client-rmq.spec.ts │ │ │ ├── client-tcp.spec.ts │ │ │ ├── test.proto │ │ │ └── test2.proto │ │ ├── container.spec.ts │ │ ├── context │ │ │ ├── exception-filters-context.spec.ts │ │ │ ├── request-context-host.spec.ts │ │ │ ├── rpc-context-creator.spec.ts │ │ │ └── rpc-proxy.spec.ts │ │ ├── ctx-host │ │ │ ├── base-rpc-context.spec.ts │ │ │ ├── kafka.context.spec.ts │ │ │ ├── mqtt.context.spec.ts │ │ │ ├── nats.context.spec.ts │ │ │ ├── redis.context.spec.ts │ │ │ ├── rmq.context.spec.ts │ │ │ └── tcp.context.spec.ts │ │ ├── decorators │ │ │ ├── client.decorator.spec.ts │ │ │ ├── ctx.decorator.spec.ts │ │ │ ├── event-pattern.decorator.spec.ts │ │ │ ├── message-pattern.decorator.spec.ts │ │ │ └── payload.decorator.spec.ts │ │ ├── deserializers │ │ │ ├── identity.deserializer.spec.ts │ │ │ ├── incoming-request.deserializer.spec.ts │ │ │ ├── incoming-response.deserializer.spec.ts │ │ │ └── kafka-response.deserializer.spec.ts │ │ ├── exceptions │ │ │ ├── rpc-exception.spec.ts │ │ │ └── rpc-exceptions-handler.spec.ts │ │ ├── factories │ │ │ └── rpc-params-factory.spec.ts │ │ ├── helpers │ │ │ ├── grpc-helpers.spec.ts │ │ │ ├── kafka-logger.spec.ts │ │ │ ├── kafka-parser.spec.ts │ │ │ └── kafka-reply-partition-assigner.spec.ts │ │ ├── json-socket │ │ │ ├── connection.spec.ts │ │ │ ├── data │ │ │ │ └── long-payload-with-special-chars.ts │ │ │ ├── helpers.ts │ │ │ ├── listener-chaining.spec.ts │ │ │ └── message-parsing.spec.ts │ │ ├── listeners-controller.spec.ts │ │ ├── listeners-metadata-explorer.spec.ts │ │ ├── module │ │ │ └── clients.module.spec.ts │ │ ├── serializers │ │ │ ├── identity.serializer.spec.ts │ │ │ ├── kafka-request.serializer.spec.ts │ │ │ ├── mqtt-record.serializer.spec.ts │ │ │ ├── nats-record.serializer.spec.ts │ │ │ └── rmq-record.serializer.spec.ts │ │ ├── server │ │ │ ├── server-factory.spec.ts │ │ │ ├── server-grpc.spec.ts │ │ │ ├── server-kafka.spec.ts │ │ │ ├── server-mqtt.spec.ts │ │ │ ├── server-nats.spec.ts │ │ │ ├── server-redis.spec.ts │ │ │ ├── server-rmq.spec.ts │ │ │ ├── server-tcp.spec.ts │ │ │ ├── server.spec.ts │ │ │ ├── test.proto │ │ │ └── test2.proto │ │ ├── tsconfig.json │ │ └── utils │ │ │ └── transform-pattern.utils.spec.ts │ ├── tokens.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── utils │ │ ├── index.ts │ │ ├── param.utils.ts │ │ └── transform-pattern.utils.ts ├── platform-express │ ├── Readme.md │ ├── adapters │ │ ├── express-adapter.ts │ │ ├── index.ts │ │ └── utils │ │ │ └── get-body-parser-options.util.ts │ ├── index.ts │ ├── interfaces │ │ ├── index.ts │ │ ├── nest-express-application.interface.ts │ │ ├── nest-express-body-parser-options.interface.ts │ │ ├── nest-express-body-parser.interface.ts │ │ └── serve-static-options.interface.ts │ ├── multer │ │ ├── files.constants.ts │ │ ├── index.ts │ │ ├── interceptors │ │ │ ├── any-files.interceptor.ts │ │ │ ├── file-fields.interceptor.ts │ │ │ ├── file.interceptor.ts │ │ │ ├── files.interceptor.ts │ │ │ ├── index.ts │ │ │ └── no-files.interceptor.ts │ │ ├── interfaces │ │ │ ├── files-upload-module.interface.ts │ │ │ ├── index.ts │ │ │ └── multer-options.interface.ts │ │ ├── multer.constants.ts │ │ ├── multer.module.ts │ │ └── multer │ │ │ ├── multer.constants.ts │ │ │ └── multer.utils.ts │ ├── package.json │ ├── test │ │ ├── multer │ │ │ ├── interceptors │ │ │ │ ├── any-files.interceptor.spec.ts │ │ │ │ ├── file-fields.interceptor.spec.ts │ │ │ │ ├── file.interceptor.spec.ts │ │ │ │ ├── files.interceptor.spec.ts │ │ │ │ └── no-files.inteceptor.spec.ts │ │ │ └── multer │ │ │ │ ├── multer.module.spec.ts │ │ │ │ └── multer.utils.spec.ts │ │ └── tsconfig.json │ ├── tsconfig.build.json │ └── tsconfig.json ├── platform-fastify │ ├── Readme.md │ ├── adapters │ │ ├── fastify-adapter.ts │ │ └── index.ts │ ├── constants.ts │ ├── decorators │ │ ├── index.ts │ │ ├── route-config.decorator.ts │ │ └── route-constraints.decorator.ts │ ├── index.ts │ ├── interfaces │ │ ├── external │ │ │ ├── fastify-static-options.interface.ts │ │ │ ├── fastify-view-options.interface.ts │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── nest-fastify-application.interface.ts │ │ └── nest-fastify-body-parser-options.interface.ts │ ├── package.json │ ├── test │ │ └── decorators │ │ │ ├── router-config.decorator.spec.ts │ │ │ └── router-constraints.decorator.spec.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── platform-socket.io │ ├── Readme.md │ ├── adapters │ │ ├── index.ts │ │ └── io-adapter.ts │ ├── index.ts │ ├── package.json │ ├── tsconfig.build.json │ └── tsconfig.json ├── platform-ws │ ├── Readme.md │ ├── adapters │ │ ├── index.ts │ │ └── ws-adapter.ts │ ├── index.ts │ ├── package.json │ ├── tsconfig.build.json │ └── tsconfig.json ├── testing │ ├── Readme.md │ ├── index.ts │ ├── interfaces │ │ ├── index.ts │ │ ├── mock-factory.ts │ │ ├── override-by-factory-options.interface.ts │ │ ├── override-by.interface.ts │ │ └── override-module.interface.ts │ ├── package.json │ ├── services │ │ └── testing-logger.service.ts │ ├── test.ts │ ├── testing-injector.ts │ ├── testing-instance-loader.ts │ ├── testing-module.builder.ts │ ├── testing-module.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── tsconfig.build.json ├── tsconfig.json └── websockets │ ├── Readme.md │ ├── adapters │ ├── index.ts │ └── ws-adapter.ts │ ├── constants.ts │ ├── context │ ├── exception-filters-context.ts │ ├── ws-context-creator.ts │ ├── ws-metadata-constants.ts │ └── ws-proxy.ts │ ├── decorators │ ├── connected-socket.decorator.ts │ ├── gateway-server.decorator.ts │ ├── index.ts │ ├── message-body.decorator.ts │ ├── socket-gateway.decorator.ts │ └── subscribe-message.decorator.ts │ ├── enums │ └── ws-paramtype.enum.ts │ ├── errors │ ├── index.ts │ ├── invalid-socket-port.exception.ts │ └── ws-exception.ts │ ├── exceptions │ ├── base-ws-exception-filter.ts │ ├── index.ts │ └── ws-exceptions-handler.ts │ ├── factories │ ├── server-and-event-streams-factory.ts │ └── ws-params-factory.ts │ ├── gateway-metadata-explorer.ts │ ├── index.ts │ ├── interfaces │ ├── gateway-metadata.interface.ts │ ├── hooks │ │ ├── index.ts │ │ ├── on-gateway-connection.interface.ts │ │ ├── on-gateway-disconnect.interface.ts │ │ └── on-gateway-init.interface.ts │ ├── index.ts │ ├── nest-gateway.interface.ts │ ├── server-and-event-streams-host.interface.ts │ ├── web-socket-server.interface.ts │ ├── websockets-entrypoint-metadata.interface.ts │ └── ws-response.interface.ts │ ├── package.json │ ├── socket-module.ts │ ├── socket-server-provider.ts │ ├── sockets-container.ts │ ├── test │ ├── container.spec.ts │ ├── context │ │ ├── exception-filters.context.spec.ts │ │ ├── ws-context-creator.spec.ts │ │ └── ws-proxy.spec.ts │ ├── decorators │ │ ├── connected-socket.decorator.spec.ts │ │ └── message-body.decorator.spec.ts │ ├── exceptions │ │ ├── ws-exception.spec.ts │ │ └── ws-exceptions-handler.spec.ts │ ├── factories │ │ ├── server-and-event-streams-factory.spec.ts │ │ └── ws-params-factory.spec.ts │ ├── gateway-metadata-explorer.spec.ts │ ├── socket-server-provider.spec.ts │ ├── tsconfig.json │ ├── utils │ │ ├── compare-element.util.spec.ts │ │ ├── gateway-server.decorator.spec.ts │ │ ├── socket-gateway.decorator.spec.ts │ │ └── subscribe-message.decorator.spec.ts │ └── web-sockets-controller.spec.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── utils │ ├── compare-element.util.ts │ ├── index.ts │ └── param.utils.ts │ └── web-sockets-controller.ts ├── readme_jp.md ├── readme_kr.md ├── readme_zh.md ├── renovate.json ├── sample ├── 01-cats-app │ ├── .eslintrc.js │ ├── .gitignore │ ├── e2e │ │ ├── cats │ │ │ └── cats.e2e-spec.ts │ │ └── jest-e2e.json │ ├── jest.json │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── cats │ │ │ ├── cats.controller.spec.ts │ │ │ ├── cats.controller.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.service.spec.ts │ │ │ ├── cats.service.ts │ │ │ ├── dto │ │ │ │ └── create-cat.dto.ts │ │ │ └── interfaces │ │ │ │ └── cat.interface.ts │ │ ├── common │ │ │ ├── decorators │ │ │ │ └── roles.decorator.ts │ │ │ ├── filters │ │ │ │ └── http-exception.filter.ts │ │ │ ├── guards │ │ │ │ └── roles.guard.ts │ │ │ ├── interceptors │ │ │ │ ├── exception.interceptor.ts │ │ │ │ └── timeout.interceptor.ts │ │ │ ├── middleware │ │ │ │ └── logger.middleware.ts │ │ │ └── pipes │ │ │ │ ├── parse-int.pipe.ts │ │ │ │ └── validation.pipe.ts │ │ ├── core │ │ │ ├── core.module.ts │ │ │ └── interceptors │ │ │ │ ├── logging.interceptor.ts │ │ │ │ └── transform.interceptor.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 02-gateways │ ├── .eslintrc.js │ ├── .gitignore │ ├── client │ │ └── index.html │ ├── e2e │ │ ├── events-gateway │ │ │ └── gateway.e2e-spec.ts │ │ └── jest-e2e.json │ ├── jest.json │ ├── package.json │ ├── src │ │ ├── adapters │ │ │ └── redis-io.adapter.ts │ │ ├── app.module.ts │ │ ├── events │ │ │ ├── events.gateway.spec.ts │ │ │ ├── events.gateway.ts │ │ │ └── events.module.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 03-microservices │ ├── .eslintrc.js │ ├── .gitignore │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── common │ │ │ ├── filters │ │ │ │ └── rpc-exception.filter.ts │ │ │ ├── interceptors │ │ │ │ └── logging.interceptor.ts │ │ │ └── strategies │ │ │ │ └── nats.strategy.ts │ │ ├── main.ts │ │ └── math │ │ │ ├── math.constants.ts │ │ │ ├── math.controller.ts │ │ │ └── math.module.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 04-grpc │ ├── .eslintrc.js │ ├── .gitignore │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── grpc-client.options.ts │ │ ├── hero │ │ │ ├── hero.controller.ts │ │ │ ├── hero.module.ts │ │ │ ├── hero.proto │ │ │ └── interfaces │ │ │ │ ├── hero-by-id.interface.ts │ │ │ │ └── hero.interface.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 05-sql-typeorm │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── docker-compose.yml │ ├── jest.json │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── main.ts │ │ └── users │ │ │ ├── dto │ │ │ └── create-user.dto.ts │ │ │ ├── user.entity.ts │ │ │ ├── users.controller.spec.ts │ │ │ ├── users.controller.ts │ │ │ ├── users.module.ts │ │ │ ├── users.service.spec.ts │ │ │ └── users.service.ts │ ├── test │ │ ├── jest-e2e.json │ │ └── users │ │ │ └── users.e2e-spec.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 06-mongoose │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── docker-compose.yml │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── cats │ │ │ ├── cats.controller.spec.ts │ │ │ ├── cats.controller.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.service.spec.ts │ │ │ ├── cats.service.ts │ │ │ ├── dto │ │ │ │ ├── create-cat.dto.ts │ │ │ │ └── update-cat.dto.ts │ │ │ └── schemas │ │ │ │ └── cat.schema.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 07-sequelize │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── docker-compose.yml │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── main.ts │ │ └── users │ │ │ ├── dto │ │ │ └── create-user.dto.ts │ │ │ ├── models │ │ │ └── user.model.ts │ │ │ ├── users.controller.spec.ts │ │ │ ├── users.controller.ts │ │ │ ├── users.module.ts │ │ │ ├── users.service.spec.ts │ │ │ └── users.service.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 08-webpack │ ├── .eslintrc.js │ ├── .gitignore │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ └── main.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── webpack-hmr.config.js ├── 09-babel-example │ ├── .babelrc │ ├── .gitignore │ ├── index.js │ ├── jsconfig.json │ ├── nodemon.json │ ├── package.json │ └── src │ │ ├── app.module.js │ │ ├── cats │ │ ├── cats.controller.js │ │ ├── cats.module.js │ │ └── cats.service.js │ │ └── main.js ├── 10-fastify │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── cats │ │ │ ├── cats.controller.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.service.ts │ │ │ ├── dto │ │ │ │ └── create-cat.dto.ts │ │ │ └── interfaces │ │ │ │ └── cat.interface.ts │ │ ├── common │ │ │ ├── decorators │ │ │ │ └── roles.decorator.ts │ │ │ ├── guards │ │ │ │ └── roles.guard.ts │ │ │ ├── interceptors │ │ │ │ └── exception.interceptor.ts │ │ │ ├── middleware │ │ │ │ └── logger.middleware.ts │ │ │ └── pipes │ │ │ │ ├── parse-int.pipe.ts │ │ │ │ └── validation.pipe.ts │ │ ├── core │ │ │ ├── core.module.ts │ │ │ └── interceptors │ │ │ │ ├── logging.interceptor.ts │ │ │ │ └── transform.interceptor.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 11-swagger │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── cats │ │ │ ├── cats.controller.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.service.ts │ │ │ ├── dto │ │ │ │ └── create-cat.dto.ts │ │ │ └── entities │ │ │ │ └── cat.entity.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 12-graphql-schema-first │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── e2e │ │ ├── cats │ │ │ └── cats.e2e-spec.ts │ │ └── jest-e2e.json │ ├── generate-typings.ts │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── cats │ │ │ ├── cat-owner.resolver.spec.ts │ │ │ ├── cat-owner.resolver.ts │ │ │ ├── cats.graphql │ │ │ ├── cats.guard.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.resolver.spec.ts │ │ │ ├── cats.resolver.ts │ │ │ ├── cats.service.spec.ts │ │ │ ├── cats.service.ts │ │ │ └── dto │ │ │ │ └── create-cat.dto.ts │ │ ├── common │ │ │ ├── directives │ │ │ │ └── upper-case.directive.ts │ │ │ ├── plugins │ │ │ │ └── logging.plugin.ts │ │ │ └── scalars │ │ │ │ └── date.scalar.ts │ │ ├── graphql.schema.ts │ │ ├── main.ts │ │ └── owners │ │ │ ├── owners.module.ts │ │ │ ├── owners.service.spec.ts │ │ │ └── owners.service.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 13-mongo-typeorm │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── docker-compose.yml │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── main.ts │ │ └── photo │ │ │ ├── photo.controller.spec.ts │ │ │ ├── photo.controller.ts │ │ │ ├── photo.entity.ts │ │ │ ├── photo.module.ts │ │ │ ├── photo.service.spec.ts │ │ │ └── photo.service.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 14-mongoose-base │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── docker-compose.yml │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── cats │ │ │ ├── cats.controller.spec.ts │ │ │ ├── cats.controller.ts │ │ │ ├── cats.module.ts │ │ │ ├── cats.providers.ts │ │ │ ├── cats.service.spec.ts │ │ │ ├── cats.service.ts │ │ │ ├── dto │ │ │ │ └── create-cat.dto.ts │ │ │ ├── interfaces │ │ │ │ └── cat.interface.ts │ │ │ └── schemas │ │ │ │ └── cat.schema.ts │ │ ├── database │ │ │ ├── database.module.ts │ │ │ └── database.providers.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 15-mvc │ ├── .eslintrc.js │ ├── .gitignore │ ├── nodemon.json │ ├── package.json │ ├── public │ │ └── .gitkeep │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ └── main.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── views │ │ └── index.hbs ├── 16-gateways-ws │ ├── .eslintrc.js │ ├── .gitignore │ ├── client │ │ └── index.html │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── events │ │ │ ├── events.gateway.ts │ │ │ └── events.module.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 17-mvc-fastify │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── nodemon.json │ ├── package.json │ ├── public │ │ └── .gitkeep │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ └── main.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── views │ │ └── index.hbs ├── 18-context │ ├── .eslintrc.js │ ├── .gitignore │ ├── package.json │ ├── src │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── main.ts │ │ └── my-dynamic.module.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 19-auth-jwt │ ├── .eslintrc.js │ ├── .gitignore │ ├── e2e │ │ ├── app │ │ │ └── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── nest-cli.json │ ├── nodemon-debug.json │ ├── nodemon.json │ ├── package.json │ ├── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.spec.ts │ │ ├── app.service.ts │ │ ├── auth │ │ │ ├── auth.controller.ts │ │ │ ├── auth.guard.ts │ │ │ ├── auth.module.ts │ │ │ ├── auth.service.ts │ │ │ ├── constants.ts │ │ │ └── decorators │ │ │ │ └── public.decorator.ts │ │ ├── main.ts │ │ └── users │ │ │ ├── users.module.ts │ │ │ ├── users.service.spec.ts │ │ │ └── users.service.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 20-cache │ ├── .eslintrc.js │ ├── .gitignore │ ├── jest.json │ ├── package.json │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── common │ │ │ └── http-cache.interceptor.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 21-serializer │ ├── .eslintrc.js │ ├── .gitignore │ ├── jest.json │ ├── package.json │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── entities │ │ │ ├── role.entity.ts │ │ │ └── user.entity.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 22-graphql-prisma │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── generate-typings.ts │ ├── nest-cli.json │ ├── package.json │ ├── prisma │ │ └── schema.prisma │ ├── src │ │ ├── app.module.ts │ │ ├── graphql.schema.ts │ │ ├── main.ts │ │ ├── posts │ │ │ ├── posts.module.ts │ │ │ ├── posts.resolvers.ts │ │ │ ├── posts.service.ts │ │ │ └── schema.graphql │ │ └── prisma │ │ │ ├── prisma.module.ts │ │ │ └── prisma.service.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 23-graphql-code-first │ ├── .eslintrc.js │ ├── .gitignore │ ├── nest-cli.json │ ├── package.json │ ├── schema.gql │ ├── src │ │ ├── app.module.ts │ │ ├── common │ │ │ ├── directives │ │ │ │ └── upper-case.directive.ts │ │ │ ├── plugins │ │ │ │ ├── complexity.plugin.ts │ │ │ │ └── logging.plugin.ts │ │ │ └── scalars │ │ │ │ └── date.scalar.ts │ │ ├── main.ts │ │ └── recipes │ │ │ ├── dto │ │ │ ├── new-recipe.input.ts │ │ │ └── recipes.args.ts │ │ │ ├── models │ │ │ └── recipe.model.ts │ │ │ ├── recipes.module.ts │ │ │ ├── recipes.resolver.ts │ │ │ └── recipes.service.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 24-serve-static │ ├── .eslintrc.js │ ├── .gitignore │ ├── client │ │ ├── index.html │ │ └── logo.svg │ ├── package.json │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 25-dynamic-modules │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── config │ │ └── development.env │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── config │ │ │ ├── config.module.ts │ │ │ ├── config.service.spec.ts │ │ │ ├── config.service.ts │ │ │ ├── constants.ts │ │ │ └── interfaces │ │ │ │ ├── config-options.interface.ts │ │ │ │ ├── envconfig.interface.ts │ │ │ │ └── index.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 26-queues │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── docker-compose.yml │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── audio │ │ │ ├── audio.controller.ts │ │ │ ├── audio.module.ts │ │ │ └── audio.processor.ts │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 27-scheduling │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── main.ts │ │ └── tasks │ │ │ ├── tasks.module.ts │ │ │ └── tasks.service.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 28-sse │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── jest.json │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── index.html │ │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 29-file-upload │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── e2e │ │ ├── app │ │ │ └── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── jest.json │ ├── package.json │ ├── src │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── main.ts │ │ └── sample.dto.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 30-event-emitter │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── main.ts │ │ └── orders │ │ │ ├── dto │ │ │ └── create-order.dto.ts │ │ │ ├── entities │ │ │ └── order.entity.ts │ │ │ ├── events │ │ │ └── order-created.event.ts │ │ │ ├── listeners │ │ │ └── order-created.listener.ts │ │ │ ├── orders.controller.ts │ │ │ ├── orders.module.ts │ │ │ └── orders.service.ts │ ├── test │ │ ├── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── tsconfig.build.json │ └── tsconfig.json ├── 31-graphql-federation-code-first │ ├── README.md │ ├── gateway │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── README.md │ │ ├── nest-cli.json │ │ ├── package.json │ │ ├── src │ │ │ ├── app.controller.spec.ts │ │ │ ├── app.controller.ts │ │ │ ├── app.module.ts │ │ │ ├── app.service.ts │ │ │ └── main.ts │ │ ├── tsconfig.build.json │ │ └── tsconfig.json │ ├── posts-application │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── README.md │ │ ├── nest-cli.json │ │ ├── package.json │ │ ├── src │ │ │ ├── app.controller.spec.ts │ │ │ ├── app.controller.ts │ │ │ ├── app.module.ts │ │ │ ├── app.service.ts │ │ │ ├── main.ts │ │ │ └── posts │ │ │ │ ├── models │ │ │ │ ├── post.model.ts │ │ │ │ └── user.model.ts │ │ │ │ ├── posts.module.ts │ │ │ │ ├── posts.resolver.spec.ts │ │ │ │ ├── posts.resolver.ts │ │ │ │ ├── posts.service.spec.ts │ │ │ │ ├── posts.service.ts │ │ │ │ ├── users.resolver.spec.ts │ │ │ │ └── users.resolver.ts │ │ ├── tsconfig.build.json │ │ └── tsconfig.json │ └── users-application │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── README.md │ │ ├── nest-cli.json │ │ ├── package.json │ │ ├── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── main.ts │ │ └── users │ │ │ ├── models │ │ │ └── user.model.ts │ │ │ ├── users.module.ts │ │ │ ├── users.resolver.spec.ts │ │ │ ├── users.resolver.ts │ │ │ ├── users.service.spec.ts │ │ │ └── users.service.ts │ │ ├── tsconfig.build.json │ │ └── tsconfig.json ├── 32-graphql-federation-schema-first │ ├── README.md │ ├── gateway │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── README.md │ │ ├── nest-cli.json │ │ ├── package.json │ │ ├── src │ │ │ ├── app.controller.spec.ts │ │ │ ├── app.controller.ts │ │ │ ├── app.module.ts │ │ │ ├── app.service.ts │ │ │ └── main.ts │ │ ├── tsconfig.build.json │ │ └── tsconfig.json │ ├── posts-application │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── README.md │ │ ├── nest-cli.json │ │ ├── package.json │ │ ├── src │ │ │ ├── app.controller.spec.ts │ │ │ ├── app.controller.ts │ │ │ ├── app.module.ts │ │ │ ├── app.service.ts │ │ │ ├── main.ts │ │ │ └── posts │ │ │ │ ├── models │ │ │ │ ├── post.model.ts │ │ │ │ └── user.model.ts │ │ │ │ ├── posts.graphql │ │ │ │ ├── posts.interfaces.ts │ │ │ │ ├── posts.module.ts │ │ │ │ ├── posts.resolver.spec.ts │ │ │ │ ├── posts.resolver.ts │ │ │ │ ├── posts.service.spec.ts │ │ │ │ ├── posts.service.ts │ │ │ │ ├── users.interfaces.ts │ │ │ │ ├── users.resolver.spec.ts │ │ │ │ └── users.resolver.ts │ │ ├── tsconfig.build.json │ │ └── tsconfig.json │ └── users-application │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── README.md │ │ ├── nest-cli.json │ │ ├── package.json │ │ ├── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── main.ts │ │ └── users │ │ │ ├── models │ │ │ └── user.model.ts │ │ │ ├── users.graphql │ │ │ ├── users.module.ts │ │ │ ├── users.resolver.spec.ts │ │ │ ├── users.resolver.ts │ │ │ ├── users.service.spec.ts │ │ │ └── users.service.ts │ │ ├── tsconfig.build.json │ │ └── tsconfig.json ├── 33-graphql-mercurius │ ├── .eslintrc.js │ ├── .gitignore │ ├── nest-cli.json │ ├── package.json │ ├── schema.gql │ ├── src │ │ ├── app.module.ts │ │ ├── common │ │ │ └── scalars │ │ │ │ └── date.scalar.ts │ │ ├── main.ts │ │ └── recipes │ │ │ ├── dto │ │ │ ├── new-recipe.input.ts │ │ │ └── recipes.args.ts │ │ │ ├── models │ │ │ └── recipe.model.ts │ │ │ ├── recipes.module.ts │ │ │ ├── recipes.resolver.ts │ │ │ └── recipes.service.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── 34-using-esm-packages │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── nest-cli.json │ ├── package.json │ ├── src │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.ts │ │ ├── import-esm-package.ts │ │ ├── main.ts │ │ └── superjson.provider.ts │ ├── test │ │ ├── app.e2e-spec.ts │ │ └── jest-e2e.json │ ├── tsconfig.build.json │ └── tsconfig.json └── 35-use-esm-package-after-node22 │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── nest-cli.json │ ├── package.json │ ├── src │ ├── app.controller.ts │ ├── app.module.ts │ ├── app.service.ts │ └── main.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── scripts ├── prepare.sh ├── run-integration.sh ├── test.sh └── update-samples.sh ├── tools ├── benchmarks │ ├── check-benchmarks.ts │ ├── get-benchmarks.ts │ └── report-contents.md └── gulp │ ├── config.ts │ ├── gulpfile.ts │ ├── tasks │ ├── clean.ts │ ├── copy-misc.ts │ ├── move.ts │ └── samples.ts │ ├── tsconfig.json │ └── util │ └── task-helpers.ts ├── tsconfig.json └── tsconfig.spec.json /.eslintignore: -------------------------------------------------------------------------------- 1 | **/node_modules/** 2 | *.d.ts 3 | *.js -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | package-lock.json -diff -merge 2 | package-lock.json linguist-generated=true 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [kamilmysliwiec] 4 | open_collective: nest 5 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | - package-ecosystem: "github-actions" 9 | directory: "/" 10 | schedule: 11 | interval: daily 12 | open-pull-requests-limit: 10 13 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | npx --no-install commitlint --edit $1 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npx lint-staged 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # source 2 | **/*.ts 3 | *.ts 4 | 5 | # definitions 6 | !**/*.d.ts 7 | !*.d.ts 8 | 9 | # configuration 10 | package-lock.json 11 | tslint.json 12 | tsconfig.json 13 | .prettierrc 14 | 15 | *.tsbuildinfo -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | packages/**/*.d.ts 2 | packages/**/*.js 3 | .nyc_output 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "arrowParens": "avoid", 4 | "trailingComma": "all" 5 | } 6 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report security issues to `support@nestjs.com`. 6 | -------------------------------------------------------------------------------- /benchmarks/express.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const express = require('express'); 4 | const app = express(); 5 | 6 | app.get('/', async (req, res) => res.send('Hello world')); 7 | app.listen(3000); 8 | -------------------------------------------------------------------------------- /benchmarks/fastify.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fastify = require('fastify')(); 4 | fastify.get('/', async (req, reply) => reply.send('Hello world')); 5 | fastify.listen({ 6 | port: 3000 7 | }); 8 | -------------------------------------------------------------------------------- /benchmarks/nest.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, '__esModule', { value: true }); 3 | const core_1 = require('@nestjs/core'); 4 | const app_module_1 = require('./nest/app.module'); 5 | core_1.NestFactory.create(app_module_1.AppModule, { 6 | logger: false, 7 | bodyParser: false, 8 | }).then(app => app.listen(3000)); 9 | //# sourceMappingURL=main.js.map 10 | -------------------------------------------------------------------------------- /benchmarks/nest/app.controller.d.ts: -------------------------------------------------------------------------------- 1 | export declare class AppController { 2 | root(): string; 3 | } 4 | -------------------------------------------------------------------------------- /benchmarks/nest/app.controller.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAAiD;AAGjD,IAAa,aAAa,GAA1B,MAAa,aAAa;IAExB,IAAI;QACF,OAAO,cAAc,CAAA;IACvB,CAAC;CACF,CAAA;AAHC;IADC,YAAG,EAAE;;;;yCAGL;AAJU,aAAa;IADzB,mBAAU,EAAE;GACA,aAAa,CAKzB;AALY,sCAAa"} -------------------------------------------------------------------------------- /benchmarks/nest/app.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class AppModule {} 2 | -------------------------------------------------------------------------------- /benchmarks/nest/app.module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AAMjD,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IAJrB,eAAM,CAAC;QACN,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAC,8BAAa,CAAC;KAC7B,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"} -------------------------------------------------------------------------------- /benchmarks/nest/main.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /benchmarks/nest/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"} -------------------------------------------------------------------------------- /hooks/mocha-init-hook.ts: -------------------------------------------------------------------------------- 1 | export const mochaHooks = (): Mocha.RootHookObject => { 2 | return { 3 | async beforeAll(this: Mocha.Context) { 4 | await import('reflect-metadata'); 5 | }, 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /integration/auto-mock/src/bar.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { FooService } from './foo.service'; 3 | 4 | @Injectable() 5 | export class BarService { 6 | constructor(private readonly foo: FooService) {} 7 | 8 | bar() { 9 | this.foo.foo(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /integration/auto-mock/src/foo.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class FooService { 5 | foo() { 6 | console.log('foo called'); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/cors/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller() 4 | export class AppController { 5 | @Get() 6 | getGlobals() { 7 | return ''; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration/cors/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | 4 | @Module({ 5 | controllers: [AppController], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /integration/discovery/src/decorators/webhook.decorators.ts: -------------------------------------------------------------------------------- 1 | import { DiscoveryService } from '@nestjs/core'; 2 | 3 | export const Webhook = DiscoveryService.createDecorator<{ name: string }>(); 4 | export const WebhookHandler = DiscoveryService.createDecorator<{ 5 | event: string; 6 | }>(); 7 | -------------------------------------------------------------------------------- /integration/discovery/src/my-webhook/cleanup.webhook.ts: -------------------------------------------------------------------------------- 1 | import { Webhook, WebhookHandler } from '../decorators/webhook.decorators'; 2 | 3 | @Webhook({ name: 'cleanup' }) 4 | export class CleanupWebhook { 5 | @WebhookHandler({ event: 'start' }) 6 | onStart() { 7 | console.log('cleanup started'); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration/discovery/src/my-webhook/flush.webhook.ts: -------------------------------------------------------------------------------- 1 | import { Webhook, WebhookHandler } from '../decorators/webhook.decorators'; 2 | 3 | @Webhook({ name: 'flush' }) 4 | export class FlushWebhook { 5 | @WebhookHandler({ event: 'start' }) 6 | onStart() { 7 | console.log('flush started'); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration/discovery/src/my-webhook/my-webhook.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CleanupWebhook } from './cleanup.webhook'; 3 | import { FlushWebhook } from './flush.webhook'; 4 | 5 | @Module({ providers: [CleanupWebhook, FlushWebhook] }) 6 | export class MyWebhookModule {} 7 | -------------------------------------------------------------------------------- /integration/graphql-code-first/src/recipes/dto/recipes.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | import { Max, Min } from 'class-validator'; 3 | 4 | @ArgsType() 5 | export class RecipesArgs { 6 | @Field(type => Int) 7 | @Min(0) 8 | skip = 0; 9 | 10 | @Field(type => Int) 11 | @Min(1) 12 | @Max(50) 13 | take = 25; 14 | } 15 | -------------------------------------------------------------------------------- /integration/graphql-schema-first/src/cats/cats.types.graphql: -------------------------------------------------------------------------------- 1 | type Query { 2 | getCats: [Cat] 3 | cat(id: ID!): Cat 4 | } 5 | 6 | type Mutation { 7 | createCat(name: String): Cat 8 | } 9 | 10 | type Subscription { 11 | catCreated: Cat 12 | } 13 | 14 | type Cat { 15 | id: Int 16 | name: String 17 | age: Int 18 | } 19 | -------------------------------------------------------------------------------- /integration/graphql-schema-first/src/cats/interfaces/cat.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Cat { 2 | readonly id: number; 3 | readonly name: string; 4 | readonly age: number; 5 | } 6 | -------------------------------------------------------------------------------- /integration/graphql-schema-first/src/config.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ConfigService } from './config.service'; 3 | 4 | @Module({ 5 | providers: [ConfigService], 6 | exports: [ConfigService], 7 | }) 8 | export class ConfigModule {} 9 | -------------------------------------------------------------------------------- /integration/graphql-schema-first/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /integration/hello-world/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { HelloModule } from './hello/hello.module'; 3 | import { HostArrayModule } from './host-array/host-array.module'; 4 | import { HostModule } from './host/host.module'; 5 | 6 | @Module({ 7 | imports: [HelloModule, HostModule, HostArrayModule], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /integration/hello-world/src/hello/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/hello-world/src/hello/hello.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class HelloService { 5 | greeting(): string { 6 | return 'Hello world!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/hello-world/src/hello/users/users.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class UsersService { 5 | findById(id: string) { 6 | return { id }; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/hello-world/src/host-array/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/hello-world/src/host-array/host-array.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class HostArrayService { 5 | greeting(): string { 6 | return 'Host Greeting!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/hello-world/src/host-array/users/users.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class UsersService { 5 | findById(id: string) { 6 | return { id, host: true }; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/hello-world/src/host/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/hello-world/src/host/host.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class HostService { 5 | greeting(): string { 6 | return 'Host Greeting!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/hello-world/src/host/users/users.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class UsersService { 5 | findById(id: string) { 6 | return { id, host: true }; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/injector/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ExportsModule } from './exports/exports.module'; 3 | 4 | @Module({ 5 | imports: [ExportsModule], 6 | }) 7 | export class ApplicationModule {} 8 | -------------------------------------------------------------------------------- /integration/injector/src/circular-modules/circular.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, forwardRef, Inject } from '@nestjs/common'; 2 | import { InputService } from './input.service'; 3 | 4 | @Injectable() 5 | export class CircularService { 6 | constructor( 7 | @Inject(forwardRef(() => InputService)) 8 | public readonly service: InputService, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /integration/injector/src/circular-modules/input.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Inject, forwardRef } from '@nestjs/common'; 2 | import { CircularService } from './circular.service'; 3 | 4 | @Injectable() 5 | export class InputService { 6 | constructor( 7 | @Inject(forwardRef(() => CircularService)) 8 | public readonly service: CircularService, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /integration/injector/src/circular-properties/circular.service.ts: -------------------------------------------------------------------------------- 1 | import { forwardRef, Inject, Injectable } from '@nestjs/common'; 2 | import { InputService } from './input.service'; 3 | 4 | @Injectable() 5 | export class CircularService { 6 | @Inject(forwardRef(() => InputService)) 7 | public readonly service: InputService; 8 | } 9 | -------------------------------------------------------------------------------- /integration/injector/src/circular-properties/input.service.ts: -------------------------------------------------------------------------------- 1 | import { forwardRef, Inject, Injectable } from '@nestjs/common'; 2 | import { CircularService } from './circular.service'; 3 | 4 | @Injectable() 5 | export class InputService { 6 | @Inject(forwardRef(() => CircularService)) 7 | public readonly service: CircularService; 8 | } 9 | -------------------------------------------------------------------------------- /integration/injector/src/circular-structure-dynamic-module/input.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class InputService {} 5 | -------------------------------------------------------------------------------- /integration/injector/src/circular/circular.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CircularService } from './circular.service'; 3 | import { InputService } from './input.service'; 4 | 5 | @Module({ 6 | providers: [CircularService, InputService], 7 | }) 8 | export class CircularModule {} 9 | -------------------------------------------------------------------------------- /integration/injector/src/circular/circular.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, forwardRef, Inject } from '@nestjs/common'; 2 | import { InputService } from './input.service'; 3 | 4 | @Injectable() 5 | export class CircularService { 6 | constructor( 7 | @Inject(forwardRef(() => InputService)) 8 | public readonly service: InputService, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /integration/injector/src/circular/input.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Inject, forwardRef } from '@nestjs/common'; 2 | import { CircularService } from './circular.service'; 3 | 4 | @Injectable() 5 | export class InputService { 6 | constructor( 7 | @Inject(forwardRef(() => CircularService)) 8 | public readonly service: CircularService, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /integration/injector/src/core-injectables/core-injectables.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | 3 | @Module({}) 4 | export class CoreInjectablesModule {} 5 | -------------------------------------------------------------------------------- /integration/injector/src/defaults/core.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class CoreService {} 5 | -------------------------------------------------------------------------------- /integration/injector/src/defaults/defaults.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { DefaultsService } from './defaults.service'; 3 | 4 | @Module({ 5 | providers: [DefaultsService], 6 | }) 7 | export class DefaultsModule {} 8 | -------------------------------------------------------------------------------- /integration/injector/src/defaults/defaults.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Optional } from '@nestjs/common'; 2 | import { CoreService } from './core.service'; 3 | 4 | @Injectable() 5 | export class DefaultsService { 6 | constructor( 7 | @Inject(CoreService) 8 | @Optional() 9 | public readonly coreService = { default: true }, 10 | ) {} 11 | } 12 | -------------------------------------------------------------------------------- /integration/injector/src/exports/exports.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ExportsService } from './exports.service'; 3 | 4 | @Module({ 5 | exports: [ExportsService], 6 | }) 7 | export class ExportsModule {} 8 | -------------------------------------------------------------------------------- /integration/injector/src/exports/exports.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class ExportsService {} 5 | -------------------------------------------------------------------------------- /integration/injector/src/inject/core.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class CoreService {} 5 | -------------------------------------------------------------------------------- /integration/injector/src/inject/inject.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { InjectService } from './inject.service'; 3 | 4 | @Module({ 5 | providers: [InjectService], 6 | }) 7 | export class InjectModule {} 8 | -------------------------------------------------------------------------------- /integration/injector/src/inject/inject.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { CoreService } from './core.service'; 3 | 4 | @Injectable() 5 | export class InjectService { 6 | constructor(private readonly coreService: CoreService) {} 7 | } 8 | -------------------------------------------------------------------------------- /integration/injector/src/multiple-providers/multiple-providers.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AModule } from './a.module'; 3 | import { BModule } from './b.module'; 4 | import { CModule } from './c.module'; 5 | 6 | @Module({ 7 | imports: [AModule, BModule, CModule], 8 | }) 9 | export class MultipleProvidersModule {} 10 | -------------------------------------------------------------------------------- /integration/injector/src/properties/dependency.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class DependencyService {} 5 | -------------------------------------------------------------------------------- /integration/injector/src/scoped/scoped.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Scope } from '@nestjs/common'; 2 | 3 | @Controller({ 4 | path: 'test', 5 | scope: Scope.REQUEST, 6 | }) 7 | export class ScopedController {} 8 | -------------------------------------------------------------------------------- /integration/injector/src/scoped/scoped.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Scope } from '@nestjs/common'; 2 | import { REQUEST } from '@nestjs/core'; 3 | 4 | @Injectable({ scope: Scope.REQUEST }) 5 | export class ScopedService { 6 | constructor(@Inject(REQUEST) public readonly request) {} 7 | } 8 | -------------------------------------------------------------------------------- /integration/injector/src/scoped/transient.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Scope } from '@nestjs/common'; 2 | import { Transient2Service } from './transient2.service'; 3 | 4 | @Injectable({ scope: Scope.TRANSIENT }) 5 | export class TransientService { 6 | constructor(public readonly svc: Transient2Service) {} 7 | } 8 | -------------------------------------------------------------------------------- /integration/injector/src/scoped/transient2.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Logger, Scope } from '@nestjs/common'; 2 | 3 | @Injectable({ scope: Scope.TRANSIENT }) 4 | export class Transient2Service { 5 | logger = new Logger(); 6 | } 7 | -------------------------------------------------------------------------------- /integration/injector/src/scoped/transient3.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Scope } from '@nestjs/common'; 2 | import { TransientService } from './transient.service'; 3 | 4 | @Injectable({ scope: Scope.TRANSIENT }) 5 | export class Transient3Service { 6 | constructor(public readonly svc: TransientService) {} 7 | } 8 | -------------------------------------------------------------------------------- /integration/inspector/src/app-v1.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller({ 4 | version: '1', 5 | }) 6 | export class AppV1Controller { 7 | @Get('/') 8 | helloWorldV1() { 9 | return 'Hello World V1!'; 10 | } 11 | 12 | @Get('/:param/hello') 13 | paramV1() { 14 | return 'Parameter V1!'; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /integration/inspector/src/cats/cats.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsController } from './cats.controller'; 3 | import { CatsService } from './cats.service'; 4 | 5 | @Module({ 6 | controllers: [CatsController], 7 | providers: [CatsService], 8 | }) 9 | export class CatsModule {} 10 | -------------------------------------------------------------------------------- /integration/inspector/src/cats/dto/create-cat.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsInt, IsString } from 'class-validator'; 2 | 3 | export class CreateCatDto { 4 | @IsString() 5 | readonly name: string; 6 | 7 | @IsInt() 8 | readonly age: number; 9 | 10 | @IsString() 11 | readonly breed: string; 12 | } 13 | -------------------------------------------------------------------------------- /integration/inspector/src/cats/interfaces/cat.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Cat { 2 | name: string; 3 | age: number; 4 | breed: string; 5 | } 6 | -------------------------------------------------------------------------------- /integration/inspector/src/chat/chat.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ChatService } from './chat.service'; 3 | import { ChatGateway } from './chat.gateway'; 4 | 5 | @Module({ 6 | providers: [ChatGateway, ChatService], 7 | }) 8 | export class ChatModule {} 9 | -------------------------------------------------------------------------------- /integration/inspector/src/chat/dto/create-chat.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateChatDto {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/chat/dto/update-chat.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateChatDto } from './create-chat.dto'; 3 | 4 | export class UpdateChatDto extends PartialType(CreateChatDto) { 5 | id: number; 6 | } 7 | -------------------------------------------------------------------------------- /integration/inspector/src/chat/entities/chat.entity.ts: -------------------------------------------------------------------------------- 1 | export class Chat {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/circular-hello/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/inspector/src/circular-modules/circular.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, forwardRef, Inject } from '@nestjs/common'; 2 | import { InputService } from './input.service'; 3 | 4 | @Injectable() 5 | export class CircularService { 6 | constructor( 7 | @Inject(forwardRef(() => InputService)) 8 | public readonly service: InputService, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /integration/inspector/src/circular-modules/input.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Inject, forwardRef } from '@nestjs/common'; 2 | import { CircularService } from './circular.service'; 3 | 4 | @Injectable() 5 | export class InputService { 6 | constructor( 7 | @Inject(forwardRef(() => CircularService)) 8 | public readonly service: CircularService, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /integration/inspector/src/common/middleware/logger.middleware.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, NestMiddleware } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class LoggerMiddleware implements NestMiddleware { 5 | use(req: any, res: any, next: () => void) { 6 | console.log(`Request...`); 7 | next(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration/inspector/src/database/database.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { DatabaseService } from './database.service'; 3 | import { DatabaseController } from './database.controller'; 4 | 5 | @Module({ 6 | controllers: [DatabaseController], 7 | providers: [DatabaseService], 8 | }) 9 | export class DatabaseModule {} 10 | -------------------------------------------------------------------------------- /integration/inspector/src/database/dto/create-database.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateDatabaseDto {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/database/dto/update-database.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateDatabaseDto } from './create-database.dto'; 3 | 4 | export class UpdateDatabaseDto extends PartialType(CreateDatabaseDto) {} 5 | -------------------------------------------------------------------------------- /integration/inspector/src/database/entities/database.entity.ts: -------------------------------------------------------------------------------- 1 | export class Database {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/defaults/core.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class CoreService {} 5 | -------------------------------------------------------------------------------- /integration/inspector/src/defaults/defaults.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { DefaultsService } from './defaults.service'; 3 | 4 | @Module({ 5 | providers: [DefaultsService], 6 | }) 7 | export class DefaultsModule {} 8 | -------------------------------------------------------------------------------- /integration/inspector/src/defaults/defaults.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Optional } from '@nestjs/common'; 2 | import { CoreService } from './core.service'; 3 | 4 | @Injectable() 5 | export class DefaultsService { 6 | constructor( 7 | @Inject(CoreService) 8 | @Optional() 9 | public readonly coreService = { default: true }, 10 | ) {} 11 | } 12 | -------------------------------------------------------------------------------- /integration/inspector/src/dogs/dogs.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { DogsService } from './dogs.service'; 3 | import { DogsController } from './dogs.controller'; 4 | 5 | @Module({ 6 | controllers: [DogsController], 7 | providers: [DogsService], 8 | }) 9 | export class DogsModule {} 10 | -------------------------------------------------------------------------------- /integration/inspector/src/dogs/dto/create-dog.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateDogDto {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/dogs/dto/update-dog.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateDogDto } from './create-dog.dto'; 3 | 4 | export class UpdateDogDto extends PartialType(CreateDogDto) {} 5 | -------------------------------------------------------------------------------- /integration/inspector/src/dogs/entities/dog.entity.ts: -------------------------------------------------------------------------------- 1 | export class Dog {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/durable/durable.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { DurableController } from './durable.controller'; 3 | import { DurableService } from './durable.service'; 4 | 5 | @Module({ 6 | controllers: [DurableController], 7 | providers: [DurableService], 8 | }) 9 | export class DurableModule {} 10 | -------------------------------------------------------------------------------- /integration/inspector/src/external-svc/dto/create-external-svc.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateExternalSvcDto {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/external-svc/dto/update-external-svc.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateExternalSvcDto } from './create-external-svc.dto'; 3 | 4 | export class UpdateExternalSvcDto extends PartialType(CreateExternalSvcDto) { 5 | id: number; 6 | } 7 | -------------------------------------------------------------------------------- /integration/inspector/src/external-svc/entities/external-svc.entity.ts: -------------------------------------------------------------------------------- 1 | export class ExternalSvc {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/properties/dependency.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class DependencyService {} 5 | -------------------------------------------------------------------------------- /integration/inspector/src/request-chain/helper/helper.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { HelperService } from './helper.service'; 3 | 4 | @Module({ 5 | providers: [HelperService], 6 | exports: [HelperService], 7 | }) 8 | export class HelperModule {} 9 | -------------------------------------------------------------------------------- /integration/inspector/src/request-chain/helper/helper.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Scope } from '@nestjs/common'; 2 | import { REQUEST } from '@nestjs/core'; 3 | 4 | @Injectable({ scope: Scope.REQUEST }) 5 | export class HelperService { 6 | constructor(@Inject(REQUEST) public readonly request) {} 7 | 8 | public noop() {} 9 | } 10 | -------------------------------------------------------------------------------- /integration/inspector/src/users/dto/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateUserDto {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/users/dto/update-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateUserDto } from './create-user.dto'; 3 | 4 | export class UpdateUserDto extends PartialType(CreateUserDto) {} 5 | -------------------------------------------------------------------------------- /integration/inspector/src/users/entities/user.entity.ts: -------------------------------------------------------------------------------- 1 | export class User {} 2 | -------------------------------------------------------------------------------- /integration/inspector/src/users/users.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UsersService } from './users.service'; 3 | import { UsersController } from './users.controller'; 4 | 5 | @Module({ 6 | controllers: [UsersController], 7 | providers: [UsersService], 8 | }) 9 | export class UsersModule {} 10 | -------------------------------------------------------------------------------- /integration/lazy-modules/src/global.module.ts: -------------------------------------------------------------------------------- 1 | import { Module, Injectable, Global } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class GlobalService { 5 | constructor() {} 6 | } 7 | 8 | @Global() 9 | @Module({ 10 | providers: [GlobalService], 11 | exports: [GlobalService], 12 | }) 13 | export class GlobalModule {} 14 | -------------------------------------------------------------------------------- /integration/lazy-modules/src/lazy.module.ts: -------------------------------------------------------------------------------- 1 | import { Module, Injectable } from '@nestjs/common'; 2 | import { GlobalService } from './global.module'; 3 | 4 | @Injectable() 5 | export class LazyService { 6 | constructor(public globalService: GlobalService) {} 7 | } 8 | 9 | @Module({ 10 | providers: [LazyService], 11 | }) 12 | export class LazyModule {} 13 | -------------------------------------------------------------------------------- /integration/lazy-modules/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /integration/lazy-modules/src/transient.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Scope } from '@nestjs/common'; 2 | import { EagerService } from './eager.module'; 3 | 4 | @Injectable({ scope: Scope.TRANSIENT }) 5 | export class TransientService { 6 | constructor(private eagerService: EagerService) {} 7 | 8 | eager() { 9 | return this.eagerService.sayHello(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /integration/microservices/src/grpc-advanced/proto/common/item_types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package proto_example.common.items; 3 | 4 | enum ItemType { 5 | DEFAULT = 0; 6 | SUPERIOR = 1; 7 | FLAWLESS = 2; 8 | } -------------------------------------------------------------------------------- /integration/microservices/src/grpc-advanced/proto/common/shipment_types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package proto_example.common.shipments; 3 | 4 | message ShipmentType { 5 | string from = 1; 6 | string to = 2; 7 | string carrier = 3; 8 | } -------------------------------------------------------------------------------- /integration/microservices/src/grpc-advanced/proto/root.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package proto_example; 3 | import public "orders/service.proto"; 4 | -------------------------------------------------------------------------------- /integration/microservices/src/grpc/math2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package math2; 4 | 5 | service Math2 { 6 | rpc Sum2 (RequestSum) returns (SumResult) {} 7 | } 8 | 9 | message SumResult { 10 | int32 result = 1; 11 | } 12 | 13 | message RequestSum { 14 | repeated int32 data = 1; 15 | } 16 | -------------------------------------------------------------------------------- /integration/microservices/src/kafka-concurrent/dto/sum.dto.ts: -------------------------------------------------------------------------------- 1 | export class SumDto { 2 | key: string; 3 | numbers: number[]; 4 | } 5 | -------------------------------------------------------------------------------- /integration/microservices/src/kafka/dtos/business.dto.ts: -------------------------------------------------------------------------------- 1 | import { UserEntity } from '../entities/user.entity'; 2 | 3 | export class BusinessDto { 4 | name: string; 5 | phone: string; 6 | user: UserEntity; 7 | } 8 | -------------------------------------------------------------------------------- /integration/microservices/src/kafka/dtos/user.dto.ts: -------------------------------------------------------------------------------- 1 | export class UserDto { 2 | name: string; 3 | email: string; 4 | phone: string; 5 | years: number; 6 | } 7 | -------------------------------------------------------------------------------- /integration/microservices/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { ApplicationModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(ApplicationModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /integration/microservices/src/nats/nats.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable } from '@nestjs/common'; 2 | import { CONTEXT } from '@nestjs/microservices'; 3 | 4 | @Injectable() 5 | export class NatsService { 6 | constructor(@Inject(CONTEXT) public ctx) {} 7 | } 8 | -------------------------------------------------------------------------------- /integration/module-utils/src/interfaces/integration-module-options.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IntegrationModuleOptions { 2 | url: string; 3 | secure?: boolean; 4 | } 5 | -------------------------------------------------------------------------------- /integration/mongoose/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { MongooseModule } from '@nestjs/mongoose'; 3 | import { CatsModule } from './cats/cats.module'; 4 | 5 | @Module({ 6 | imports: [ 7 | MongooseModule.forRoot('mongodb://localhost:27017/test'), 8 | CatsModule, 9 | ], 10 | }) 11 | export class ApplicationModule {} 12 | -------------------------------------------------------------------------------- /integration/mongoose/src/cats/dto/create-cat.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateCatDto { 2 | readonly name: string; 3 | readonly age: number; 4 | readonly breed: string; 5 | } 6 | -------------------------------------------------------------------------------- /integration/mongoose/src/cats/interfaces/cat.interface.ts: -------------------------------------------------------------------------------- 1 | import { Document } from 'mongoose'; 2 | 3 | export interface Cat extends Document { 4 | readonly name: string; 5 | readonly age: number; 6 | readonly breed: string; 7 | } 8 | -------------------------------------------------------------------------------- /integration/mongoose/src/cats/schemas/cat.schema.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from 'mongoose'; 2 | 3 | export const CatSchema = new mongoose.Schema({ 4 | name: String, 5 | age: Number, 6 | breed: String, 7 | }); 8 | -------------------------------------------------------------------------------- /integration/mongoose/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { ApplicationModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(ApplicationModule); 6 | await app.listen(3001); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /integration/nest-application/app-locals/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Req } from '@nestjs/common'; 2 | import { Request } from 'express'; 3 | 4 | @Controller() 5 | export class AppController { 6 | @Get() 7 | getGlobals(@Req() req: Request) { 8 | return req.app.locals; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /integration/nest-application/app-locals/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | 4 | @Module({ 5 | controllers: [AppController], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /integration/nest-application/get-url/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | @Module({ 6 | controllers: [AppController], 7 | providers: [AppService], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /integration/nest-application/get-url/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | sayHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/nest-application/listen/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | @Module({ 6 | controllers: [AppController], 7 | providers: [AppService], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /integration/nest-application/listen/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | sayHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/nest-application/raw-body/src/express.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ExpressController } from './express.controller'; 3 | 4 | @Module({ 5 | controllers: [ExpressController], 6 | }) 7 | export class ExpressModule {} 8 | -------------------------------------------------------------------------------- /integration/nest-application/raw-body/src/fastify.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { FastifyController } from './fastify.controller'; 3 | 4 | @Module({ 5 | controllers: [FastifyController], 6 | }) 7 | export class FastifyModule {} 8 | -------------------------------------------------------------------------------- /integration/nest-application/sse/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | 4 | @Module({ 5 | controllers: [AppController], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /integration/nest-application/use-body-parser/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | 4 | @Module({ 5 | controllers: [AppController], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /integration/repl/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UsersModule } from './users/users.module'; 3 | 4 | @Module({ 5 | imports: [UsersModule], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /integration/repl/src/users/dto/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateUserDto {} 2 | -------------------------------------------------------------------------------- /integration/repl/src/users/dto/update-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateUserDto } from './create-user.dto'; 3 | 4 | export class UpdateUserDto extends PartialType(CreateUserDto) {} 5 | -------------------------------------------------------------------------------- /integration/repl/src/users/entities/user.entity.ts: -------------------------------------------------------------------------------- 1 | export class User {} 2 | -------------------------------------------------------------------------------- /integration/repl/src/users/users.repository.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class UsersRepository { 5 | async find() { 6 | return [{ id: 1, email: 'test@nestjs.com' }]; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration/scopes/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { HelloModule } from './hello/hello.module'; 3 | 4 | @Module({ 5 | imports: [HelloModule.forRoot({ provide: 'META', useValue: true })], 6 | }) 7 | export class ApplicationModule {} 8 | -------------------------------------------------------------------------------- /integration/scopes/src/circular-hello/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/scopes/src/circular-transient/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/scopes/src/hello/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/scopes/src/hello/hello.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Scope } from '@nestjs/common'; 2 | 3 | @Injectable({ scope: Scope.REQUEST }) 4 | export class HelloService { 5 | constructor(@Inject('META') private readonly meta) {} 6 | 7 | greeting(): string { 8 | return 'Hello world!'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /integration/scopes/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { ApplicationModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(ApplicationModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /integration/scopes/src/msvc/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/scopes/src/msvc/hello.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Scope } from '@nestjs/common'; 2 | 3 | @Injectable({ scope: Scope.REQUEST }) 4 | export class HelloService { 5 | constructor(@Inject('META') private readonly meta) {} 6 | 7 | greeting(): string { 8 | return 'Hello world!'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /integration/scopes/src/request-chain/helper/helper.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { HelperService } from './helper.service'; 3 | 4 | @Module({ 5 | providers: [HelperService], 6 | exports: [HelperService], 7 | }) 8 | export class HelperModule {} 9 | -------------------------------------------------------------------------------- /integration/scopes/src/request-chain/helper/helper.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Scope } from '@nestjs/common'; 2 | import { REQUEST } from '@nestjs/core'; 3 | 4 | @Injectable({ scope: Scope.REQUEST }) 5 | export class HelperService { 6 | constructor(@Inject(REQUEST) public readonly request) {} 7 | 8 | public noop() {} 9 | } 10 | -------------------------------------------------------------------------------- /integration/scopes/src/resolve-scoped/logger.provider.ts: -------------------------------------------------------------------------------- 1 | import { FactoryProvider } from '@nestjs/common'; 2 | 3 | export const LOGGER_PROVIDER = 'LOGGER_PROVIDER'; 4 | export const loggerProvider: FactoryProvider = { 5 | provide: LOGGER_PROVIDER, 6 | useFactory: () => { 7 | return { logger: true }; 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /integration/scopes/src/resolve-scoped/logger.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Scope } from '@nestjs/common'; 2 | import { LOGGER_PROVIDER } from './logger.provider'; 3 | 4 | @Injectable({ scope: Scope.TRANSIENT }) 5 | export class LoggerService { 6 | constructor(@Inject(LOGGER_PROVIDER) public logger) {} 7 | } 8 | -------------------------------------------------------------------------------- /integration/scopes/src/resolve-scoped/request-logger.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Scope } from '@nestjs/common'; 2 | import { LoggerService } from './logger.service'; 3 | 4 | @Injectable({ scope: Scope.REQUEST }) 5 | export class RequestLoggerService { 6 | constructor(public loggerService: LoggerService) {} 7 | } 8 | -------------------------------------------------------------------------------- /integration/scopes/src/transient/dto/test.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 2 | 3 | export class TestDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | string: string; 7 | 8 | @IsNumber() 9 | number: number; 10 | } 11 | -------------------------------------------------------------------------------- /integration/scopes/src/transient/hello.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, Scope } from '@nestjs/common'; 2 | 3 | @Injectable({ scope: Scope.REQUEST }) 4 | export class HelloService { 5 | constructor(@Inject('META') private readonly meta) {} 6 | 7 | greeting(): string { 8 | return 'Hello world!'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /integration/send-files/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | @Module({ 6 | controllers: [AppController], 7 | providers: [AppService], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /integration/send-files/src/non-file.ts: -------------------------------------------------------------------------------- 1 | export class NonFile { 2 | constructor(private readonly value: string) {} 3 | 4 | pipe() { 5 | return this.value; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /integration/typeorm/ormconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "mysql", 3 | "host": "127.0.0.1", 4 | "port": 3306, 5 | "username": "root", 6 | "password": "root", 7 | "database": "test", 8 | "entities": ["src/**/**.entity{.ts,.js}"], 9 | "synchronize": true 10 | } 11 | -------------------------------------------------------------------------------- /integration/typeorm/src/app-async.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { DatabaseModule } from './database.module'; 3 | import { PhotoModule } from './photo/photo.module'; 4 | 5 | @Module({ 6 | imports: [DatabaseModule.forRoot(), PhotoModule], 7 | }) 8 | export class AsyncApplicationModule {} 9 | -------------------------------------------------------------------------------- /integration/typeorm/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3001); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /integration/versioning/src/app-v1.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller({ 4 | version: '1', 5 | }) 6 | export class AppV1Controller { 7 | @Get('/') 8 | helloWorldV1() { 9 | return 'Hello World V1!'; 10 | } 11 | 12 | @Get('/:param/hello') 13 | paramV1() { 14 | return 'Parameter V1!'; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /integration/versioning/src/app-v2.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller({ 4 | version: '2', 5 | }) 6 | export class AppV2Controller { 7 | @Get('/') 8 | helloWorldV2() { 9 | return 'Hello World V2!'; 10 | } 11 | 12 | @Get('/:param/hello') 13 | paramV1() { 14 | return 'Parameter V2!'; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /integration/versioning/src/multiple-middleware.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller({ 4 | version: ['1', '2'], 5 | path: 'middleware', 6 | }) 7 | export class MultipleMiddlewareVersionController { 8 | @Get('/multiple') 9 | multiple() { 10 | return 'Multiple Versions 1 or 2'; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /integration/versioning/src/multiple.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller({ 4 | version: ['1', '2'], 5 | }) 6 | export class MultipleVersionController { 7 | @Get('/multiple') 8 | multiple() { 9 | return 'Multiple Versions 1 or 2'; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /integration/versioning/src/neutral-middleware.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, VERSION_NEUTRAL } from '@nestjs/common'; 2 | 3 | @Controller({ 4 | path: 'middleware', 5 | version: VERSION_NEUTRAL, 6 | }) 7 | export class VersionNeutralMiddlewareController { 8 | @Get('/neutral') 9 | neutral() { 10 | return 'Neutral'; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /integration/versioning/src/neutral.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, VERSION_NEUTRAL } from '@nestjs/common'; 2 | 3 | @Controller({ 4 | version: VERSION_NEUTRAL, 5 | }) 6 | export class VersionNeutralController { 7 | @Get('/neutral') 8 | neutral() { 9 | return 'Neutral'; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /integration/versioning/src/no-versioning.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller('foo') 4 | export class NoVersioningController { 5 | @Get('/bar') 6 | helloFoo() { 7 | return 'Hello FooBar!'; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration/websockets/src/ack.gateway.ts: -------------------------------------------------------------------------------- 1 | import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; 2 | 3 | @WebSocketGateway(8080) 4 | export class AckGateway { 5 | @SubscribeMessage('push') 6 | onPush() { 7 | return 'pong'; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration/websockets/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ApplicationGateway } from './app.gateway'; 3 | 4 | @Module({ 5 | providers: [ApplicationGateway], 6 | }) 7 | export class ApplicationModule {} 8 | -------------------------------------------------------------------------------- /integration/websockets/src/example-path.gateway.ts: -------------------------------------------------------------------------------- 1 | import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; 2 | 3 | @WebSocketGateway({ 4 | path: '/example', 5 | }) 6 | export class ExamplePathGateway { 7 | @SubscribeMessage('push') 8 | onPush(client, data) { 9 | return { 10 | event: 'pop', 11 | data, 12 | }; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /integration/websockets/src/namespace.gateway.ts: -------------------------------------------------------------------------------- 1 | import { WebSocketGateway, SubscribeMessage } from '@nestjs/websockets'; 2 | 3 | @WebSocketGateway(8080, { 4 | namespace: 'test', 5 | }) 6 | export class NamespaceGateway { 7 | @SubscribeMessage('push') 8 | onPush(client, data) { 9 | return { 10 | event: 'pop', 11 | data, 12 | }; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /integration/websockets/src/ws-path.gateway.ts: -------------------------------------------------------------------------------- 1 | import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; 2 | 3 | @WebSocketGateway({ 4 | path: '/ws-path', 5 | }) 6 | export class WsPathGateway { 7 | @SubscribeMessage('push') 8 | onPush(client, data) { 9 | return { 10 | event: 'pop', 11 | data, 12 | }; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /integration/websockets/src/ws-path2.gateway.ts: -------------------------------------------------------------------------------- 1 | import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets'; 2 | 3 | @WebSocketGateway({ 4 | path: '/ws-path', 5 | }) 6 | export class WsPathGateway2 { 7 | @SubscribeMessage('push') 8 | onPush(client, data) { 9 | return { 10 | event: 'pop', 11 | data, 12 | }; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.4.0", 3 | "packages": [ 4 | "packages/*" 5 | ], 6 | "version": "10.4.13" 7 | } 8 | -------------------------------------------------------------------------------- /packages/common/PACKAGE.md: -------------------------------------------------------------------------------- 1 | The common package comes with decorators such as `@Controller()`, `@Injectable()` and so on. 2 | -------------------------------------------------------------------------------- /packages/common/decorators/index.ts: -------------------------------------------------------------------------------- 1 | export * from './core'; 2 | export * from './modules'; 3 | export * from './http'; 4 | -------------------------------------------------------------------------------- /packages/common/decorators/modules/index.ts: -------------------------------------------------------------------------------- 1 | export * from './global.decorator'; 2 | export * from './module.decorator'; 3 | -------------------------------------------------------------------------------- /packages/common/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './request-method.enum'; 2 | export * from './http-status.enum'; 3 | export * from './shutdown-signal.enum'; 4 | export * from './version-type.enum'; 5 | -------------------------------------------------------------------------------- /packages/common/enums/request-method.enum.ts: -------------------------------------------------------------------------------- 1 | export enum RequestMethod { 2 | GET = 0, 3 | POST, 4 | PUT, 5 | DELETE, 6 | PATCH, 7 | ALL, 8 | OPTIONS, 9 | HEAD, 10 | SEARCH, 11 | } 12 | -------------------------------------------------------------------------------- /packages/common/enums/route-paramtypes.enum.ts: -------------------------------------------------------------------------------- 1 | export enum RouteParamtypes { 2 | REQUEST = 0, 3 | RESPONSE = 1, 4 | NEXT = 2, 5 | BODY = 3, 6 | QUERY = 4, 7 | PARAM = 5, 8 | HEADERS = 6, 9 | SESSION = 7, 10 | FILE = 8, 11 | FILES = 9, 12 | HOST = 10, 13 | IP = 11, 14 | RAW_BODY = 12, 15 | } 16 | -------------------------------------------------------------------------------- /packages/common/enums/version-type.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export enum VersioningType { 5 | URI, 6 | HEADER, 7 | MEDIA_TYPE, 8 | CUSTOM, 9 | } 10 | -------------------------------------------------------------------------------- /packages/common/file-stream/index.ts: -------------------------------------------------------------------------------- 1 | export * from './streamable-file'; 2 | -------------------------------------------------------------------------------- /packages/common/file-stream/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './streamable-options.interface'; 2 | export * from './streamable-handler-response.interface'; 3 | -------------------------------------------------------------------------------- /packages/common/interfaces/abstract.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Abstract extends Function { 2 | prototype: T; 3 | } 4 | -------------------------------------------------------------------------------- /packages/common/interfaces/controllers/controller-metadata.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ControllerMetadata { 2 | path?: string; 3 | } 4 | -------------------------------------------------------------------------------- /packages/common/interfaces/controllers/controller.interface.ts: -------------------------------------------------------------------------------- 1 | export type Controller = object; 2 | -------------------------------------------------------------------------------- /packages/common/interfaces/controllers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './controller-metadata.interface'; 2 | export * from './controller.interface'; 3 | -------------------------------------------------------------------------------- /packages/common/interfaces/exceptions/exception-filter-metadata.interface.ts: -------------------------------------------------------------------------------- 1 | import { ExceptionFilter } from './exception-filter.interface'; 2 | import { Type } from '../type.interface'; 3 | 4 | export interface ExceptionFilterMetadata { 5 | func: ExceptionFilter['catch']; 6 | exceptionMetatypes: Type[]; 7 | } 8 | -------------------------------------------------------------------------------- /packages/common/interfaces/exceptions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './exception-filter-metadata.interface'; 2 | export * from './exception-filter.interface'; 3 | export * from './rpc-exception-filter-metadata.interface'; 4 | export * from './rpc-exception-filter.interface'; 5 | export * from './ws-exception-filter.interface'; 6 | -------------------------------------------------------------------------------- /packages/common/interfaces/exceptions/rpc-exception-filter-metadata.interface.ts: -------------------------------------------------------------------------------- 1 | import { RpcExceptionFilter } from './rpc-exception-filter.interface'; 2 | import { Type } from '../type.interface'; 3 | 4 | export interface RpcExceptionFilterMetadata { 5 | func: RpcExceptionFilter['catch']; 6 | exceptionMetatypes: Type[]; 7 | } 8 | -------------------------------------------------------------------------------- /packages/common/interfaces/features/custom-route-param-factory.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export type CustomParamFactory = ( 5 | data: TData, 6 | input: TInput, 7 | ) => TOutput; 8 | -------------------------------------------------------------------------------- /packages/common/interfaces/features/paramtype.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export type Paramtype = 'body' | 'query' | 'param' | 'custom'; 5 | -------------------------------------------------------------------------------- /packages/common/interfaces/global-prefix-options.interface.ts: -------------------------------------------------------------------------------- 1 | import { RouteInfo } from './middleware'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export interface GlobalPrefixOptions { 7 | exclude?: T[]; 8 | } 9 | -------------------------------------------------------------------------------- /packages/common/interfaces/hooks/before-application-shutdown.interface.ts: -------------------------------------------------------------------------------- 1 | export interface BeforeApplicationShutdown { 2 | beforeApplicationShutdown(signal?: string): any; 3 | } 4 | -------------------------------------------------------------------------------- /packages/common/interfaces/hooks/index.ts: -------------------------------------------------------------------------------- 1 | export * from './before-application-shutdown.interface'; 2 | export * from './on-application-bootstrap.interface'; 3 | export * from './on-application-shutdown.interface'; 4 | export * from './on-destroy.interface'; 5 | export * from './on-init.interface'; 6 | -------------------------------------------------------------------------------- /packages/common/interfaces/hooks/on-init.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Interface defining method called once the host module has been initialized. 3 | * 4 | * @see [Lifecycle Events](https://docs.nestjs.com/fundamentals/lifecycle-events) 5 | * 6 | * @publicApi 7 | */ 8 | export interface OnModuleInit { 9 | onModuleInit(): any; 10 | } 11 | -------------------------------------------------------------------------------- /packages/common/interfaces/http/http-exception-body.interface.ts: -------------------------------------------------------------------------------- 1 | export type HttpExceptionBodyMessage = string | string[]; 2 | 3 | export interface HttpExceptionBody { 4 | message: HttpExceptionBodyMessage; 5 | error?: string; 6 | statusCode: number; 7 | } 8 | -------------------------------------------------------------------------------- /packages/common/interfaces/http/http-redirect-response.interface.ts: -------------------------------------------------------------------------------- 1 | import { HttpStatus } from '../../enums'; 2 | 3 | export interface HttpRedirectResponse { 4 | url: string; 5 | statusCode: HttpStatus; 6 | } 7 | -------------------------------------------------------------------------------- /packages/common/interfaces/http/index.ts: -------------------------------------------------------------------------------- 1 | export * from './http-exception-body.interface'; 2 | export * from './http-redirect-response.interface'; 3 | export * from './http-server.interface'; 4 | export * from './message-event.interface'; 5 | export * from './raw-body-request.interface'; 6 | -------------------------------------------------------------------------------- /packages/common/interfaces/http/message-event.interface.ts: -------------------------------------------------------------------------------- 1 | export interface MessageEvent { 2 | data: string | object; 3 | id?: string; 4 | type?: string; 5 | retry?: number; 6 | } 7 | -------------------------------------------------------------------------------- /packages/common/interfaces/http/raw-body-request.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export type RawBodyRequest = T & { rawBody?: Buffer }; 5 | -------------------------------------------------------------------------------- /packages/common/interfaces/injectable.interface.ts: -------------------------------------------------------------------------------- 1 | export type Injectable = unknown; 2 | -------------------------------------------------------------------------------- /packages/common/interfaces/microservices/nest-hybrid-application-options.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface NestHybridApplicationOptions { 5 | inheritAppConfig?: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /packages/common/interfaces/microservices/nest-microservice-options.interface.ts: -------------------------------------------------------------------------------- 1 | import { NestApplicationContextOptions } from '../nest-application-context-options.interface'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export type NestMicroserviceOptions = NestApplicationContextOptions; 7 | -------------------------------------------------------------------------------- /packages/common/interfaces/middleware/index.ts: -------------------------------------------------------------------------------- 1 | export * from './middleware-config-proxy.interface'; 2 | export * from './middleware-configuration.interface'; 3 | export * from './middleware-consumer.interface'; 4 | export * from './nest-middleware.interface'; 5 | -------------------------------------------------------------------------------- /packages/common/interfaces/middleware/nest-middleware.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @see [Middleware](https://docs.nestjs.com/middleware) 3 | * 4 | * @publicApi 5 | */ 6 | export interface NestMiddleware { 7 | use(req: TRequest, res: TResponse, next: (error?: Error | any) => void): any; 8 | } 9 | -------------------------------------------------------------------------------- /packages/common/interfaces/modules/forward-reference.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ForwardReference { 2 | forwardRef: T; 3 | } 4 | -------------------------------------------------------------------------------- /packages/common/interfaces/modules/injection-token.interface.ts: -------------------------------------------------------------------------------- 1 | import { Abstract } from '../abstract.interface'; 2 | import { Type } from '../type.interface'; 3 | 4 | /** 5 | * @publicApi 6 | */ 7 | export type InjectionToken = 8 | | string 9 | | symbol 10 | | Type 11 | | Abstract 12 | | Function; 13 | -------------------------------------------------------------------------------- /packages/common/interfaces/modules/introspection-result.interface.ts: -------------------------------------------------------------------------------- 1 | import { Scope } from '../scope-options.interface'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export interface IntrospectionResult { 7 | /** 8 | * Enum defining lifetime of host class or factory. 9 | */ 10 | scope: Scope; 11 | } 12 | -------------------------------------------------------------------------------- /packages/common/interfaces/modules/nest-module.interface.ts: -------------------------------------------------------------------------------- 1 | import { MiddlewareConsumer } from '../middleware/middleware-consumer.interface'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export interface NestModule { 7 | configure(consumer: MiddlewareConsumer); 8 | } 9 | -------------------------------------------------------------------------------- /packages/common/interfaces/modules/optional-factory-dependency.interface.ts: -------------------------------------------------------------------------------- 1 | import { InjectionToken } from './injection-token.interface'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export type OptionalFactoryDependency = { 7 | token: InjectionToken; 8 | optional: boolean; 9 | }; 10 | -------------------------------------------------------------------------------- /packages/common/interfaces/type.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Type extends Function { 2 | new (...args: any[]): T; 3 | } 4 | -------------------------------------------------------------------------------- /packages/common/module-utils/constants.ts: -------------------------------------------------------------------------------- 1 | export const DEFAULT_METHOD_KEY = 'register'; 2 | export const DEFAULT_FACTORY_CLASS_METHOD_KEY = 'create'; 3 | 4 | export const ASYNC_METHOD_SUFFIX = 'Async'; 5 | export const CONFIGURABLE_MODULE_ID = 'CONFIGURABLE_MODULE_ID'; 6 | -------------------------------------------------------------------------------- /packages/common/module-utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './configurable-module.builder'; 2 | export * from './interfaces'; 3 | -------------------------------------------------------------------------------- /packages/common/module-utils/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './configurable-module-async-options.interface'; 2 | export * from './configurable-module-cls.interface'; 3 | export * from './configurable-module-host.interface'; 4 | -------------------------------------------------------------------------------- /packages/common/module-utils/utils/generate-options-injection-token.util.ts: -------------------------------------------------------------------------------- 1 | import { randomStringGenerator } from '../../utils/random-string-generator.util'; 2 | 3 | export function generateOptionsInjectionToken() { 4 | const hash = randomStringGenerator(); 5 | return `CONFIGURABLE_MODULE_OPTIONS[${hash}]`; 6 | } 7 | -------------------------------------------------------------------------------- /packages/common/module-utils/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './generate-options-injection-token.util'; 2 | export * from './get-injection-providers.util'; 3 | -------------------------------------------------------------------------------- /packages/common/pipes/file/index.ts: -------------------------------------------------------------------------------- 1 | export * from './file-type.validator'; 2 | export * from './file-validator.interface'; 3 | export * from './max-file-size.validator'; 4 | export * from './parse-file-options.interface'; 5 | export * from './parse-file.pipe'; 6 | export * from './parse-file-pipe.builder'; 7 | -------------------------------------------------------------------------------- /packages/common/pipes/file/interfaces/file.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IFile { 2 | mimetype: string; 3 | size: number; 4 | } 5 | -------------------------------------------------------------------------------- /packages/common/pipes/file/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './file.interface'; 2 | -------------------------------------------------------------------------------- /packages/common/pipes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './default-value.pipe'; 2 | export * from './parse-array.pipe'; 3 | export * from './parse-bool.pipe'; 4 | export * from './parse-int.pipe'; 5 | export * from './parse-float.pipe'; 6 | export * from './parse-enum.pipe'; 7 | export * from './parse-uuid.pipe'; 8 | export * from './validation.pipe'; 9 | export * from './file'; 10 | -------------------------------------------------------------------------------- /packages/common/serializer/class-serializer.constants.ts: -------------------------------------------------------------------------------- 1 | export const CLASS_SERIALIZER_OPTIONS = 'class_serializer:options'; 2 | -------------------------------------------------------------------------------- /packages/common/serializer/class-serializer.interfaces.ts: -------------------------------------------------------------------------------- 1 | import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface'; 2 | import { Type } from '../interfaces'; 3 | 4 | /** 5 | * @publicApi 6 | */ 7 | export interface ClassSerializerContextOptions extends ClassTransformOptions { 8 | type?: Type; 9 | } 10 | -------------------------------------------------------------------------------- /packages/common/serializer/decorators/index.ts: -------------------------------------------------------------------------------- 1 | export * from './serialize-options.decorator'; 2 | -------------------------------------------------------------------------------- /packages/common/serializer/index.ts: -------------------------------------------------------------------------------- 1 | export * from './class-serializer.interceptor'; 2 | export * from './decorators'; 3 | export * from './class-serializer.interfaces'; 4 | -------------------------------------------------------------------------------- /packages/common/services/index.ts: -------------------------------------------------------------------------------- 1 | export * from './console-logger.service'; 2 | export * from './logger.service'; 3 | -------------------------------------------------------------------------------- /packages/common/services/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './is-log-level-enabled.util'; 2 | -------------------------------------------------------------------------------- /packages/common/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.spec.json" 3 | } 4 | -------------------------------------------------------------------------------- /packages/common/test/utils/random-string-generator.util.spec.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai'; 2 | import { randomStringGenerator } from '../../utils/random-string-generator.util'; 3 | 4 | describe('randomStringGenerator', () => { 5 | it('should generate random string', () => { 6 | expect(randomStringGenerator()).to.be.a('string'); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /packages/common/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "outDir": ".", 5 | "rootDir": ".", 6 | "paths": {} 7 | }, 8 | "exclude": ["node_modules", "dist", "test/**/*", "*.spec.ts"], 9 | "references": [] 10 | } 11 | -------------------------------------------------------------------------------- /packages/common/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/common/utils/extend-metadata.util.ts: -------------------------------------------------------------------------------- 1 | export function extendArrayMetadata>( 2 | key: string, 3 | metadata: T, 4 | target: Function, 5 | ) { 6 | const previousValue = Reflect.getMetadata(key, target) || []; 7 | const value = [...previousValue, ...metadata]; 8 | Reflect.defineMetadata(key, value, target); 9 | } 10 | -------------------------------------------------------------------------------- /packages/common/utils/forward-ref.util.ts: -------------------------------------------------------------------------------- 1 | import { ForwardReference } from '../interfaces/modules/forward-reference.interface'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export const forwardRef = (fn: () => any): ForwardReference => ({ 7 | forwardRef: fn, 8 | }); 9 | -------------------------------------------------------------------------------- /packages/common/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './forward-ref.util'; 2 | -------------------------------------------------------------------------------- /packages/common/utils/random-string-generator.util.ts: -------------------------------------------------------------------------------- 1 | import { uid } from 'uid'; 2 | 3 | export const randomStringGenerator = () => uid(21); 4 | -------------------------------------------------------------------------------- /packages/core/PACKAGE.md: -------------------------------------------------------------------------------- 1 | Implements Nest's core functionality, low-level services, and utilities. 2 | -------------------------------------------------------------------------------- /packages/core/adapters/index.ts: -------------------------------------------------------------------------------- 1 | export * from './http-adapter'; 2 | -------------------------------------------------------------------------------- /packages/core/discovery/index.ts: -------------------------------------------------------------------------------- 1 | export * from './discovery-module'; 2 | export * from './discovery-service'; 3 | -------------------------------------------------------------------------------- /packages/core/errors/exceptions/invalid-class.exception.ts: -------------------------------------------------------------------------------- 1 | import { INVALID_CLASS_MESSAGE } from '../messages'; 2 | import { RuntimeException } from './runtime.exception'; 3 | 4 | export class InvalidClassException extends RuntimeException { 5 | constructor(value: any) { 6 | super(INVALID_CLASS_MESSAGE`${value}`); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/core/errors/exceptions/invalid-exception-filter.exception.ts: -------------------------------------------------------------------------------- 1 | import { RuntimeException } from './runtime.exception'; 2 | import { INVALID_EXCEPTION_FILTER } from '../messages'; 3 | 4 | export class InvalidExceptionFilterException extends RuntimeException { 5 | constructor() { 6 | super(INVALID_EXCEPTION_FILTER); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/core/errors/exceptions/invalid-middleware-configuration.exception.ts: -------------------------------------------------------------------------------- 1 | import { RuntimeException } from './runtime.exception'; 2 | import { INVALID_MIDDLEWARE_CONFIGURATION } from '../messages'; 3 | 4 | export class InvalidMiddlewareConfigurationException extends RuntimeException { 5 | constructor() { 6 | super(INVALID_MIDDLEWARE_CONFIGURATION); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/core/errors/exceptions/invalid-middleware.exception.ts: -------------------------------------------------------------------------------- 1 | import { INVALID_MIDDLEWARE_MESSAGE } from '../messages'; 2 | import { RuntimeException } from './runtime.exception'; 3 | 4 | export class InvalidMiddlewareException extends RuntimeException { 5 | constructor(name: string) { 6 | super(INVALID_MIDDLEWARE_MESSAGE`${name}`); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/core/errors/exceptions/runtime.exception.ts: -------------------------------------------------------------------------------- 1 | export class RuntimeException extends Error { 2 | constructor(message = ``) { 3 | super(message); 4 | } 5 | 6 | public what() { 7 | return this.message; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/core/errors/exceptions/unknown-export.exception.ts: -------------------------------------------------------------------------------- 1 | import { UNKNOWN_EXPORT_MESSAGE } from '../messages'; 2 | import { RuntimeException } from './runtime.exception'; 3 | 4 | export class UnknownExportException extends RuntimeException { 5 | constructor(token: string | symbol, moduleName: string) { 6 | super(UNKNOWN_EXPORT_MESSAGE(token, moduleName)); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/core/exceptions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './base-exception-filter'; 2 | -------------------------------------------------------------------------------- /packages/core/guards/constants.ts: -------------------------------------------------------------------------------- 1 | export const FORBIDDEN_MESSAGE = 'Forbidden resource'; 2 | -------------------------------------------------------------------------------- /packages/core/guards/index.ts: -------------------------------------------------------------------------------- 1 | export * from './constants'; 2 | export * from './guards-consumer'; 3 | export * from './guards-context-creator'; 4 | -------------------------------------------------------------------------------- /packages/core/helpers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './context-id-factory'; 2 | export * from './external-context-creator'; 3 | export * from './http-adapter-host'; 4 | -------------------------------------------------------------------------------- /packages/core/helpers/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './external-handler-metadata.interface'; 2 | export * from './params-metadata.interface'; 3 | -------------------------------------------------------------------------------- /packages/core/helpers/interfaces/params-metadata.interface.ts: -------------------------------------------------------------------------------- 1 | import { ParamData } from '@nestjs/common'; 2 | 3 | export type ParamsMetadata = Record; 4 | export interface ParamMetadata { 5 | index: number; 6 | data?: ParamData; 7 | } 8 | -------------------------------------------------------------------------------- /packages/core/helpers/is-durable.ts: -------------------------------------------------------------------------------- 1 | import { SCOPE_OPTIONS_METADATA } from '@nestjs/common/constants'; 2 | import { Type } from '@nestjs/common/interfaces/type.interface'; 3 | 4 | export function isDurable(provider: Type): boolean | undefined { 5 | const metadata = Reflect.getMetadata(SCOPE_OPTIONS_METADATA, provider); 6 | return metadata && metadata.durable; 7 | } 8 | -------------------------------------------------------------------------------- /packages/core/helpers/optional-require.ts: -------------------------------------------------------------------------------- 1 | export function optionalRequire(packageName: string, loaderFn?: Function) { 2 | try { 3 | return loaderFn ? loaderFn() : require(packageName); 4 | } catch (e) { 5 | return {}; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/core/helpers/rethrow.ts: -------------------------------------------------------------------------------- 1 | export const rethrow = (err: unknown) => { 2 | throw err; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/core/hooks/index.ts: -------------------------------------------------------------------------------- 1 | export * from './on-app-bootstrap.hook'; 2 | export * from './on-app-shutdown.hook'; 3 | export * from './on-module-destroy.hook'; 4 | export * from './on-module-init.hook'; 5 | export * from './before-app-shutdown.hook'; 6 | -------------------------------------------------------------------------------- /packages/core/injector/constants.ts: -------------------------------------------------------------------------------- 1 | import { ContextId } from './instance-wrapper'; 2 | 3 | export const CONTROLLER_ID_KEY = 'CONTROLLER_ID'; 4 | 5 | const STATIC_CONTEXT_ID = 1; 6 | export const STATIC_CONTEXT: ContextId = Object.freeze({ 7 | id: STATIC_CONTEXT_ID, 8 | }); 9 | -------------------------------------------------------------------------------- /packages/core/injector/index.ts: -------------------------------------------------------------------------------- 1 | export * from './container'; 2 | export * from './inquirer'; 3 | export { ContextId, HostComponentInfo } from './instance-wrapper'; 4 | export * from './lazy-module-loader/lazy-module-loader'; 5 | export * from './module-ref'; 6 | export * from './modules-container'; 7 | -------------------------------------------------------------------------------- /packages/core/injector/inquirer/index.ts: -------------------------------------------------------------------------------- 1 | export * from './inquirer-constants'; 2 | -------------------------------------------------------------------------------- /packages/core/injector/inquirer/inquirer-constants.ts: -------------------------------------------------------------------------------- 1 | export const INQUIRER = 'INQUIRER'; 2 | -------------------------------------------------------------------------------- /packages/core/injector/internal-core-module/index.ts: -------------------------------------------------------------------------------- 1 | export * from './internal-core-module'; 2 | -------------------------------------------------------------------------------- /packages/core/injector/lazy-module-loader/lazy-module-loader-options.interface.ts: -------------------------------------------------------------------------------- 1 | export interface LazyModuleLoaderLoadOptions { 2 | /** 3 | * If `false`, no logs will be generated when loading some module lazily. 4 | */ 5 | logger?: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /packages/core/inspector/index.ts: -------------------------------------------------------------------------------- 1 | export * from './graph-inspector'; 2 | export * from './initialize-on-preview.allowlist'; 3 | export * from './partial-graph.host'; 4 | export * from './serialized-graph'; 5 | -------------------------------------------------------------------------------- /packages/core/inspector/noop-graph-inspector.ts: -------------------------------------------------------------------------------- 1 | import { GraphInspector } from './graph-inspector'; 2 | 3 | // eslint-disable-next-line @typescript-eslint/no-empty-function 4 | const noop = () => {}; 5 | export const NoopGraphInspector: GraphInspector = new Proxy( 6 | GraphInspector.prototype, 7 | { 8 | get: () => noop, 9 | }, 10 | ); 11 | -------------------------------------------------------------------------------- /packages/core/interceptors/index.ts: -------------------------------------------------------------------------------- 1 | export * from './interceptors-consumer'; 2 | export * from './interceptors-context-creator'; 3 | -------------------------------------------------------------------------------- /packages/core/interfaces/module-definition.interface.ts: -------------------------------------------------------------------------------- 1 | import { DynamicModule, ForwardReference } from '@nestjs/common'; 2 | import { Type } from '@nestjs/common/interfaces'; 3 | 4 | export type ModuleDefinition = 5 | | ForwardReference 6 | | Type 7 | | DynamicModule 8 | | Promise; 9 | -------------------------------------------------------------------------------- /packages/core/interfaces/module-override.interface.ts: -------------------------------------------------------------------------------- 1 | import { ModuleDefinition } from './module-definition.interface'; 2 | 3 | export interface ModuleOverride { 4 | moduleToReplace: ModuleDefinition; 5 | newModule: ModuleDefinition; 6 | } 7 | -------------------------------------------------------------------------------- /packages/core/middleware/index.ts: -------------------------------------------------------------------------------- 1 | export * from './builder'; 2 | -------------------------------------------------------------------------------- /packages/core/pipes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './params-token-factory'; 2 | export * from './pipes-consumer'; 3 | export * from './pipes-context-creator'; 4 | -------------------------------------------------------------------------------- /packages/core/repl/constants.ts: -------------------------------------------------------------------------------- 1 | export const REPL_INITIALIZED_MESSAGE = 'REPL initialized'; 2 | -------------------------------------------------------------------------------- /packages/core/repl/index.ts: -------------------------------------------------------------------------------- 1 | export * from './repl'; 2 | -------------------------------------------------------------------------------- /packages/core/repl/native-functions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './help-repl-fn'; 2 | export * from './get-relp-fn'; 3 | export * from './resolve-repl-fn'; 4 | export * from './select-relp-fn'; 5 | export * from './debug-repl-fn'; 6 | export * from './methods-repl-fn'; 7 | -------------------------------------------------------------------------------- /packages/core/router/index.ts: -------------------------------------------------------------------------------- 1 | export * from './interfaces'; 2 | export * from './request'; 3 | export { RouterModule } from './router-module'; 4 | -------------------------------------------------------------------------------- /packages/core/router/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './routes.interface'; 2 | -------------------------------------------------------------------------------- /packages/core/router/interfaces/resolver.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Resolver { 2 | resolve(instance: any, basePath: string): void; 3 | registerNotFoundHandler(): void; 4 | registerExceptionHandler(): void; 5 | } 6 | -------------------------------------------------------------------------------- /packages/core/router/interfaces/routes.interface.ts: -------------------------------------------------------------------------------- 1 | import { Type } from '@nestjs/common'; 2 | 3 | export interface RouteTree { 4 | path: string; 5 | module?: Type; 6 | children?: (RouteTree | Type)[]; 7 | } 8 | 9 | export type Routes = RouteTree[]; 10 | -------------------------------------------------------------------------------- /packages/core/router/request/index.ts: -------------------------------------------------------------------------------- 1 | export { REQUEST } from './request-constants'; 2 | -------------------------------------------------------------------------------- /packages/core/router/request/request-constants.ts: -------------------------------------------------------------------------------- 1 | export const REQUEST = 'REQUEST'; 2 | export const REQUEST_CONTEXT_ID = Symbol('REQUEST_CONTEXT_ID'); 3 | -------------------------------------------------------------------------------- /packages/core/router/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './exclude-route.util'; 2 | export * from './flatten-route-paths.util'; 3 | -------------------------------------------------------------------------------- /packages/core/services/index.ts: -------------------------------------------------------------------------------- 1 | export * from './reflector.service'; 2 | -------------------------------------------------------------------------------- /packages/core/test/helpers/context-id-factory.spec.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai'; 2 | import { createContextId } from '../../helpers/context-id-factory'; 3 | 4 | describe('createContextId', () => { 5 | it('should return an object with random "id" property', () => { 6 | expect(createContextId()).to.have.property('id'); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /packages/core/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.spec.json" 3 | } 4 | -------------------------------------------------------------------------------- /packages/core/test/utils/string.cleaner.ts: -------------------------------------------------------------------------------- 1 | export function stringCleaner(str: string) { 2 | return str ? str.replace(/\s+/g, '').replace(/\n+/g, '') : str; 3 | } 4 | -------------------------------------------------------------------------------- /packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Nest 3 | * Copyright(c) 2017 - 2023 Kamil Mysliwiec 4 | * https://nestjs.com 5 | * MIT Licensed 6 | */ 7 | -------------------------------------------------------------------------------- /packages/microservices/client/constants.ts: -------------------------------------------------------------------------------- 1 | export const GRPC_CANCELLED = 'Cancelled'; 2 | export const RABBITMQ_REPLY_QUEUE = 'amq.rabbitmq.reply-to'; 3 | -------------------------------------------------------------------------------- /packages/microservices/ctx-host/index.ts: -------------------------------------------------------------------------------- 1 | export * from './kafka.context'; 2 | export * from './mqtt.context'; 3 | export * from './nats.context'; 4 | export * from './redis.context'; 5 | export * from './rmq.context'; 6 | export * from './tcp.context'; 7 | export * from './base-rpc.context'; 8 | -------------------------------------------------------------------------------- /packages/microservices/decorators/ctx.decorator.ts: -------------------------------------------------------------------------------- 1 | import { RpcParamtype } from '../enums/rpc-paramtype.enum'; 2 | import { createRpcParamDecorator } from '../utils/param.utils'; 3 | 4 | export const Ctx: () => ParameterDecorator = createRpcParamDecorator( 5 | RpcParamtype.CONTEXT, 6 | ); 7 | -------------------------------------------------------------------------------- /packages/microservices/decorators/grpc-service.decorator.ts: -------------------------------------------------------------------------------- 1 | import { Controller } from '@nestjs/common'; 2 | 3 | /** 4 | * Defines the GrpcService. The service can inject dependencies through constructor. 5 | * Those dependencies have to belong to the same module. 6 | */ 7 | export const GrpcService = Controller; 8 | -------------------------------------------------------------------------------- /packages/microservices/decorators/index.ts: -------------------------------------------------------------------------------- 1 | export * from './client.decorator'; 2 | export * from './ctx.decorator'; 3 | export * from './event-pattern.decorator'; 4 | export * from './grpc-service.decorator'; 5 | export * from './message-pattern.decorator'; 6 | export * from './payload.decorator'; 7 | -------------------------------------------------------------------------------- /packages/microservices/deserializers/identity.deserializer.ts: -------------------------------------------------------------------------------- 1 | import { Deserializer } from '../interfaces/deserializer.interface'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export class IdentityDeserializer implements Deserializer { 7 | deserialize(value: any) { 8 | return value; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/microservices/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './transport.enum'; 2 | export * from './kafka-headers.enum'; 3 | -------------------------------------------------------------------------------- /packages/microservices/enums/pattern-handler.enum.ts: -------------------------------------------------------------------------------- 1 | export enum PatternHandler { 2 | MESSAGE = 1, 3 | EVENT = 2, 4 | } 5 | -------------------------------------------------------------------------------- /packages/microservices/enums/rpc-paramtype.enum.ts: -------------------------------------------------------------------------------- 1 | import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum'; 2 | 3 | export enum RpcParamtype { 4 | PAYLOAD = RouteParamtypes.BODY, 5 | CONTEXT = RouteParamtypes.HEADERS, 6 | GRPC_CALL = RouteParamtypes.FILES, 7 | } 8 | -------------------------------------------------------------------------------- /packages/microservices/enums/transport.enum.ts: -------------------------------------------------------------------------------- 1 | export enum Transport { 2 | TCP, 3 | REDIS, 4 | NATS, 5 | MQTT, 6 | GRPC, 7 | RMQ, 8 | KAFKA, 9 | } 10 | -------------------------------------------------------------------------------- /packages/microservices/errors/corrupted-packet-length.exception.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export class CorruptedPacketLengthException extends Error { 5 | constructor(rawContentLength: string) { 6 | super(`Corrupted length value "${rawContentLength}" supplied in a packet`); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/microservices/errors/empty-response.exception.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export class EmptyResponseException extends Error { 5 | constructor(pattern: string) { 6 | super( 7 | `Empty response. There are no subscribers listening to that message ("${pattern}")`, 8 | ); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/microservices/errors/invalid-json-format.exception.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export class InvalidJSONFormatException extends Error { 5 | constructor(err: Error, data: string) { 6 | super(`Could not parse JSON: ${err.message}\nRequest data: ${data}`); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/microservices/errors/invalid-message.exception.ts: -------------------------------------------------------------------------------- 1 | import { RuntimeException } from '@nestjs/core/errors/exceptions/runtime.exception'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export class InvalidMessageException extends RuntimeException { 7 | constructor() { 8 | super(`The invalid data or message pattern (undefined/null)`); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/microservices/errors/net-socket-closed.exception.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export class NetSocketClosedException extends Error { 5 | constructor() { 6 | super(`The net socket is closed.`); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/microservices/exceptions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './base-rpc-exception-filter'; 2 | export * from './kafka-retriable-exception'; 3 | export * from './rpc-exception'; 4 | -------------------------------------------------------------------------------- /packages/microservices/helpers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './json-socket'; 2 | export * from './kafka-logger'; 3 | export * from './kafka-parser'; 4 | export * from './kafka-reply-partition-assigner'; 5 | export * from './tcp-socket'; 6 | export * from './grpc-helpers'; 7 | -------------------------------------------------------------------------------- /packages/microservices/interfaces/client-grpc.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface ClientGrpc { 5 | getService(name: string): T; 6 | getClientByServiceName(name: string): T; 7 | } 8 | -------------------------------------------------------------------------------- /packages/microservices/interfaces/closeable.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Closeable { 2 | close(): void; 3 | } 4 | -------------------------------------------------------------------------------- /packages/microservices/interfaces/custom-transport-strategy.interface.ts: -------------------------------------------------------------------------------- 1 | import { Transport } from '../enums'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export interface CustomTransportStrategy { 7 | readonly transportId?: Transport | symbol; 8 | listen(callback: (...optionalParams: unknown[]) => any): any; 9 | close(): any; 10 | } 11 | -------------------------------------------------------------------------------- /packages/microservices/interfaces/pattern-metadata.interface.ts: -------------------------------------------------------------------------------- 1 | export type PatternMetadata = Record | string; 2 | -------------------------------------------------------------------------------- /packages/microservices/interfaces/pattern.interface.ts: -------------------------------------------------------------------------------- 1 | export type MsFundamentalPattern = string | number; 2 | 3 | export interface MsObjectPattern { 4 | [key: string]: MsFundamentalPattern | MsObjectPattern; 5 | } 6 | 7 | export type MsPattern = MsObjectPattern | MsFundamentalPattern; 8 | -------------------------------------------------------------------------------- /packages/microservices/module/index.ts: -------------------------------------------------------------------------------- 1 | export * from './clients.module'; 2 | export * from './interfaces'; 3 | -------------------------------------------------------------------------------- /packages/microservices/module/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './clients-module.interface'; 2 | -------------------------------------------------------------------------------- /packages/microservices/record-builders/index.ts: -------------------------------------------------------------------------------- 1 | export * from './mqtt.record-builder'; 2 | export * from './nats.record-builder'; 3 | export * from './rmq.record-builder'; 4 | -------------------------------------------------------------------------------- /packages/microservices/serializers/identity.serializer.ts: -------------------------------------------------------------------------------- 1 | import { Serializer } from '../interfaces/serializer.interface'; 2 | 3 | export class IdentitySerializer implements Serializer { 4 | serialize(value: any) { 5 | return value; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/microservices/serializers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './identity.serializer'; 2 | export * from './kafka-request.serializer'; 3 | export * from './mqtt-record.serializer'; 4 | export * from './nats-record.serializer'; 5 | export * from './rmq-record.serializer'; 6 | -------------------------------------------------------------------------------- /packages/microservices/server/index.ts: -------------------------------------------------------------------------------- 1 | export * from './server'; 2 | export * from './server-grpc'; 3 | export * from './server-kafka'; 4 | export * from './server-mqtt'; 5 | export * from './server-nats'; 6 | export * from './server-redis'; 7 | export * from './server-rmq'; 8 | export * from './server-tcp'; 9 | -------------------------------------------------------------------------------- /packages/microservices/test/client/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package test; 4 | 5 | service TestService { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /packages/microservices/test/client/test2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package test2; 4 | 5 | service TestService { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /packages/microservices/test/server/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package test; -------------------------------------------------------------------------------- /packages/microservices/test/server/test2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package test2; -------------------------------------------------------------------------------- /packages/microservices/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.spec.json" 3 | } 4 | -------------------------------------------------------------------------------- /packages/microservices/tokens.ts: -------------------------------------------------------------------------------- 1 | import { REQUEST } from '@nestjs/core'; 2 | 3 | export const CONTEXT = REQUEST; 4 | -------------------------------------------------------------------------------- /packages/microservices/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/microservices/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './transform-pattern.utils'; 2 | -------------------------------------------------------------------------------- /packages/platform-express/adapters/index.ts: -------------------------------------------------------------------------------- 1 | export * from './express-adapter'; 2 | -------------------------------------------------------------------------------- /packages/platform-express/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Nest @platform-express 3 | * Copyright(c) 2017 - 2023 Kamil Mysliwiec 4 | * https://nestjs.com 5 | * MIT Licensed 6 | */ 7 | 8 | export * from './adapters'; 9 | export * from './interfaces'; 10 | export * from './multer'; 11 | -------------------------------------------------------------------------------- /packages/platform-express/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './nest-express-application.interface'; 2 | export { NestExpressBodyParserOptions } from './nest-express-body-parser-options.interface'; 3 | export * from './nest-express-body-parser.interface'; 4 | -------------------------------------------------------------------------------- /packages/platform-express/interfaces/nest-express-body-parser.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Interface defining possible body parser types, to be used with `NestExpressApplication.useBodyParser()`. 3 | */ 4 | export type NestExpressBodyParserType = 'json' | 'urlencoded' | 'text' | 'raw'; 5 | -------------------------------------------------------------------------------- /packages/platform-express/multer/files.constants.ts: -------------------------------------------------------------------------------- 1 | export const MULTER_MODULE_OPTIONS = 'MULTER_MODULE_OPTIONS'; 2 | -------------------------------------------------------------------------------- /packages/platform-express/multer/index.ts: -------------------------------------------------------------------------------- 1 | export * from './interceptors'; 2 | export * from './interfaces'; 3 | export * from './multer.module'; 4 | -------------------------------------------------------------------------------- /packages/platform-express/multer/interceptors/index.ts: -------------------------------------------------------------------------------- 1 | export * from './any-files.interceptor'; 2 | export * from './file-fields.interceptor'; 3 | export * from './file.interceptor'; 4 | export * from './files.interceptor'; 5 | export * from './no-files.interceptor'; 6 | -------------------------------------------------------------------------------- /packages/platform-express/multer/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './files-upload-module.interface'; 2 | -------------------------------------------------------------------------------- /packages/platform-express/multer/multer.constants.ts: -------------------------------------------------------------------------------- 1 | export const MULTER_MODULE_ID = 'MULTER_MODULE_ID'; 2 | -------------------------------------------------------------------------------- /packages/platform-express/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.spec.json" 3 | } 4 | -------------------------------------------------------------------------------- /packages/platform-express/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/platform-fastify/adapters/index.ts: -------------------------------------------------------------------------------- 1 | export * from './fastify-adapter'; 2 | -------------------------------------------------------------------------------- /packages/platform-fastify/constants.ts: -------------------------------------------------------------------------------- 1 | export const FASTIFY_ROUTE_CONFIG_METADATA = '__fastify_route_config__'; 2 | export const FASTIFY_ROUTE_CONSTRAINTS_METADATA = 3 | '__fastify_route_constraints__'; 4 | -------------------------------------------------------------------------------- /packages/platform-fastify/decorators/index.ts: -------------------------------------------------------------------------------- 1 | export * from './route-config.decorator'; 2 | export * from './route-constraints.decorator'; 3 | -------------------------------------------------------------------------------- /packages/platform-fastify/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Nest @platform-fastify 3 | * Copyright(c) 2017 - 2023 Kamil Mysliwiec 4 | * https://nestjs.com 5 | * MIT Licensed 6 | */ 7 | 8 | export * from './adapters'; 9 | export * from './interfaces'; 10 | export * from './decorators'; 11 | -------------------------------------------------------------------------------- /packages/platform-fastify/interfaces/external/index.ts: -------------------------------------------------------------------------------- 1 | export * from './fastify-static-options.interface'; 2 | export * from './fastify-view-options.interface'; 3 | -------------------------------------------------------------------------------- /packages/platform-fastify/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './nest-fastify-application.interface'; 2 | export * from './nest-fastify-body-parser-options.interface'; 3 | -------------------------------------------------------------------------------- /packages/platform-fastify/interfaces/nest-fastify-body-parser-options.interface.ts: -------------------------------------------------------------------------------- 1 | import type { AddContentTypeParser } from 'fastify'; 2 | 3 | export type NestFastifyBodyParserOptions = Omit< 4 | Parameters[1], 5 | 'parseAs' 6 | >; 7 | -------------------------------------------------------------------------------- /packages/platform-fastify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/platform-socket.io/adapters/index.ts: -------------------------------------------------------------------------------- 1 | export * from './io-adapter'; 2 | -------------------------------------------------------------------------------- /packages/platform-socket.io/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Nest @platform-socket.io 3 | * Copyright(c) 2017 - 2023 Kamil Mysliwiec 4 | * https://nestjs.com 5 | * MIT Licensed 6 | */ 7 | 8 | export * from './adapters'; 9 | -------------------------------------------------------------------------------- /packages/platform-socket.io/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/platform-ws/adapters/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ws-adapter'; 2 | -------------------------------------------------------------------------------- /packages/platform-ws/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Nest @platform-ws 3 | * Copyright(c) 2017 - 2023 Kamil Mysliwiec 4 | * https://nestjs.com 5 | * MIT Licensed 6 | */ 7 | 8 | export * from './adapters'; 9 | -------------------------------------------------------------------------------- /packages/platform-ws/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/testing/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Nest @testing 3 | * Copyright(c) 2017 - 2023 Kamil Mysliwiec 4 | * https://nestjs.com 5 | * MIT Licensed 6 | */ 7 | 8 | export * from './interfaces'; 9 | export * from './test'; 10 | export * from './testing-module'; 11 | export * from './testing-module.builder'; 12 | -------------------------------------------------------------------------------- /packages/testing/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './mock-factory'; 2 | export * from './override-by-factory-options.interface'; 3 | export * from './override-by.interface'; 4 | -------------------------------------------------------------------------------- /packages/testing/interfaces/mock-factory.ts: -------------------------------------------------------------------------------- 1 | import { InjectionToken } from '@nestjs/common'; 2 | 3 | export type MockFactory = (token?: InjectionToken) => any; 4 | -------------------------------------------------------------------------------- /packages/testing/interfaces/override-by-factory-options.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface OverrideByFactoryOptions { 5 | factory: (...args: any[]) => any; 6 | inject?: any[]; 7 | } 8 | -------------------------------------------------------------------------------- /packages/testing/interfaces/override-module.interface.ts: -------------------------------------------------------------------------------- 1 | import { ModuleDefinition } from '@nestjs/core/interfaces/module-definition.interface'; 2 | import { TestingModuleBuilder } from '../testing-module.builder'; 3 | 4 | /** 5 | * @publicApi 6 | */ 7 | export interface OverrideModule { 8 | useModule: (newModule: ModuleDefinition) => TestingModuleBuilder; 9 | } 10 | -------------------------------------------------------------------------------- /packages/testing/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/websockets/adapters/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ws-adapter'; 2 | -------------------------------------------------------------------------------- /packages/websockets/context/ws-metadata-constants.ts: -------------------------------------------------------------------------------- 1 | import { WsParamtype } from '../enums/ws-paramtype.enum'; 2 | 3 | export const DEFAULT_CALLBACK_METADATA = { 4 | [`${WsParamtype.PAYLOAD}:1`]: { index: 1, data: undefined, pipes: [] }, 5 | [`${WsParamtype.SOCKET}:0`]: { index: 0, data: undefined, pipes: [] }, 6 | }; 7 | -------------------------------------------------------------------------------- /packages/websockets/decorators/connected-socket.decorator.ts: -------------------------------------------------------------------------------- 1 | import { WsParamtype } from '../enums/ws-paramtype.enum'; 2 | import { createWsParamDecorator } from '../utils/param.utils'; 3 | 4 | /** 5 | * @publicApi 6 | */ 7 | export const ConnectedSocket: () => ParameterDecorator = createWsParamDecorator( 8 | WsParamtype.SOCKET, 9 | ); 10 | -------------------------------------------------------------------------------- /packages/websockets/decorators/index.ts: -------------------------------------------------------------------------------- 1 | export * from './connected-socket.decorator'; 2 | export * from './gateway-server.decorator'; 3 | export * from './message-body.decorator'; 4 | export * from './socket-gateway.decorator'; 5 | export * from './subscribe-message.decorator'; 6 | -------------------------------------------------------------------------------- /packages/websockets/enums/ws-paramtype.enum.ts: -------------------------------------------------------------------------------- 1 | import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum'; 2 | 3 | export enum WsParamtype { 4 | SOCKET = RouteParamtypes.REQUEST, 5 | PAYLOAD = RouteParamtypes.BODY, 6 | } 7 | -------------------------------------------------------------------------------- /packages/websockets/errors/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ws-exception'; 2 | -------------------------------------------------------------------------------- /packages/websockets/errors/invalid-socket-port.exception.ts: -------------------------------------------------------------------------------- 1 | import { RuntimeException } from '@nestjs/core/errors/exceptions/runtime.exception'; 2 | 3 | export class InvalidSocketPortException extends RuntimeException { 4 | constructor(port: number | string, type: any) { 5 | super(`Invalid port (${port}) in gateway ${type}`); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/websockets/exceptions/index.ts: -------------------------------------------------------------------------------- 1 | export * from './base-ws-exception-filter'; 2 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/hooks/index.ts: -------------------------------------------------------------------------------- 1 | export * from './on-gateway-connection.interface'; 2 | export * from './on-gateway-disconnect.interface'; 3 | export * from './on-gateway-init.interface'; 4 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/hooks/on-gateway-connection.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface OnGatewayConnection { 5 | handleConnection(client: T, ...args: any[]): any; 6 | } 7 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/hooks/on-gateway-disconnect.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface OnGatewayDisconnect { 5 | handleDisconnect(client: T): any; 6 | } 7 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/hooks/on-gateway-init.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface OnGatewayInit { 5 | afterInit(server: T): any; 6 | } 7 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './gateway-metadata.interface'; 2 | export * from './hooks'; 3 | export * from './server-and-event-streams-host.interface'; 4 | export * from './web-socket-server.interface'; 5 | export * from './ws-response.interface'; 6 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/nest-gateway.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface NestGateway { 5 | afterInit?: (server: any) => void; 6 | handleConnection?: (...args: any[]) => void; 7 | handleDisconnect?: (client: any) => void; 8 | } 9 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/server-and-event-streams-host.interface.ts: -------------------------------------------------------------------------------- 1 | import { ReplaySubject, Subject } from 'rxjs'; 2 | 3 | /** 4 | * @publicApi 5 | */ 6 | export interface ServerAndEventStreamsHost { 7 | server: T; 8 | init: ReplaySubject; 9 | connection: Subject; 10 | disconnect: Subject; 11 | } 12 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/web-socket-server.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface WebSocketServerOptions { 5 | port: number; 6 | namespace: string; 7 | } 8 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/websockets-entrypoint-metadata.interface.ts: -------------------------------------------------------------------------------- 1 | export type WebsocketEntrypointMetadata = { 2 | port: number; 3 | message: unknown; 4 | }; 5 | -------------------------------------------------------------------------------- /packages/websockets/interfaces/ws-response.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @publicApi 3 | */ 4 | export interface WsResponse { 5 | event: string; 6 | data: T; 7 | } 8 | -------------------------------------------------------------------------------- /packages/websockets/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.spec.json" 3 | } 4 | -------------------------------------------------------------------------------- /packages/websockets/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": [], 7 | "include": [], 8 | "references": [ 9 | { 10 | "path": "./tsconfig.build.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/websockets/utils/compare-element.util.ts: -------------------------------------------------------------------------------- 1 | export function compareElementAt( 2 | prev: unknown[], 3 | curr: unknown[], 4 | index: number, 5 | ) { 6 | return prev && curr && prev[index] === curr[index]; 7 | } 8 | -------------------------------------------------------------------------------- /packages/websockets/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './param.utils'; 2 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["config:base", ":dependencyDashboard"], 3 | "labels": ["dependencies"], 4 | "packageRules": [ 5 | { 6 | "matchDepTypes": ["devDependencies"], 7 | "automerge": true 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /sample/01-cats-app/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # tests 13 | /test 14 | /coverage 15 | /.nyc_output 16 | 17 | # dist 18 | /dist -------------------------------------------------------------------------------- /sample/01-cats-app/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsModule } from './cats/cats.module'; 3 | import { CoreModule } from './core/core.module'; 4 | 5 | @Module({ 6 | imports: [CoreModule, CatsModule], 7 | }) 8 | export class AppModule {} 9 | -------------------------------------------------------------------------------- /sample/01-cats-app/src/cats/cats.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsController } from './cats.controller'; 3 | import { CatsService } from './cats.service'; 4 | 5 | @Module({ 6 | controllers: [CatsController], 7 | providers: [CatsService], 8 | }) 9 | export class CatsModule {} 10 | -------------------------------------------------------------------------------- /sample/01-cats-app/src/cats/dto/create-cat.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsInt, IsString } from 'class-validator'; 2 | 3 | export class CreateCatDto { 4 | @IsString() 5 | readonly name: string; 6 | 7 | @IsInt() 8 | readonly age: number; 9 | 10 | @IsString() 11 | readonly breed: string; 12 | } 13 | -------------------------------------------------------------------------------- /sample/01-cats-app/src/cats/interfaces/cat.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Cat { 2 | name: string; 3 | age: number; 4 | breed: string; 5 | } 6 | -------------------------------------------------------------------------------- /sample/01-cats-app/src/common/decorators/roles.decorator.ts: -------------------------------------------------------------------------------- 1 | import { Reflector } from '@nestjs/core'; 2 | 3 | export const Roles = Reflector.createDecorator(); 4 | -------------------------------------------------------------------------------- /sample/01-cats-app/src/common/middleware/logger.middleware.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, NestMiddleware } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class LoggerMiddleware implements NestMiddleware { 5 | use(req: any, res: any, next: () => void) { 6 | console.log(`Request...`); 7 | next(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/01-cats-app/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/02-gateways/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/02-gateways/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { EventsModule } from './events/events.module'; 3 | 4 | @Module({ 5 | imports: [EventsModule], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /sample/02-gateways/src/events/events.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { EventsGateway } from './events.gateway'; 3 | 4 | @Module({ 5 | providers: [EventsGateway], 6 | }) 7 | export class EventsModule {} 8 | -------------------------------------------------------------------------------- /sample/02-gateways/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/03-microservices/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/03-microservices/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { MathModule } from './math/math.module'; 3 | 4 | @Module({ 5 | imports: [MathModule], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /sample/03-microservices/src/math/math.constants.ts: -------------------------------------------------------------------------------- 1 | export const MATH_SERVICE = 'MATH_SERVICE'; 2 | -------------------------------------------------------------------------------- /sample/03-microservices/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/04-grpc/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/04-grpc/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "assets": ["**/*.proto"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sample/04-grpc/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { HeroModule } from './hero/hero.module'; 3 | 4 | @Module({ 5 | imports: [HeroModule], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /sample/04-grpc/src/hero/hero.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package hero; 4 | 5 | service HeroesService { 6 | rpc FindOne (HeroById) returns (Hero); 7 | rpc FindMany (stream HeroById) returns (stream Hero); 8 | } 9 | 10 | message HeroById { 11 | int32 id = 1; 12 | } 13 | 14 | message Hero { 15 | int32 id = 1; 16 | string name = 2; 17 | } 18 | -------------------------------------------------------------------------------- /sample/04-grpc/src/hero/interfaces/hero-by-id.interface.ts: -------------------------------------------------------------------------------- 1 | export interface HeroById { 2 | id: number; 3 | } 4 | -------------------------------------------------------------------------------- /sample/04-grpc/src/hero/interfaces/hero.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Hero { 2 | id: number; 3 | name: string; 4 | } 5 | -------------------------------------------------------------------------------- /sample/04-grpc/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/05-sql-typeorm/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /coverage 17 | /.nyc_output 18 | 19 | # dist 20 | /dist -------------------------------------------------------------------------------- /sample/05-sql-typeorm/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/05-sql-typeorm/src/users/dto/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateUserDto { 2 | firstName: string; 3 | lastName: string; 4 | } 5 | -------------------------------------------------------------------------------- /sample/05-sql-typeorm/src/users/user.entity.ts: -------------------------------------------------------------------------------- 1 | import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; 2 | 3 | @Entity() 4 | export class User { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | firstName: string; 10 | 11 | @Column() 12 | lastName: string; 13 | 14 | @Column({ default: true }) 15 | isActive: boolean; 16 | } 17 | -------------------------------------------------------------------------------- /sample/05-sql-typeorm/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/05-sql-typeorm/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/06-mongoose/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/06-mongoose/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | mongodb: 5 | image: mongo:latest 6 | environment: 7 | - MONGODB_DATABASE="test" 8 | ports: 9 | - 27017:27017 -------------------------------------------------------------------------------- /sample/06-mongoose/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { MongooseModule } from '@nestjs/mongoose'; 3 | import { CatsModule } from './cats/cats.module'; 4 | 5 | @Module({ 6 | imports: [ 7 | MongooseModule.forRoot('mongodb://localhost:27017/test'), 8 | CatsModule, 9 | ], 10 | }) 11 | export class AppModule {} 12 | -------------------------------------------------------------------------------- /sample/06-mongoose/src/cats/dto/create-cat.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateCatDto { 2 | readonly name: string; 3 | readonly age: number; 4 | readonly breed: string; 5 | } 6 | -------------------------------------------------------------------------------- /sample/06-mongoose/src/cats/dto/update-cat.dto.ts: -------------------------------------------------------------------------------- 1 | export class UpdateCatDto { 2 | readonly name?: string; 3 | readonly age?: number; 4 | readonly breed?: string; 5 | } 6 | -------------------------------------------------------------------------------- /sample/06-mongoose/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/06-mongoose/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/07-sequelize/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/07-sequelize/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | mysql: 5 | image: mysql:9 6 | restart: always 7 | environment: 8 | MYSQL_ROOT_PASSWORD: root 9 | MYSQL_DATABASE: test 10 | ports: 11 | - "3306:3306" 12 | -------------------------------------------------------------------------------- /sample/07-sequelize/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/07-sequelize/src/users/dto/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateUserDto { 2 | firstName: string; 3 | lastName: string; 4 | } 5 | -------------------------------------------------------------------------------- /sample/07-sequelize/src/users/models/user.model.ts: -------------------------------------------------------------------------------- 1 | import { Column, Model, Table } from 'sequelize-typescript'; 2 | 3 | @Table 4 | export class User extends Model { 5 | @Column 6 | firstName: string; 7 | 8 | @Column 9 | lastName: string; 10 | 11 | @Column({ defaultValue: true }) 12 | isActive: boolean; 13 | } 14 | -------------------------------------------------------------------------------- /sample/07-sequelize/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/08-webpack/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/08-webpack/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "deleteOutDir": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sample/08-webpack/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/08-webpack/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | @Module({ 6 | imports: [], 7 | controllers: [AppController], 8 | providers: [AppService], 9 | }) 10 | export class AppModule {} 11 | -------------------------------------------------------------------------------- /sample/08-webpack/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello() { 6 | return 'Hello world!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/08-webpack/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/09-babel-example/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"], 3 | "plugins": [ 4 | ["@babel/plugin-proposal-decorators", { "legacy": true }], 5 | [ 6 | "@babel/plugin-transform-runtime", 7 | { 8 | "regenerator": true 9 | } 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /sample/09-babel-example/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/09-babel-example/index.js: -------------------------------------------------------------------------------- 1 | require('@babel/register'); 2 | require('./src/main'); 3 | -------------------------------------------------------------------------------- /sample/09-babel-example/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "experimentalDecorators": true 5 | }, 6 | "exclude": [ 7 | "node_modules" 8 | ] 9 | } -------------------------------------------------------------------------------- /sample/09-babel-example/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "js", 4 | "ignore": ["src/**/*.spec.js"], 5 | "exec": "node index --exec babel-node" 6 | } 7 | -------------------------------------------------------------------------------- /sample/09-babel-example/src/app.module.js: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsModule } from './cats/cats.module'; 3 | 4 | @Module({ 5 | imports: [CatsModule], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /sample/09-babel-example/src/cats/cats.module.js: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsController } from './cats.controller'; 3 | import { CatsService } from './cats.service'; 4 | 5 | @Module({ 6 | controllers: [CatsController], 7 | providers: [CatsService], 8 | }) 9 | export class CatsModule {} 10 | -------------------------------------------------------------------------------- /sample/09-babel-example/src/cats/cats.service.js: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class CatsService { 5 | constructor() { 6 | this.cats = []; 7 | } 8 | 9 | create(cat) { 10 | this.cats.push(cat); 11 | } 12 | 13 | findAll() { 14 | return this.cats; 15 | } 16 | } -------------------------------------------------------------------------------- /sample/09-babel-example/src/main.js: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/10-fastify/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/10-fastify/README.md: -------------------------------------------------------------------------------- 1 | ### Fastify sample 2 | 3 | Note that if you are running the Nest app on a remote machine, you may need to change the listen address, as per [these instructions](https://docs.nestjs.com/techniques/performance#adapter): 4 | 5 | `await app.listen(3000, '0.0.0.0')` -------------------------------------------------------------------------------- /sample/10-fastify/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsModule } from './cats/cats.module'; 3 | import { CoreModule } from './core/core.module'; 4 | 5 | @Module({ 6 | imports: [CatsModule, CoreModule], 7 | }) 8 | export class AppModule {} 9 | -------------------------------------------------------------------------------- /sample/10-fastify/src/cats/cats.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsController } from './cats.controller'; 3 | import { CatsService } from './cats.service'; 4 | 5 | @Module({ 6 | controllers: [CatsController], 7 | providers: [CatsService], 8 | }) 9 | export class CatsModule {} 10 | -------------------------------------------------------------------------------- /sample/10-fastify/src/cats/dto/create-cat.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsInt, IsString } from 'class-validator'; 2 | 3 | export class CreateCatDto { 4 | @IsString() 5 | readonly name: string; 6 | 7 | @IsInt() 8 | readonly age: number; 9 | 10 | @IsString() 11 | readonly breed: string; 12 | } 13 | -------------------------------------------------------------------------------- /sample/10-fastify/src/cats/interfaces/cat.interface.ts: -------------------------------------------------------------------------------- 1 | export interface Cat { 2 | readonly name: string; 3 | readonly age: number; 4 | readonly breed: string; 5 | } 6 | -------------------------------------------------------------------------------- /sample/10-fastify/src/common/decorators/roles.decorator.ts: -------------------------------------------------------------------------------- 1 | import { SetMetadata } from '@nestjs/common'; 2 | 3 | export const Roles = (...roles: string[]) => SetMetadata('roles', roles); 4 | -------------------------------------------------------------------------------- /sample/10-fastify/src/common/middleware/logger.middleware.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, NestMiddleware } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class LoggerMiddleware implements NestMiddleware { 5 | use(req: any, res: any, next: () => void) { 6 | console.log(`Request...`); 7 | next(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/10-fastify/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/11-swagger/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/11-swagger/README.md: -------------------------------------------------------------------------------- 1 | ### Swagger sample 2 | 3 | ### Installation 4 | 5 | `npm install` 6 | 7 | ### Running 8 | 9 | Once the application is running you can visit [http://localhost:3000/api](http://localhost:3000/api) to see the Swagger interface. 10 | 11 | See [here](https://docs.nestjs.com/recipes/swagger#bootstrap) for more information. -------------------------------------------------------------------------------- /sample/11-swagger/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "plugins": [ 4 | { 5 | "name": "@nestjs/swagger", 6 | "options": { 7 | "introspectComments": true 8 | } 9 | } 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/11-swagger/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsModule } from './cats/cats.module'; 3 | 4 | @Module({ 5 | imports: [CatsModule], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /sample/11-swagger/src/cats/cats.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsController } from './cats.controller'; 3 | import { CatsService } from './cats.service'; 4 | 5 | @Module({ 6 | controllers: [CatsController], 7 | providers: [CatsService], 8 | }) 9 | export class CatsModule {} 10 | -------------------------------------------------------------------------------- /sample/11-swagger/src/cats/dto/create-cat.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsInt, IsString } from 'class-validator'; 2 | 3 | export class CreateCatDto { 4 | @IsString() 5 | readonly name: string; 6 | 7 | @IsInt() 8 | readonly age: number; 9 | 10 | @IsString() 11 | readonly breed: string; 12 | } 13 | -------------------------------------------------------------------------------- /sample/11-swagger/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/12-graphql-schema-first/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/12-graphql-schema-first/README.md: -------------------------------------------------------------------------------- 1 | ### Graphql Apollo sample 2 | 3 | ### Installation 4 | 5 | `npm install` 6 | 7 | ### Graphql Playground 8 | 9 | When the application is running, you can go to [http://localhost:3000/graphql](http://localhost:3000/graphql) to access the GraphQL Playground. See [here](https://docs.nestjs.com/graphql/quick-start#playground) for more. -------------------------------------------------------------------------------- /sample/12-graphql-schema-first/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "assets": ["**/*.graphql"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sample/12-graphql-schema-first/src/owners/owners.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { OwnersService } from './owners.service'; 3 | 4 | @Module({ 5 | providers: [OwnersService], 6 | exports: [OwnersService], 7 | }) 8 | export class OwnersModule {} 9 | -------------------------------------------------------------------------------- /sample/12-graphql-schema-first/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/13-mongo-typeorm/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/13-mongo-typeorm/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | mongodb: 5 | image: mongo:8.0 6 | environment: 7 | - MONGODB_DATABASE="test" 8 | ports: 9 | - 27017:27017 -------------------------------------------------------------------------------- /sample/13-mongo-typeorm/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/13-mongo-typeorm/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/14-mongoose-base/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | mongodb: 5 | image: mongo:latest 6 | environment: 7 | - MONGODB_DATABASE="test" 8 | ports: 9 | - 27017:27017 -------------------------------------------------------------------------------- /sample/14-mongoose-base/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CatsModule } from './cats/cats.module'; 3 | 4 | @Module({ 5 | imports: [CatsModule], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/src/cats/cats.providers.ts: -------------------------------------------------------------------------------- 1 | import { Mongoose } from 'mongoose'; 2 | import { CatSchema } from './schemas/cat.schema'; 3 | 4 | export const catsProviders = [ 5 | { 6 | provide: 'CAT_MODEL', 7 | useFactory: (mongoose: Mongoose) => mongoose.model('Cat', CatSchema), 8 | inject: ['DATABASE_CONNECTION'], 9 | }, 10 | ]; 11 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/src/cats/dto/create-cat.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateCatDto { 2 | readonly name: string; 3 | readonly age: number; 4 | readonly breed: string; 5 | } 6 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/src/cats/interfaces/cat.interface.ts: -------------------------------------------------------------------------------- 1 | import { Document } from 'mongoose'; 2 | 3 | export interface Cat extends Document { 4 | readonly name: string; 5 | readonly age: number; 6 | readonly breed: string; 7 | } 8 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/src/cats/schemas/cat.schema.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from 'mongoose'; 2 | 3 | export const CatSchema = new mongoose.Schema({ 4 | name: String, 5 | age: Number, 6 | breed: String, 7 | }); 8 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/src/database/database.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { databaseProviders } from './database.providers'; 3 | 4 | @Module({ 5 | providers: [...databaseProviders], 6 | exports: [...databaseProviders], 7 | }) 8 | export class DatabaseModule {} 9 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/src/database/database.providers.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from 'mongoose'; 2 | 3 | export const databaseProviders = [ 4 | { 5 | provide: 'DATABASE_CONNECTION', 6 | useFactory: async (): Promise => 7 | await mongoose.connect('mongodb://localhost/test'), 8 | }, 9 | ]; 10 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/14-mongoose-base/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/15-mvc/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/15-mvc/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "ts", 4 | "ignore": ["src/**/*.spec.ts"], 5 | "exec": "ts-node ./src/main" 6 | } 7 | -------------------------------------------------------------------------------- /sample/15-mvc/public/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codev612/nestjs/0e5bf68e7a60a31138f5f3c839c492df01f1a0a2/sample/15-mvc/public/.gitkeep -------------------------------------------------------------------------------- /sample/15-mvc/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Render } from '@nestjs/common'; 2 | 3 | @Controller() 4 | export class AppController { 5 | @Get() 6 | @Render('index') 7 | root() { 8 | return { message: 'Hello world!' }; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /sample/15-mvc/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | 4 | @Module({ 5 | imports: [], 6 | controllers: [AppController], 7 | providers: [], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /sample/15-mvc/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/15-mvc/views/index.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | App 7 | 8 | 9 | 10 | {{ message }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample/16-gateways-ws/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/16-gateways-ws/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { EventsModule } from './events/events.module'; 3 | 4 | @Module({ 5 | imports: [EventsModule], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /sample/16-gateways-ws/src/events/events.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { EventsGateway } from './events.gateway'; 3 | 4 | @Module({ 5 | providers: [EventsGateway], 6 | }) 7 | export class EventsModule {} 8 | -------------------------------------------------------------------------------- /sample/16-gateways-ws/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/17-mvc-fastify/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/17-mvc-fastify/README.md: -------------------------------------------------------------------------------- 1 | ### Fastify MVC sample 2 | 3 | Note that if you are running the Nest app on a remote machine, you may need to change the listen address, as per [these instructions](https://docs.nestjs.com/techniques/performance#adapter): 4 | 5 | `await app.listen(3000, '0.0.0.0')` -------------------------------------------------------------------------------- /sample/17-mvc-fastify/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "ts", 4 | "ignore": ["src/**/*.spec.ts"], 5 | "exec": "ts-node ./src/main" 6 | } 7 | -------------------------------------------------------------------------------- /sample/17-mvc-fastify/public/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codev612/nestjs/0e5bf68e7a60a31138f5f3c839c492df01f1a0a2/sample/17-mvc-fastify/public/.gitkeep -------------------------------------------------------------------------------- /sample/17-mvc-fastify/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Get, Controller, Render } from '@nestjs/common'; 2 | 3 | @Controller() 4 | export class AppController { 5 | @Get() 6 | @Render('index.hbs') 7 | root() { 8 | return { message: 'Hello world!' }; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /sample/17-mvc-fastify/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | 4 | @Module({ 5 | imports: [], 6 | controllers: [AppController], 7 | providers: [], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /sample/17-mvc-fastify/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/17-mvc-fastify/views/index.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | App 7 | 8 | 9 | 10 | {{ message }} 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample/18-context/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/18-context/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello world!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/18-context/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "ts", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src" 5 | } 6 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/nodemon-debug.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "ts", 4 | "ignore": ["src/**/*.spec.ts"], 5 | "exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register src/main.ts" 6 | } 7 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["dist"], 3 | "ext": "js", 4 | "exec": "node dist/main" 5 | } 6 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller } from '@nestjs/common'; 2 | 3 | @Controller() 4 | export class AppController {} 5 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/src/auth/constants.ts: -------------------------------------------------------------------------------- 1 | export const jwtConstants = { 2 | secret: 3 | 'DO NOT USE THIS VALUE. INSTEAD, CREATE A COMPLEX SECRET AND KEEP IT SAFE OUTSIDE OF THE SOURCE CODE.', 4 | }; 5 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/src/auth/decorators/public.decorator.ts: -------------------------------------------------------------------------------- 1 | import { SetMetadata } from '@nestjs/common'; 2 | 3 | export const IS_PUBLIC_KEY = 'isPublic'; 4 | export const Public = () => SetMetadata(IS_PUBLIC_KEY, true); 5 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/src/users/users.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UsersService } from './users.service'; 3 | 4 | @Module({ 5 | providers: [UsersService], 6 | exports: [UsersService], 7 | }) 8 | export class UsersModule {} 9 | -------------------------------------------------------------------------------- /sample/19-auth-jwt/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/20-cache/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/20-cache/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { CacheModule } from '@nestjs/cache-manager'; 2 | import { Module } from '@nestjs/common'; 3 | import { AppController } from './app.controller'; 4 | 5 | @Module({ 6 | imports: [CacheModule.register()], 7 | controllers: [AppController], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /sample/20-cache/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/21-serializer/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/21-serializer/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | 4 | @Module({ 5 | controllers: [AppController], 6 | }) 7 | export class AppModule {} 8 | -------------------------------------------------------------------------------- /sample/21-serializer/src/entities/role.entity.ts: -------------------------------------------------------------------------------- 1 | export class RoleEntity { 2 | id: number; 3 | name: string; 4 | 5 | constructor(partial: Partial) { 6 | Object.assign(this, partial); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/21-serializer/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/22-graphql-prisma/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist 22 | 23 | # database 24 | prisma/dev.db 25 | 26 | # secrets 27 | .env -------------------------------------------------------------------------------- /sample/22-graphql-prisma/generate-typings.ts: -------------------------------------------------------------------------------- 1 | import { GraphQLDefinitionsFactory } from '@nestjs/graphql'; 2 | import { join } from 'path'; 3 | 4 | const definitionsFactory = new GraphQLDefinitionsFactory(); 5 | definitionsFactory.generate({ 6 | typePaths: ['./src/**/*.graphql'], 7 | path: join(process.cwd(), 'src/graphql.schema.ts'), 8 | outputAs: 'class', 9 | }); 10 | -------------------------------------------------------------------------------- /sample/22-graphql-prisma/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "assets": ["**/*.graphql"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sample/22-graphql-prisma/src/prisma/prisma.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PrismaService } from './prisma.service'; 3 | 4 | @Module({ 5 | providers: [PrismaService], 6 | exports: [PrismaService], 7 | }) 8 | export class PrismaModule {} 9 | -------------------------------------------------------------------------------- /sample/22-graphql-prisma/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/23-graphql-code-first/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/23-graphql-code-first/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "plugins": [ 4 | { 5 | "name": "@nestjs/graphql", 6 | "options": { 7 | "introspectComments": true 8 | } 9 | } 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/23-graphql-code-first/src/recipes/dto/recipes.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | import { Max, Min } from 'class-validator'; 3 | 4 | @ArgsType() 5 | export class RecipesArgs { 6 | @Field(type => Int) 7 | @Min(0) 8 | skip = 0; 9 | 10 | @Field(type => Int) 11 | @Min(1) 12 | @Max(50) 13 | take = 25; 14 | } 15 | -------------------------------------------------------------------------------- /sample/23-graphql-code-first/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/24-serve-static/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/24-serve-static/client/index.html: -------------------------------------------------------------------------------- 1 | 2 |

Static website

3 | 8 | -------------------------------------------------------------------------------- /sample/24-serve-static/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | @Controller() 4 | export class AppController { 5 | @Get() 6 | getHello() { 7 | return 'Hello, world!'; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/24-serve-static/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/25-dynamic-modules/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/25-dynamic-modules/config/development.env: -------------------------------------------------------------------------------- 1 | HELLO_MESSAGE = 'Hello there, world!' -------------------------------------------------------------------------------- /sample/25-dynamic-modules/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "ts", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src" 5 | } 6 | -------------------------------------------------------------------------------- /sample/25-dynamic-modules/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/25-dynamic-modules/src/config/constants.ts: -------------------------------------------------------------------------------- 1 | export const CONFIG_OPTIONS = 'CONFIG_OPTIONS'; 2 | -------------------------------------------------------------------------------- /sample/25-dynamic-modules/src/config/interfaces/config-options.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ConfigOptions { 2 | folder: string; 3 | } 4 | -------------------------------------------------------------------------------- /sample/25-dynamic-modules/src/config/interfaces/envconfig.interface.ts: -------------------------------------------------------------------------------- 1 | export interface EnvConfig { 2 | [key: string]: string; 3 | } 4 | -------------------------------------------------------------------------------- /sample/25-dynamic-modules/src/config/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './envconfig.interface'; 2 | export * from './config-options.interface'; 3 | -------------------------------------------------------------------------------- /sample/25-dynamic-modules/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/25-dynamic-modules/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/26-queues/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/26-queues/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | redis: 4 | image: redis:alpine 5 | ports: 6 | - 6379:6379 7 | -------------------------------------------------------------------------------- /sample/26-queues/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "ts", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src" 5 | } 6 | -------------------------------------------------------------------------------- /sample/26-queues/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/26-queues/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/26-queues/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/26-queues/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/27-scheduling/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/27-scheduling/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "ts", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src" 5 | } 6 | -------------------------------------------------------------------------------- /sample/27-scheduling/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/27-scheduling/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/27-scheduling/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | console.log(`Application is running on: ${await app.getUrl()}`); 8 | } 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /sample/27-scheduling/src/tasks/tasks.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TasksService } from './tasks.service'; 3 | 4 | @Module({ 5 | providers: [TasksService], 6 | }) 7 | export class TasksModule {} 8 | -------------------------------------------------------------------------------- /sample/27-scheduling/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/28-sse/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/28-sse/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "assets": ["**/*.html"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sample/28-sse/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | 4 | @Module({ 5 | imports: [], 6 | controllers: [AppController], 7 | providers: [], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /sample/28-sse/src/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sample/28-sse/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/29-file-upload/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # tests 13 | /test 14 | /coverage 15 | /.nyc_output 16 | 17 | # dist 18 | /dist -------------------------------------------------------------------------------- /sample/29-file-upload/README.md: -------------------------------------------------------------------------------- 1 | # File Upload 2 | 3 | A simple example of file upload 4 | 5 | ## Execution 6 | 7 | ```sh 8 | npm run start # OR npm run start:dev 9 | # in another terminal 10 | curl http://localhost:3000/file -F 'file=@./package.json' -F 'name=test' 11 | ``` -------------------------------------------------------------------------------- /sample/29-file-upload/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | @Module({ 6 | controllers: [AppController], 7 | providers: [AppService], 8 | }) 9 | export class AppModule {} 10 | -------------------------------------------------------------------------------- /sample/29-file-upload/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello() { 6 | return { hello: 'world' }; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/29-file-upload/src/sample.dto.ts: -------------------------------------------------------------------------------- 1 | export class SampleDto { 2 | name: string; 3 | } 4 | -------------------------------------------------------------------------------- /sample/29-file-upload/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/30-event-emitter/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/30-event-emitter/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /sample/30-event-emitter/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello() { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/30-event-emitter/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/30-event-emitter/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/30-event-emitter/src/orders/dto/create-order.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateOrderDto { 2 | name: string; 3 | description: string; 4 | } 5 | -------------------------------------------------------------------------------- /sample/30-event-emitter/src/orders/entities/order.entity.ts: -------------------------------------------------------------------------------- 1 | export class Order { 2 | id: number; 3 | name: string; 4 | description: string; 5 | } 6 | -------------------------------------------------------------------------------- /sample/30-event-emitter/src/orders/events/order-created.event.ts: -------------------------------------------------------------------------------- 1 | export class OrderCreatedEvent { 2 | name: string; 3 | description: string; 4 | } 5 | -------------------------------------------------------------------------------- /sample/30-event-emitter/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/30-event-emitter/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/gateway/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/gateway/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/gateway/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/gateway/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3001); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/gateway/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/posts-application/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/posts-application/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/posts-application/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/posts-application/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3003); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/posts-application/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/users-application/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/users-application/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/users-application/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/users-application/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3002); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/users-application/src/users/models/user.model.ts: -------------------------------------------------------------------------------- 1 | import { Directive, Field, ID, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | @Directive('@key(fields: "id")') 5 | export class User { 6 | @Field((type) => ID) 7 | id: number; 8 | 9 | @Field() 10 | name: string; 11 | } 12 | -------------------------------------------------------------------------------- /sample/31-graphql-federation-code-first/users-application/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/gateway/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/gateway/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/gateway/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/gateway/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3002); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/gateway/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/posts-application/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/posts-application/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/posts-application/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/posts-application/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3001); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/posts-application/src/posts/posts.interfaces.ts: -------------------------------------------------------------------------------- 1 | import { Directive, Field, ID, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | export interface Post { 4 | id: number; 5 | title: string; 6 | authorId: number; 7 | } 8 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/posts-application/src/posts/users.interfaces.ts: -------------------------------------------------------------------------------- 1 | import { Post } from './posts.interfaces'; 2 | 3 | export interface User { 4 | id: number; 5 | posts?: Post[]; 6 | } 7 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/posts-application/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/users-application/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/users-application/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/users-application/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/users-application/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/users-application/src/users/models/user.model.ts: -------------------------------------------------------------------------------- 1 | import { Directive, Field, ID, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | @Directive('@key(fields: "id")') 5 | export class User { 6 | @Field((type) => ID) 7 | id: number; 8 | 9 | @Field() 10 | name: string; 11 | } 12 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/users-application/src/users/users.graphql: -------------------------------------------------------------------------------- 1 | type User @key(fields: "id") { 2 | id: ID! 3 | name: String! 4 | } 5 | 6 | extend type Query { 7 | getUser(id: ID!): User 8 | } 9 | -------------------------------------------------------------------------------- /sample/32-graphql-federation-schema-first/users-application/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/33-graphql-mercurius/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # IDE 5 | /.idea 6 | /.awcache 7 | /.vscode 8 | 9 | # misc 10 | npm-debug.log 11 | 12 | # example 13 | /quick-start 14 | 15 | # tests 16 | /test 17 | /coverage 18 | /.nyc_output 19 | 20 | # dist 21 | /dist -------------------------------------------------------------------------------- /sample/33-graphql-mercurius/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "plugins": [ 4 | { 5 | "name": "@nestjs/graphql", 6 | "options": { 7 | "introspectComments": true 8 | } 9 | } 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/33-graphql-mercurius/src/recipes/dto/recipes.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field, Int } from '@nestjs/graphql'; 2 | import { Max, Min } from 'class-validator'; 3 | 4 | @ArgsType() 5 | export class RecipesArgs { 6 | @Field(type => Int) 7 | @Min(0) 8 | skip = 0; 9 | 10 | @Field(type => Int) 11 | @Min(1) 12 | @Max(50) 13 | take = 25; 14 | } 15 | -------------------------------------------------------------------------------- /sample/33-graphql-mercurius/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/34-using-esm-packages/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/34-using-esm-packages/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src", 5 | "compilerOptions": { 6 | "deleteOutDir": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/34-using-esm-packages/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello() { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/34-using-esm-packages/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/34-using-esm-packages/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/34-using-esm-packages/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /sample/35-use-esm-package-after-node22/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /sample/35-use-esm-package-after-node22/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src", 5 | "compilerOptions": { 6 | "deleteOutDir": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sample/35-use-esm-package-after-node22/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | @Module({ 6 | imports: [], 7 | controllers: [AppController], 8 | providers: [AppService], 9 | }) 10 | export class AppModule {} 11 | -------------------------------------------------------------------------------- /sample/35-use-esm-package-after-node22/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import superjson from 'superjson'; 3 | 4 | @Injectable() 5 | export class AppService { 6 | getJsonStringExample() { 7 | const jsonString = superjson.stringify({ big: 10n }); 8 | 9 | return { 10 | jsonString, 11 | }; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sample/35-use-esm-package-after-node22/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /sample/35-use-esm-package-after-node22/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /scripts/prepare.sh: -------------------------------------------------------------------------------- 1 | # 1. Build fresh packages and move them to sample and integration directories 2 | npm run build &>/dev/null 3 | 4 | # 2. Start docker containers to perform integration tests 5 | npm run test:docker:up -------------------------------------------------------------------------------- /scripts/run-integration.sh: -------------------------------------------------------------------------------- 1 | # 1. Build fresh packages and move them integration dit 2 | npm run build &>/dev/null 3 | 4 | # 2. Start docker containers to perform integration tests 5 | npm run test:docker:up 6 | 7 | # 3. Run integration tests 8 | npm run test:integration -------------------------------------------------------------------------------- /scripts/test.sh: -------------------------------------------------------------------------------- 1 | # Run both unit and integration tests 2 | npm run test 3 | npm run test:integration -------------------------------------------------------------------------------- /scripts/update-samples.sh: -------------------------------------------------------------------------------- 1 | for d in ./sample/*/ ; do (cd "$d" && printf $d\\n && ncu -u && npm i --package-lock-only); done -------------------------------------------------------------------------------- /tools/gulp/config.ts: -------------------------------------------------------------------------------- 1 | import { getDirs } from './util/task-helpers'; 2 | 3 | // All paths are related to the base dir 4 | export const source = 'packages'; 5 | export const samplePath = 'sample'; 6 | 7 | export const packagePaths = getDirs(source); 8 | -------------------------------------------------------------------------------- /tools/gulp/gulpfile.ts: -------------------------------------------------------------------------------- 1 | import './tasks/clean'; 2 | import './tasks/copy-misc'; 3 | import './tasks/move'; 4 | import './tasks/samples'; 5 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["integration/**/*", "**/*.spec.ts"], 4 | "exclude": ["node_modules", "dist"] 5 | } --------------------------------------------------------------------------------