-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpayload.config.ts
More file actions
97 lines (91 loc) · 2.32 KB
/
Copy pathpayload.config.ts
File metadata and controls
97 lines (91 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { postgresAdapter } from '@payloadcms/db-postgres'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from 'path'
import { buildConfig } from 'payload'
import { fileURLToPath } from 'url'
import sharp from 'sharp'
import {
Users,
Clients,
Media,
Plans,
Microcycles,
Workouts,
WorkoutGroups,
WorkoutExerciseRows,
WorkoutLogs,
RoundLogs,
SetLogs,
ExerciseLogs,
Exercises,
ShareLinks,
} from './collections'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const serverURL = process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000'
// Fail fast on a misconfigured deploy: a missing secret or DB URL should crash at
// startup with a clear message, not boot with an empty secret / no database.
function requiredEnv(name: string): string {
const value = process.env[name]
if (!value) throw new Error(`Missing required env var: ${name}`)
return value
}
const payloadSecret = requiredEnv('PAYLOAD_SECRET')
const databaseURL = requiredEnv('DATABASE_URL')
export default buildConfig({
serverURL,
// Restrict cross-origin requests and CSRF-trusted origins to our own domain.
cors: [serverURL],
csrf: [serverURL],
// GraphQL is not used by the app; disable it to shrink the public API surface.
graphQL: {
disable: true,
},
// Cap upload size at the multipart parser to reject oversized files early.
upload: {
limits: {
fileSize: 5_000_000, // 5 MB
},
abortOnLimit: true,
},
admin: {
user: Users.slug,
importMap: {
baseDir: path.resolve(dirname),
},
},
collections: [
Users,
Clients,
Media,
Plans,
Microcycles,
Workouts,
WorkoutGroups,
WorkoutExerciseRows,
WorkoutLogs,
RoundLogs,
SetLogs,
ExerciseLogs,
Exercises,
ShareLinks,
],
editor: lexicalEditor(),
secret: payloadSecret,
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
db: postgresAdapter({
// Never auto-sync schema from models. Schema changes go through migrations only
// (migrate:create + migrate), so `yarn dev` can never push to a remote/prod DB.
push: false,
pool: {
connectionString: databaseURL,
max: 10,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000,
},
logger: false,
}),
sharp,
})