Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit 8abd8c4

Browse files
authored
Merge pull request #80 from ozkanonur/test
v3.0.0
2 parents 576380a + c6e22ff commit 8abd8c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+103
-15322
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test with Jest
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: [10.x, 12.x, 14.x]
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
- run: npm ci
23+
- run: npm run build
24+
- run: npm run test
25+
env:
26+
CI: true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# vim
2+
*.swp
3+
*.*~
4+
15
# dependencies
26
/node_modules
37

README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
<h2 align="center">Rate Limiter Module for NestJS</h2>
66

77
<p align="center">
8-
<a href="https://www.codefactor.io/repository/github/ozkanonur/nestjs-rate-limiter"><img src="https://www.codefactor.io/repository/github/ozkanonur/nestjs-rate-limiter/badge?style=flat-square&sanitize=true" alt="Code Quality" /></a>
9-
<a href="https://www.npmjs.com/package/nestjs-rate-limiter"><img src="https://img.shields.io/npm/v/nestjs-rate-limiter.svg?style=flat-square&sanitize=true" alt="NPM Version" /></a>
10-
<a href="https://www.npmjs.com/package/nestjs-rate-limiter"><img src="https://img.shields.io/npm/dm/nestjs-rate-limiter.svg?style=flat-square&sanitize=true" alt="NPM Downloads" /></a>
11-
<a href="#"><img src="https://img.shields.io/npm/l/nestjs-rate-limiter.svg?colorB=black&label=LICENSE&style=flat-square&sanitize=true" alt="License"/></a>
8+
<a href="https://www.codefactor.io/repository/github/ozkanonur/nestjs-rate-limiter"><img src="https://www.codefactor.io/repository/github/ozkanonur/nestjs-rate-limiter/badge?sanitize=true" alt="Code Quality" /></a>
9+
<a href="https://www.npmjs.com/package/nestjs-rate-limiter"><img src="https://img.shields.io/npm/v/nestjs-rate-limiter.svg?sanitize=true" alt="NPM Version" /></a>
10+
<a href="https://www.npmjs.com/package/nestjs-rate-limiter"><img src="https://img.shields.io/npm/dm/nestjs-rate-limiter.svg?sanitize=true" alt="NPM Downloads" /></a>
11+
<a href="#"><img src="https://img.shields.io/npm/l/nestjs-rate-limiter.svg?colorB=black&label=LICENSE&sanitize=true" alt="License"/></a>
12+
<a href="#"><img src="https://github.com/ozkanonur/nestjs-rate-limiter/actions/workflows/test.yml/badge.svg?branch=master" alt="Test"/></a>
1213

1314
</p>
1415

