8000 Improve config parsing by ylber-gashi · Pull Request #37 · colanode/colanode · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve config parsing #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/lib/config/smtp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
Expand Down
10 changes: 2 additions & 8 deletions apps/server/src/lib/config/user.ts
Original file line number Diff line number Diff line change
@@ -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>;
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/lib/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
< 305E /div>
0