Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to use published store #94

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"sanitize-filename-ts": "^1.0.2",
"toad-scheduler": "^3.0.1",
"typeorm": "^0.3.20",
"typeorm-rate-limit-store": "^1.0.0",
"xss": "^1.0.14"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import rateLimit from "express-rate-limit";
import { LRUCache } from "lru-cache";
import { filesDir, FileUtils, NetworkUtils } from "./utils/Utils.js";
import { fileURLToPath } from "node:url";
import { ExpressRateLimitTypeOrmStore } from "./extensions/expressRateLimit/stores/ExpressRateLimitTypeOrmStore.js";
import { ExpressRateLimitTypeOrmStore } from "typeorm-rate-limit-store";
import { ExpressRateLimitStoreModel } from "./model/db/ExpressRateLimitStore.model.js";

const opts: Partial<TsED.Configuration> = {
...config,
Expand Down Expand Up @@ -152,7 +153,6 @@ export class Server implements BeforeRoutesInit {
public constructor(
@Inject() private app: PlatformApplication,
@Inject(SQLITE_DATA_SOURCE) private ds: DataSource,
@Inject() private expressRateLimitTypeOrmStore: ExpressRateLimitTypeOrmStore,
) {}

@Configuration()
Expand Down Expand Up @@ -201,7 +201,7 @@ export class Server implements BeforeRoutesInit {
keyGenerator: request => {
return NetworkUtils.getIp(request);
},
store: this.expressRateLimitTypeOrmStore,
store: new ExpressRateLimitTypeOrmStore(this.ds.getRepository(ExpressRateLimitStoreModel)),
}),
);
}
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion src/model/db/ExpressRateLimitStore.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Column, Entity, PrimaryColumn } from "typeorm";
import type { IExpressRateLimitModel } from "typeorm-rate-limit-store";

@Entity()
export class ExpressRateLimitStoreModel {
export class ExpressRateLimitStoreModel implements IExpressRateLimitModel {
@PrimaryColumn()
public key: string;

Expand Down