forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity.module.ts
More file actions
38 lines (37 loc) · 974 Bytes
/
Copy pathsecurity.module.ts
File metadata and controls
38 lines (37 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Module, MiddlewareConsumer } from "@nestjs/common";
import { ThrottlerModule } from "@nestjs/throttler";
import { RateLimitGuard } from "./rate-limit.guard";
import { IpThrottleGuard } from "./throttle.guard";
import { AuditLogService } from "./audit-log.service";
import helmet from "helmet";
import csrf from "csurf";
import xssClean from "xss-clean";
import rateLimit from "express-rate-limit";
@Module({
imports: [
ThrottlerModule.forRoot([
{
name: "default",
ttl: 60,
limit: 100,
},
]),
],
providers: [RateLimitGuard, IpThrottleGuard, AuditLogService],
exports: [RateLimitGuard, IpThrottleGuard, AuditLogService],
})
export class SecurityModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(
helmet(),
xssClean(),
csrf({ cookie: true }),
rateLimit({
windowMs: 60 * 1000,
max: 100,
})
)
.forRoutes("*");
}
}