Feat: Add max filesize environment variable (#20)

Co-authored-by: Charly Gley <charly@gley.dev>
This commit is contained in:
PunchEnergyFTW
2025-04-28 04:30:18 +02:00
committed by GitHub
parent 792183bbb3
commit 107a467bcc
5 changed files with 7 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ services:
- MINIO_BUCKET_NAME=files # MinIO bucket name - This is needed for MinIO to work properly, dont change it if you don't know what you are doing
- FRONTEND_URL=${APP_URL:-http://${SERVER_IP:-localhost}:${APP_EXTERNAL_PORT:-5487}} # Frontend URL - Make sure to use the correct frontend URL, depends on where the frontend is running, its prepared for localhost, but you can change it to your frontend URL if needed
- SERVER_IP=${SERVER_IP:-localhost} # Server IP - Make sure to use the correct server IP if you running on a cloud provider or a virtual machine. This prepared for localhost, but you can change it to your server IP if needed
- MAX_FILESIZE=${MAX_FILESIZE:-1073741824} # Max Filesize for upload - Declared in Bytes. Default is 1GiB
ports:
- "${API_EXTERNAL_PORT:-3333}:${API_INTERNAL_PORT:-3333}" # Backend port mapping
restart: unless-stopped
@@ -179,6 +180,7 @@ The table below shows all environment variables that can be set
| MINIO_EXTERNAL_CONSOLE_PORT | 6422 | Exposed port on host for MinIO console |
| POSTGRESQL_USERNAME | postgres | PostgreSQL user |
| POSTGRESQL_DATABASE | palmr_db | Database name |
| MAX_FILESIZE | 1073741824 | Max Uploadsize per file. Unit in Bytes |
> *All these variables can be configured through a .env file in the project root or defined directly in the environment where docker-compose will be executed. The best way to do this is up to you. But be careful to replace correctly if doing directly in the compose instead of providing an environment var.*
>

View File

@@ -10,4 +10,4 @@ MINIO_REGION="sa-east-1"
MINIO_BUCKET_NAME="files"
PORT=3333
SERVER_IP="localhost"
MAX_FILESIZE="1073741824"

View File

@@ -1,6 +1,7 @@
import { prisma } from "../src/shared/prisma";
import bcrypt from "bcryptjs";
import crypto from "node:crypto";
import { env } from '../src/env';
const defaultConfigs = [
// General Configurations
@@ -31,7 +32,7 @@ const defaultConfigs = [
// Storage Configurations
{
key: "maxFileSize",
value: "1073741824", // 1GB in bytes
value: env.MAX_FILESIZE, // default 1GiB in bytes - 1073741824
type: "bigint",
group: "storage",
},

View File

@@ -12,6 +12,7 @@ const envSchema = z.object({
PORT: z.string().min(1),
DATABASE_URL: z.string().min(1),
SERVER_IP: z.string().min(1),
MAX_FILESIZE: z.string().min(1),
});
export const env = envSchema.parse(process.env);

View File

@@ -19,6 +19,7 @@ services:
- MINIO_BUCKET_NAME=files # MinIO bucket name - This is needed for MinIO to work properly, dont change it if you don't know what you are doing
- FRONTEND_URL=${APP_URL:-http://${SERVER_IP:-localhost}:${APP_EXTERNAL_PORT:-5487}} # Frontend URL - Make sure to use the correct frontend URL, depends on where the frontend is running, its prepared for localhost, but you can change it to your frontend URL if needed
- SERVER_IP=${SERVER_IP:-localhost} # Server IP - Make sure to use the correct server IP if you running on a cloud provider or a virtual machine. This prepared for localhost, but you can change it to your server IP if needed
- MAX_FILESIZE=${MAX_FILESIZE:-1073741824} # Max Filesize for upload - Declared in Bytes. Default is 1GiB
ports:
- "${API_EXTERNAL_PORT:-3333}:${API_INTERNAL_PORT:-3333}" # Backend port mapping
restart: unless-stopped