@@ -17,7 +18,7 @@
1718
- [Installation](https://github.com/ozkanonur/nestjs-rate-limiter#installation)
1819
- [Basic Usage](https://github.com/ozkanonur/nestjs-rate-limiter#basic-usage)
1920
- [Include Module](https://github.com/ozkanonur/nestjs-rate-limiter#include-module)
20-
- [Using Interceptor](https://github.com/ozkanonur/nestjs-rate-limiter#using-interceptor)
21+
- [Using Guard](https://github.com/ozkanonur/nestjs-rate-limiter#using-guard)
2122
- [With Decorator](https://github.com/ozkanonur/nestjs-rate-limiter#with-decorator)
2223
- [With All Options](https://github.com/ozkanonur/nestjs-rate-limiter#with-all-options)
2324
- [Fastify based Graphql](https://github.com/ozkanonur/nestjs-rate-limiter#fastify-based-graphql)
@@ -50,7 +51,6 @@
5051
- [customResponseSchema](https://github.com/ozkanonur/nestjs-rate-limiter#-customResponseSchema)
5152
- [Benchmarks](https://github.com/ozkanonur/nestjs-rate-limiter#benchmarks)
5253
- [TODO List](https://github.com/ozkanonur/nestjs-rate-limiter#todo)
53-
- [Examples](https://github.com/ozkanonur/nestjs-rate-limiter/examples/README.md)
5454

5555
# Description
5656

@@ -83,44 +83,44 @@ First you need to import this module into your main application module:
8383
> app.module.ts
8484
8585
```ts
86-
import { RateLimiterModule } from 'nestjs-rate-limiter';
86+
import { RateLimiterModule } from 'nestjs-rate-limiter'
8787

8888
@Module({
8989
imports: [RateLimiterModule],
9090
})
9191
export class ApplicationModule {}
9292
```
9393

94-
### Using Interceptor
94+
### Using Guard
9595

96-
Now you need to register the interceptor. You can do this only on some routes:
96+
Now you need to register the guard. You can do this only on some routes:
9797

9898
> app.controller.ts
9999
100100
```ts
101-
import { RateLimiterInterceptor } from 'nestjs-rate-limiter';
101+
import { RateLimiterGuard } from 'nestjs-rate-limiter'
102102

103-
@UseInterceptors(RateLimiterInterceptor)
103+
@UseGuards(RateLimiterGuard)
104104
@Get('/login')
105105
public async login() {
106-
console.log('hello');
106+
console.log('hello')
107107
}
108108
```
109109

110-
Or you can choose to register the interceptor globally:
110+
Or you can choose to register the guard globally:
111111

112112
> app.module.ts
113113
114114
```ts
115-
import { APP_INTERCEPTOR } from '@nestjs/core';
116-
import { RateLimiterModule, RateLimiterInterceptor } from 'nestjs-rate-limiter';
115+
import { APP_GUARD } from '@nestjs/core'
116+
import { RateLimiterModule, RateLimiterGuard } from 'nestjs-rate-limiter'
117117

118118
@Module({
119119
imports: [RateLimiterModule],
120120
providers: [
121121
{
122-
provide: APP_INTERCEPTOR,
123-
useClass: RateLimiterInterceptor,
122+
provide: APP_GUARD,
123+
useClass: RateLimiterGuard,
124124
},
125125
],
126126
})
@@ -135,19 +135,19 @@ route basis:
135135
> app.controller.ts
136136
137137
```ts
138-
import { RateLimit } from 'nestjs-rate-limiter';
138+
import { RateLimit } from 'nestjs-rate-limiter'
139139

140140
@RateLimit({ keyPrefix: 'sign-up', points: 1, duration: 60, errorMessage: 'Accounts cannot be created more than once in per minute' })
141141
@Get('/signup')
142142
public async signUp() {
143-
console.log('hello');
143+
console.log('hello')
144144
}
145145
```
146146

147147
### Dynamic Keyprefix
148148

149149
```ts
150-
import { RateLimit } from 'nestjs-rate-limiter';
150+
import { RateLimit } from 'nestjs-rate-limiter'
151151

152152
@RateLimit({
153153
keyPrefix: () => programmaticFuncThatReturnsValue(),
@@ -157,7 +157,7 @@ import { RateLimit } from 'nestjs-rate-limiter';
157157
})
158158
@Get('/example')
159159
public async example() {
160-
console.log('hello');
160+
console.log('hello')
161161
}
162162
```
163163

@@ -201,8 +201,8 @@ The usage of the limiter options is as in the code block below. For an explanati
201201
],
202202
providers: [
203203
{
204-
provide: APP_INTERCEPTOR,
205-
useClass: RateLimiterInterceptor,
204+
provide: APP_GUARD,
205+
useClass: RateLimiterGuard,
206206
},
207207
],
208208
})
@@ -486,4 +486,3 @@ GraphQLModule.forRoot({
486486
## TODO
487487
- [ ] Support Websocket
488488
- [ ] Support Rpc
489-
- [ ] Github Actions

examples/.editorconfig

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/.eslintrc.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

examples/.gitignore

Lines changed: 0 additions & 40 deletions
This file was deleted.

examples/.prettierignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/.prettierrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/README.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

examples/apps/.gitkeep

Whitespace-only changes.

examples/apps/rate-limiter-express-app/.eslintrc.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/apps/rate-limiter-express-app/jest.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/apps/rate-limiter-express-app/src/app/.gitkeep

Whitespace-only changes.

examples/apps/rate-limiter-express-app/src/app/app.module.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)