mirror of
https://github.com/detleph/server.git
synced 2026-09-05 23:44:18 +02:00
Add redis
+ Add a public lib file for redis + Add an indexed auth client + Add a function to create promisified partial clients + Add password revisions to the auth redis index
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import redis from "redis";
|
||||
import { promisify } from "util";
|
||||
|
||||
const REDIS_INDICES = {
|
||||
auth: 0,
|
||||
};
|
||||
|
||||
const REDIS_HOST = process.env.REDIS_HOST || "redis";
|
||||
const REDIS_PORT = process.env.REDIS_PORT ? parseInt(process.env.REDIS_PORT) : 6379;
|
||||
|
||||
// TODO: Extend
|
||||
function createAsyncClient(client: redis.RedisClient) {
|
||||
return {
|
||||
get: promisify(client.get).bind(client),
|
||||
set: promisify(client.set).bind(client),
|
||||
};
|
||||
}
|
||||
|
||||
// ----------------- //
|
||||
// Redis auth client //
|
||||
// ----------------- //
|
||||
|
||||
const auth = redis.createClient({ host: REDIS_HOST, port: REDIS_PORT });
|
||||
|
||||
auth.select(REDIS_INDICES.auth);
|
||||
|
||||
export const authClient = createAsyncClient(auth);
|
||||
Reference in New Issue
Block a user