-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(backend) Implement persistent sessions
Fix #63
- Loading branch information
1 parent
a99f546
commit 4cbad75
Showing
10 changed files
with
213 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { InMemoryTTLCache } from '../util/in-memory-ttl-cache' | ||
import { NeucoreGroupsProvider } from '../middleware/user-roles' | ||
import { NeucoreClient } from './neucore-client' | ||
|
||
export class NeucoreGroupCache implements NeucoreGroupsProvider { | ||
#cache: InMemoryTTLCache<number, string[]> | ||
|
||
constructor(options: { | ||
neucoreClient: NeucoreClient | ||
cacheTTL: number | ||
}) { | ||
this.#cache = new InMemoryTTLCache({ | ||
defaultTTL: options.cacheTTL, | ||
get: async characterId => { | ||
console.log('getting neucore groups for', characterId) | ||
const groups = await options.neucoreClient.getCharacterGroups(characterId) | ||
return { value: groups.map(g => g.name) } | ||
}, | ||
}) | ||
} | ||
|
||
async getGroups(characterId: number, forceRefresh = false): Promise<string[]> { | ||
return await this.#cache.get(characterId, forceRefresh) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.