mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-28 18:36:12 +01:00
Attach documents to expenses (#64)
* Upload documents to receipts * Improve documents * Make the feature opt-in * Fix file name issue
This commit is contained in:
committed by
GitHub
parent
11d2e298e8
commit
d43e731fe1
@@ -1,16 +1,37 @@
|
||||
import { z } from 'zod'
|
||||
import { ZodIssueCode, z } from 'zod'
|
||||
|
||||
const envSchema = z.object({
|
||||
POSTGRES_URL_NON_POOLING: z.string().url(),
|
||||
POSTGRES_PRISMA_URL: z.string().url(),
|
||||
NEXT_PUBLIC_BASE_URL: z
|
||||
.string()
|
||||
.optional()
|
||||
.default(
|
||||
process.env.VERCEL_URL
|
||||
? `https://${process.env.VERCEL_URL}`
|
||||
: 'http://localhost:3000',
|
||||
),
|
||||
})
|
||||
const envSchema = z
|
||||
.object({
|
||||
POSTGRES_URL_NON_POOLING: z.string().url(),
|
||||
POSTGRES_PRISMA_URL: z.string().url(),
|
||||
NEXT_PUBLIC_BASE_URL: z
|
||||
.string()
|
||||
.optional()
|
||||
.default(
|
||||
process.env.VERCEL_URL
|
||||
? `https://${process.env.VERCEL_URL}`
|
||||
: 'http://localhost:3000',
|
||||
),
|
||||
NEXT_PUBLIC_ENABLE_EXPENSE_DOCUMENTS: z.coerce.boolean().default(false),
|
||||
S3_UPLOAD_KEY: z.string().optional(),
|
||||
S3_UPLOAD_SECRET: z.string().optional(),
|
||||
S3_UPLOAD_BUCKET: z.string().optional(),
|
||||
S3_UPLOAD_REGION: z.string().optional(),
|
||||
})
|
||||
.superRefine((env, ctx) => {
|
||||
if (
|
||||
env.NEXT_PUBLIC_ENABLE_EXPENSE_DOCUMENTS &&
|
||||
(!env.S3_UPLOAD_BUCKET ||
|
||||
!env.S3_UPLOAD_KEY ||
|
||||
!env.S3_UPLOAD_REGION ||
|
||||
!env.S3_UPLOAD_SECRET)
|
||||
) {
|
||||
ctx.addIssue({
|
||||
code: ZodIssueCode.custom,
|
||||
message:
|
||||
'If NEXT_PUBLIC_ENABLE_EXPENSE_DOCUMENTS is specified, then S3_* must be specified too',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export const env = envSchema.parse(process.env)
|
||||
|
||||
Reference in New Issue
Block a user