mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 05:10:45 +08:00
change log in
This commit is contained in:
parent
9cf026f605
commit
8ca42dd973
211 changed files with 48417 additions and 109 deletions
27
uds-auth/lib/session/factory.js
Normal file
27
uds-auth/lib/session/factory.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { MemoryStore } from './memory-store.js'
|
||||
import { RedisStore } from './redis-store.js'
|
||||
|
||||
/**
|
||||
* Factory function to create appropriate session store based on config
|
||||
* @param {object} config - Session configuration
|
||||
* @returns {Promise<SessionStore>}
|
||||
*/
|
||||
export async function createSessionStore(config) {
|
||||
const { storeType, redisUrl } = config
|
||||
|
||||
if (storeType === 'redis') {
|
||||
try {
|
||||
const { createClient } = await import('redis')
|
||||
const client = createClient({ url: redisUrl })
|
||||
await client.connect()
|
||||
return new RedisStore(client)
|
||||
} catch (err) {
|
||||
console.error('[uds-auth] Failed to connect to Redis:', err.message)
|
||||
console.warn('[uds-auth] Falling back to MemoryStore')
|
||||
return new MemoryStore()
|
||||
}
|
||||
}
|
||||
|
||||
// Default to memory store
|
||||
return new MemoryStore()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue