Files
stats/packages/queue/src/connection.ts
Carl-Gerhard Lindesvärd 85e4922dc3 new redis url parser
2024-02-11 22:31:22 +01:00

14 lines
359 B
TypeScript

const parse = (connectionString: string) => {
const match = connectionString.match(/redis:\/\/(.+?):(.+?)@(.+?):(.+)/);
if (!match) {
throw new Error('Invalid connection string');
}
return {
host: match[3]!,
port: Number(match[4]),
password: match[2]!,
} as const;
};
export const connection = parse(String(process.env.REDIS_URL));