mirror of
https://github.com/colanode/colanode.git
synced 2025-12-16 03:37:51 +01:00
Improve config parsing (#37)
This commit is contained in:
@@ -95,8 +95,8 @@ export const userCreateRoute: FastifyPluginCallbackZod = (
|
||||
name: account.name,
|
||||
email: account.email,
|
||||
avatar: account.avatar,
|
||||
storage_limit: config.user.storageLimit.toString(),
|
||||
max_file_size: config.user.maxFileSize.toString(),
|
||||
storage_limit: config.user.storageLimit,
|
||||
max_file_size: config.user.maxFileSize,
|
||||
created_at: new Date(),
|
||||
created_by: request.account.id,
|
||||
status: UserStatus.Active,
|
||||
|
||||
@@ -7,7 +7,7 @@ export const smtpConfigSchema = z.discriminatedUnion('enabled', [
|
||||
required_error: 'SMTP_HOST is required when SMTP is enabled',
|
||||
}),
|
||||
port: z.coerce.number().default(587),
|
||||
secure: z.preprocess((val) => val === 'true', z.boolean().default(false)),
|
||||
secure: z.boolean().default(false),
|
||||
user: z.string({
|
||||
required_error: 'SMTP_USER is required when SMTP is enabled',
|
||||
}),
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const userConfigSchema = z.object({
|
||||
storageLimit: z.preprocess(
|
||||
(val) => val && BigInt(val as string),
|
||||
z.bigint().default(10737418240n)
|
||||
),
|
||||
maxFileSize: z.preprocess(
|
||||
(val) => val && BigInt(val as string),
|
||||
z.bigint().default(104857600n)
|
||||
),
|
||||
storageLimit: z.string().default('10737418240'),
|
||||
maxFileSize: z.string().default('104857600'),
|
||||
});
|
||||
|
||||
export type UserConfig = z.infer<typeof userConfigSchema>;
|
||||
|
||||
@@ -55,8 +55,8 @@ export const createWorkspace = async (
|
||||
name: account.name,
|
||||
email: account.email,
|
||||
avatar: account.avatar,
|
||||
storage_limit: config.user.storageLimit.toString(),
|
||||
max_file_size: config.user.maxFileSize.toString(),
|
||||
storage_limit: config.user.storageLimit,
|
||||
max_file_size: config.user.maxFileSize,
|
||||
created_at: date,
|
||||
created_by: account.id,
|
||||
status: UserStatus.Active,
|
||||
|
||||
Reference in New Issue
Block a user