nestjs-security-cli 1.3.6 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +37 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ npm install nestjs-security-cli
11
11
  ## Quick Start
12
12
 
13
13
  ```typescript
14
- import { Module } from '@nestjs/common'
14
+ import { MiddlewareConsumer, Module, RequestMethod } from '@nestjs/common'
15
15
  import { MongooseModule } from '@nestjs/mongoose'
16
16
  import { SecurityModule, BlacklistedIp, BlacklistedIpSchema, SecurityMiddleware } from 'nestjs-security-cli'
17
17
 
@@ -39,9 +39,10 @@ import { SecurityModule, BlacklistedIp, BlacklistedIpSchema, SecurityMiddleware
39
39
  ]
40
40
  } )
41
41
  export class AppModule {
42
- configure(consumer: MiddlewareConsumer) {
43
- // This protects ALL requests, including non-existent routes
44
- consumer.apply( SecurityMiddleware ).forRoutes( '*' )
42
+ configure(consumer: MiddlewareConsumer): void {
43
+ consumer
44
+ .apply( SecurityMiddleware )
45
+ .forRoutes( { path: '*', method: RequestMethod.ALL } )
45
46
  }
46
47
  }
47
48
  ```
@@ -49,7 +50,7 @@ export class AppModule {
49
50
  ## with ConfigService
50
51
 
51
52
  ```typescript
52
- import { Module } from '@nestjs/common'
53
+ import { MiddlewareConsumer, Module, RequestMethod } from '@nestjs/common'
53
54
  import { ConfigModule, ConfigService } from '@nestjs/config'
54
55
  import { MongooseModule } from '@nestjs/mongoose'
55
56
  import { SecurityModule, BlacklistedIp, BlacklistedIpSchema } from 'nestjs-security-cli'
@@ -82,6 +83,11 @@ import { SecurityModule, BlacklistedIp, BlacklistedIpSchema } from 'nestjs-secur
82
83
  ]
83
84
  } )
84
85
  export class AppModule {
86
+ configure(consumer: MiddlewareConsumer): void {
87
+ consumer
88
+ .apply( SecurityMiddleware )
89
+ .forRoutes( { path: '*', method: RequestMethod.ALL } )
90
+ }
85
91
  }
86
92
  ```
87
93
 
@@ -108,7 +114,32 @@ export class AppModule {
108
114
 
109
115
  ## If you mongodb set up is using db connections via providers, you can use the `IpBlockerProvider`
110
116
  ```typescript
111
- providers: [...IpBlockerProvider]
117
+ import { MiddlewareConsumer, Module, RequestMethod } from '@nestjs/common'
118
+ import { SecurityMiddleware, SecurityModule, IpBlockerProvider } from 'nestjs-security-cli'
119
+
120
+ @Module( {
121
+ imports: [
122
+ ConfigModule.forRoot( {
123
+ cache: true,
124
+ isGlobal: true
125
+ } ),
126
+ SecurityModule.forRoot( {
127
+ enableDatabase: true,
128
+ defaultBlockDurationHours: 24,
129
+ enableAutoBlocking: true,
130
+ enableAdminPanel: false
131
+ } )
132
+ ],
133
+ controllers: [ /* controllers */ ],
134
+ providers: [ /* providers */, ...IpBlockerProvider ]
135
+ } )
136
+ export class AppModule {
137
+ configure(consumer: MiddlewareConsumer): void {
138
+ consumer
139
+ .apply( SecurityMiddleware )
140
+ .forRoutes( { path: '*', method: RequestMethod.ALL } )
141
+ }
142
+ }
112
143
  ```
113
144
 
114
145
  ## Clean up cron
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-security-cli",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Advanced IP blocking, role-based security, and attack detection for NestJS applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",