Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/micalevisk/nestjs-devtools-loader
A tiny dependency-free helper package to easily enable/disable NestJS DevTools (@nestjs/devtools-integration).
https://github.com/micalevisk/nestjs-devtools-loader
hacktoberfest nest nestjs nestjs-devtools nodejs
Last synced: 3 months ago
JSON representation
A tiny dependency-free helper package to easily enable/disable NestJS DevTools (@nestjs/devtools-integration).
- Host: GitHub
- URL: https://github.com/micalevisk/nestjs-devtools-loader
- Owner: micalevisk
- Created: 2023-03-10T23:54:05.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T13:49:59.000Z (6 months ago)
- Last Synced: 2024-09-18T11:03:12.272Z (4 months ago)
- Topics: hacktoberfest, nest, nestjs, nestjs-devtools, nodejs
- Language: JavaScript
- Homepage: https://dev.to/micalevisk/enabledisable-nestjs-devtools-integration-without-changing-your-code-5dd9
- Size: 378 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `nestjs-devtools-loader`
[![npm version](https://img.shields.io/npm/v/nestjs-devtools-loader.svg)](https://www.npmjs.com/package/nestjs-devtools-loader)
[![npm downloads](https://img.shields.io/npm/dt/nestjs-devtools-loader.svg)](https://www.npmjs.com/package/nestjs-devtools-loader)A helper package to easily enable/disable [NestJS Devtools](https://docs.nestjs.com/devtools/overview) integration!
### What it does
1. Add `snapshot` to `true` for `NestFactory.create` call
2. Import `DevtoolsModule.register({ http: true, port: 8000 })` into the module passed to the `NestFactory.create` call if it was not imported alreadythat reduces the amount of boilerplate code you would have to write and
also allows us to not import that `DevtoolsModule` with no effort.### Install
You must have `@nestjs/core` (v9.3 or greater), `@nestjs/devtools-integration` and `reflect-metadata` installed!
```bash
npm install --save-dev nestjs-devtools-loader
```### Usage
#### Via preload module
You need to supply the `--require nestjs-devtools-loader/register` option to `node`
With NestJS's CLI, you can do:```bash
nest start --exec "node -r nestjs-devtools-loader/register"
# ^~ an alias to --require
```If you want to change the default options that are supplied to `DevtoolsModule.register()`, use the environment variable: `NESTJS_DEVTOOLS_LOADER` like this:
```
NESTJS_DEVTOOLS_LOADER='{"http":true,"port":3001}'
```#### Programmatically
```ts
import { loader } from 'nestjs-devtools-loader'
// ...
// Before calling `NestFactory.create()`:
loader({ http: true, port: 8000 })
```#### Disable
If you want to disable the loader while still injecting it into your app, set the environment variable `NESTJS_DEVTOOLS_LOADER_DISABLED` to `"true"`
#### Debug
If the env. var. `DEBUG` contains the string `"nestjs-devtools-loader"` like:
`DEBUG=nestjs-devtools-loader`
you'll see if the loader was injected or not.