8000 feat(config): add default note TTL configuration by CorentinTh · Pull Request #323 · CorentinTh/enclosed · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(config): add default note TTL configuration #323

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
Nov 11, 2024
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
8000
Diff view
1 change: 1 addition & 0 deletions packages/app-client/src/modules/config/config.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export const buildTimeConfig: Config = {
enclosedVersion: import.meta.env.VITE_ENCLOSED_VERSION ?? '0.0.0',
isAuthenticationRequired: import.meta.env.VITE_IS_AUTHENTICATION_REQUIRED === 'true',
defaultDeleteNoteAfterReading: import.meta.env.VITE_DEFAULT_DELETE_NOTE_AFTER_READING === 'true',
defaultNoteTtlSeconds: Number(import.meta.env.VITE_DEFAULT_NOTE_TTL_SECONDS ?? 3600),
};
1 change: 1 addition & 0 deletions packages/app-client/src/modules/config/config.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export type Config = {
isAuthenticationRequired: boolean;
enclosedVersion: string;
defaultDeleteNoteAfterReading: boolean;
defaultNoteTtlSeconds: number;
};
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const CreateNotePage: Component = () => {
const [getError, setError] = createSignal<{ message: string; details?: string } | null>(null);
const [getIsNoteCreated, setIsNoteCreated] = createSignal(false);
const [getIsPublic, setIsPublic] = createSignal(true);
const [getTtlInSeconds, setTtlInSeconds] = createSignal(3600);
const [getTtlInSeconds, setTtlInSeconds] = createSignal(config.defaultNoteTtlSeconds);
const [getDeleteAfterReading, setDeleteAfterReading] = createSignal(config.defaultDeleteNoteAfterReading);
const [getUploadedFiles, setUploadedFiles] = createSignal<File[]>([]);
const [getIsNoteCreating, setIsNoteCreating] = createSignal(false);
Expand Down
14 changes: 14 additions & 0 deletions packages/app-server/src/modules/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ export const configDefinition = {
default: 'false',
env: 'PUBLIC_DEFAULT_DELETE_NOTE_AFTER_READING',
},
defaultNoteTtlSeconds: {
doc: 'The default value for the expiration time of a note in seconds, the value must be one of: `3600` (1 hour), `86400` (1 day), `604800` (1 week), `2592000` (1 month)',
schema: z
.coerce
.number()
.refine(
value => [3600, 86400, 604800, 2592000].includes(value),
{
message: 'PUBLIC_DEFAULT_NOTE_TTL_SECONDS: Invalid value. Must be one of: 3600, 86400, 604800, 2592000',
},
),
default: 3600,
env: 'PUBLIC_DEFAULT_NOTE_TTL_SECONDS',
},
},
authentication: {
jwtSecret: {
Expand Down
Loading
0