Skip to content

Commit

Permalink
Merge pull request #94 from VictoriqueMoe/update-to-use-store-from-npm
Browse files Browse the repository at this point in the history
update to use published store
  • Loading branch information
VictoriqueMoe authored Mar 5, 2024
2 parents e7aeda0 + 5c07785 commit 22da528
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 115 deletions.
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
111 changes: 0 additions & 111 deletions src/extensions/expressRateLimit/stores/ExpressRateLimitTypeOrmStore.ts

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

0 comments on commit 22da528

Please sign in to comment.