mirror of
https://github.com/fosrl/pangolin.git
synced 2025-06-25 22:58:48 +02:00
move enable redis to flag
This commit is contained in:
parent
139c9d2ce3
commit
af32dfbbcd
2 changed files with 233 additions and 222 deletions
|
@ -14,7 +14,7 @@ class RedisManager {
|
|||
> = new Map();
|
||||
|
||||
private constructor() {
|
||||
this.isEnabled = config.getRawConfig().redis?.enabled || false;
|
||||
this.isEnabled = config.getRawConfig().flags?.enable_redis || false;
|
||||
if (this.isEnabled) {
|
||||
this.initializeClients();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ const getEnvOrYaml = (envVar: string) => (valFromYaml: any) => {
|
|||
return process.env[envVar] ?? valFromYaml;
|
||||
};
|
||||
|
||||
export const configSchema = z.object({
|
||||
export const configSchema = z
|
||||
.object({
|
||||
app: z.object({
|
||||
dashboard_url: z
|
||||
.string()
|
||||
|
@ -79,8 +80,14 @@ export const configSchema = z.object({
|
|||
.optional()
|
||||
.default("pangolin")
|
||||
.transform((url) => url.toLowerCase()),
|
||||
session_cookie_name: z.string().optional().default("p_session_token"),
|
||||
resource_access_token_param: z.string().optional().default("p_token"),
|
||||
session_cookie_name: z
|
||||
.string()
|
||||
.optional()
|
||||
.default("p_session_token"),
|
||||
resource_access_token_param: z
|
||||
.string()
|
||||
.optional()
|
||||
.default("p_token"),
|
||||
resource_access_token_headers: z
|
||||
.object({
|
||||
id: z.string().optional().default("P-Access-Token-Id"),
|
||||
|
@ -133,9 +140,8 @@ export const configSchema = z.object({
|
|||
.optional(),
|
||||
redis: z
|
||||
.object({
|
||||
enabled: z.boolean(),
|
||||
host: z.string().optional(),
|
||||
port: portSchema.optional(),
|
||||
host: z.string(),
|
||||
port: portSchema,
|
||||
password: z.string().optional(),
|
||||
db: z.number().int().nonnegative().optional().default(0),
|
||||
tls: z
|
||||
|
@ -144,18 +150,6 @@ export const configSchema = z.object({
|
|||
})
|
||||
.optional()
|
||||
})
|
||||
.refine(
|
||||
(redis) => {
|
||||
if (!redis.enabled) {
|
||||
return true;
|
||||
}
|
||||
return redis.host !== undefined && redis.port !== undefined;
|
||||
},
|
||||
{
|
||||
message:
|
||||
"If Redis is enabled, connection details must be provided"
|
||||
}
|
||||
)
|
||||
.optional(),
|
||||
traefik: z
|
||||
.object({
|
||||
|
@ -180,7 +174,12 @@ export const configSchema = z.object({
|
|||
use_subdomain: z.boolean().optional().default(false),
|
||||
subnet_group: z.string().optional().default("100.89.137.0/20"),
|
||||
block_size: z.number().positive().gt(0).optional().default(24),
|
||||
site_block_size: z.number().positive().gt(0).optional().default(30)
|
||||
site_block_size: z
|
||||
.number()
|
||||
.positive()
|
||||
.gt(0)
|
||||
.optional()
|
||||
.default(30)
|
||||
})
|
||||
.optional()
|
||||
.default({}),
|
||||
|
@ -246,10 +245,22 @@ export const configSchema = z.object({
|
|||
allow_raw_resources: z.boolean().optional(),
|
||||
allow_base_domain_resources: z.boolean().optional(),
|
||||
allow_local_sites: z.boolean().optional(),
|
||||
enable_integration_api: z.boolean().optional()
|
||||
enable_integration_api: z.boolean().optional(),
|
||||
enable_redis: z.boolean().optional()
|
||||
})
|
||||
.optional()
|
||||
});
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
if (data.flags?.enable_redis) {
|
||||
return data?.redis !== undefined;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
{
|
||||
message: "If Redis is enabled, configuration details must be provided"
|
||||
}
|
||||
);
|
||||
|
||||
export function readConfigFile() {
|
||||
const loadConfig = (configPath: string) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue