{"id":15288950,"url":"https://github.com/mridang/nestjs-defaults","last_synced_at":"2025-04-13T08:11:49.896Z","repository":{"id":257779499,"uuid":"859850427","full_name":"mridang/nestjs-defaults","owner":"mridang","description":"An opinionated setup for NestJS","archived":false,"fork":false,"pushed_at":"2025-02-05T05:09:09.000Z","size":1609,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-13T08:11:35.705Z","etag":null,"topics":["defaults","nestjs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@mridang/nestjs-defaults","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mridang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-19T11:45:32.000Z","updated_at":"2025-02-05T05:09:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"6d9f748c-d699-478f-9de3-8f4395be1075","html_url":"https://github.com/mridang/nestjs-defaults","commit_stats":null,"previous_names":["mridang/nestjs-defaults"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fnestjs-defaults","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fnestjs-defaults/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fnestjs-defaults/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fnestjs-defaults/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mridang","download_url":"https://codeload.github.com/mridang/nestjs-defaults/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681497,"owners_count":21144700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["defaults","nestjs"],"created_at":"2024-09-30T15:54:50.608Z","updated_at":"2025-04-13T08:11:49.873Z","avatar_url":"https://github.com/mridang.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"A set of opinionated defaults for the the NestJS framework.\n\n\u003e [!NOTE]\n\u003e This plugin has only been is designed for use with the Express tranport. It\n\u003e also assumes that you are using Sentry and deploying this to AWS.\n\nHere are some of the notable features of this library:\n\n- Enables the built-in validator at the application level, thus ensuring all endpoints are protected from receiving incorrect data.\n  https://docs.nestjs.com/techniques/validation\n- Secures the application by using Helmet by setting the necessary HTTP response headers.\n- Configures the handlebars templating engine https://docs.nestjs.com/techniques/mvc\n- Configures the cookie-parsing middleware to make it easier to read and write cookies https://docs.nestjs.com/techniques/cookies\n- Enables CORS support https://docs.nestjs.com/security/cors\n- Enables network error logging so that client-side errors can be tracked https://web.dev/articles/network-error-logging\n- Wires up Sentry so that all exceptions are reported to Sentry\n  https://docs.sentry.io/platforms/javascript/guides/node/\n- Configures the logger to write log messages using the Elastic Common Schema\n  https://www.elastic.co/guide/en/ecs/current/index.html\n- Configures a exception handler that shows pretty error pages for all 4/5xx errors\n- Configures a robots.txt endpoint that disallows all crawling and indexing\n- Configures the serving of static assets https://docs.nestjs.com/recipes/serve-static\n- Configures a health-check endpoint like Terminus https://docs.nestjs.com/recipes/terminus\n- Exports a mechanism for using Preact for SSR\n\n## Installation\n\nInstall using NPM by using the following command\n\n```sh\nnpm install --save-dev @mridang/nestjs-defaults\n```\n\n## Usage\n\nWiring this library comprises of two parts - configuring the NestJS application\nand configuring the Express transport.\n\nTo correctly leverage this library, you must use both.\n\n### Importing the exported module\n\nThe library exposes a module that should be imported in the root module.\nImporting that module will configure all the necessary defaults. The module\nrequires that you specify the name of an AWS Secrets Manager configuration.\n\n```\nimport { Global, Module } from '@nestjs/common';\nimport { DefaultsModule } from '@mridang/nestjs-defaults';\n\n@Global()\n@Module({\n  imports: [\n    DefaultsModule.register({\n      configName: 'shush',\n    }),\n  ],\n})\nexport class AppModule {\n  //\n}\n```\n\n### Configuring the NestJS application\n\nThe library also provides a `configure` convenience method that can be used for\nsetting up the transport e.g. the Handlebars templating engine, support for\nparsing cookies, validation, etc.\n\n```\nimport { NestFactory } from '@nestjs/core';\nimport { AppModule } from './app.module';\nimport { NestExpressApplication } from '@nestjs/platform-express';\nimport { ClsService } from 'nestjs-cls';\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport compression from 'compression';\nimport { BetterLogger, configure } from '@mridang/nestjs-defaults';\n\nasync function bootstrap() {\n  const nestApp = await NestFactory.create\u003cNestExpressApplication\u003e(AppModule, {\n    rawBody: true,\n    logger: new BetterLogger(new ClsService(new AsyncLocalStorage())),\n  });\n\n  configure(nestApp, __dirname);\n  nestApp.use(compression());\n  await nestApp.init();\n  await nestApp.listen(3000);\n}\n\nbootstrap();\n```\n\n## Contributing\n\nIf you have suggestions for how this library could be improved, or\nwant to report a bug, open an issue - I'd love all and any\ncontributions.\n\n## License\n\nApache License 2.0 © 2024 Mridang Agarwalla\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmridang%2Fnestjs-defaults","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmridang%2Fnestjs-defaults","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmridang%2Fnestjs-defaults/lists"}