diff --git a/src/server/Server.ts b/src/server/Server.ts index 3aa6c7c..04d77c5 100644 --- a/src/server/Server.ts +++ b/src/server/Server.ts @@ -20,7 +20,7 @@ import { Util } from '../util/index.js'; import { Registry, UserDatabase } from './components/index.js'; import { Authenticator, RateLimiter } from './middleware/index.js'; import { UserDatabaseInterface } from './interfaces/index.js'; -import { ExternalProfile, OAuthProvider, Request, Response, ServerOptions, SessionLimit } from '../../@types/Server.js'; +import { ExternalProfile, OAuthProvider, Request, Response, ServerOptions } from '../../@types/Server.js'; import { MongoMemory } from './database/index.js'; import { IPCMessage, SignupCode } from '../../@types/Other.js'; import { DoneCallback } from 'passport'; @@ -52,7 +52,7 @@ class Server extends EventEmitter { #_registry: Registry; #_mariadb: MariaDB; #_mongodb: MongoDB; - #_memoryStoreProvider: MongoMemory; + #_memoryStoreProvider: MongoMemory; #_rateLimiter: RateLimiter; #_authenticator: Authenticator; diff --git a/src/server/database/MemoryCache.ts b/src/server/database/MemoryCache.ts index 6e3d896..9b29654 100644 --- a/src/server/database/MemoryCache.ts +++ b/src/server/database/MemoryCache.ts @@ -2,11 +2,13 @@ import Server from "../Server.js"; import { MemoryCacheProvider } from "../interfaces/index.js"; class MemoryCache { + server: Server; - provider: MemoryCacheProvider; + provider: MemoryCacheProvider; collection: string; + constructor (server: Server, { provider, collection }: { - provider: MemoryCacheProvider, + provider: MemoryCacheProvider, collection?: string }) { this.server = server; diff --git a/src/server/database/MongoMemory.ts b/src/server/database/MongoMemory.ts index 91eee5b..d059df6 100644 --- a/src/server/database/MongoMemory.ts +++ b/src/server/database/MongoMemory.ts @@ -1,16 +1,16 @@ import { MongoDB } from '@navy.gif/wrappers'; import { MemoryCacheProvider } from '../interfaces/index.js'; -class MongoMemory extends MongoDB implements MemoryCacheProvider { +class MongoMemory extends MongoDB implements MemoryCacheProvider { - async getKey (key: K, collection = 'memoryStore'): Promise { + async getKey (key: K, collection = 'memoryStore'): Promise { const response = await this.findOne(collection, { key }); if (response) return response.value as V; return null; } - async setKey (key: K, value: V, collection = 'memoryStore'): Promise { + async setKey (key: unknown, value: unknown, collection = 'memoryStore'): Promise { await this.updateOne(collection, { key }, { value }, true); } diff --git a/src/server/interfaces/MemoryCacheProvider.ts b/src/server/interfaces/MemoryCacheProvider.ts index 25d384e..96c8544 100644 --- a/src/server/interfaces/MemoryCacheProvider.ts +++ b/src/server/interfaces/MemoryCacheProvider.ts @@ -1,8 +1,8 @@ -interface MemoryCacheProvider { +interface MemoryCacheProvider { ensureIndex(collection: string, indices: string[]): Promise - getKey(key: K, collection?: string): Promise - setKey(key: K, value: V, collection?: string): Promise + getKey(key: K, collection?: string): Promise + setKey(key: unknown, value: unknown, collection?: string): Promise } diff --git a/src/server/middleware/RateLimiter.ts b/src/server/middleware/RateLimiter.ts index 23c4eda..53e40b4 100644 --- a/src/server/middleware/RateLimiter.ts +++ b/src/server/middleware/RateLimiter.ts @@ -42,7 +42,7 @@ class RateLimiter { * @param {*} [options={}] * @memberof RateLimiter */ - constructor (server: Server, memoryCacheProvider: MemoryCacheProvider, { limitFn }: RateLimiterOptions = {}) { + constructor (server: Server, memoryCacheProvider: MemoryCacheProvider, { limitFn }: RateLimiterOptions = {}) { this.server = server; this.cache = new MemoryCache(server, { provider: memoryCacheProvider, collection: 'rateLimiter' });