mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-12-01 17:23:40 +08:00
Improve theme consistency, keyboard navigation, and reusable frontend components. Harden fullstack initialization and expose scoped lint and Vitest commands.
30 lines
676 B
JavaScript
30 lines
676 B
JavaScript
import { createClient } from 'redis'
|
|
|
|
let client
|
|
|
|
try {
|
|
const url = new URL(process.env.REDIS_URL)
|
|
|
|
if (!['redis:', 'rediss:'].includes(url.protocol) || !url.hostname)
|
|
throw new Error('Invalid Redis URL.')
|
|
|
|
client = createClient({
|
|
url: process.env.REDIS_URL,
|
|
socket: {
|
|
connectTimeout: 3000,
|
|
socketTimeout: 3000,
|
|
reconnectStrategy: false,
|
|
},
|
|
})
|
|
client.on('error', () => {})
|
|
await client.connect()
|
|
await client.ping()
|
|
} catch {
|
|
console.error(
|
|
'Redis check failed. Verify REDIS_URL, credentials and service availability before retrying setup.',
|
|
)
|
|
process.exitCode = 1
|
|
} finally {
|
|
if (client?.isOpen) client.destroy()
|
|
}
|