-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayload.config.ts
More file actions
123 lines (121 loc) · 3.81 KB
/
payload.config.ts
File metadata and controls
123 lines (121 loc) · 3.81 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import path from "node:path";
import { fileURLToPath } from "node:url";
import { mongooseAdapter } from "@payloadcms/db-mongodb";
import { lexicalEditor } from "@payloadcms/richtext-lexical";
import { s3Storage } from "@payloadcms/storage-s3";
import { buildConfig } from "payload";
// sharp removed — native C++ addon incompatible with Cloudflare Workers.
// Images are stored at original size in R2 and served via presigned URLs.
import { AboutSections } from "./collections/AboutSections";
import { Customers } from "./collections/Customers";
import { Media } from "./collections/Media";
import { Orders } from "./collections/Orders";
import { PickupInstructionProfiles } from "./collections/PickupInstructionProfiles";
import { Schedules } from "./collections/Schedules";
import { Timeslots } from "./collections/Timeslots";
import { Users } from "./collections/Users";
import { BankDetails } from "./globals/BankDetails";
import { ContactInfo } from "./globals/ContactInfo";
import { ScheduleSettings } from "./globals/ScheduleSettings";
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
// Wrap in an async IIFE so that process.env is read at resolution time, not at
// module-load time. On Cloudflare Workers, env vars (secrets set via the
// dashboard) are only injected into process.env when the first request arrives.
// A bare `buildConfig({ url: process.env.DATABASE_URI })` would capture an empty
// string because the module is evaluated before any request triggers env setup.
export default (async () =>
buildConfig({
secret: process.env.PAYLOAD_SECRET || "CHANGE-ME-IN-PRODUCTION",
db: mongooseAdapter({
url: process.env.DATABASE_URI || "",
connectOptions: {
// Prevent indefinite hangs on Cloudflare Workers (stateless runtime).
// Without these, a slow or unreachable MongoDB will cause the Worker
// to hang until Cloudflare cancels the request.
serverSelectionTimeoutMS: 5000,
connectTimeoutMS: 5000,
socketTimeoutMS: 10000,
},
}),
editor: lexicalEditor(),
collections: [
Users,
Customers,
Orders,
Timeslots,
Schedules,
PickupInstructionProfiles,
AboutSections,
Media,
],
globals: [ContactInfo, BankDetails, ScheduleSettings],
plugins: [
...(process.env.R2_S3_ENDPOINT
? [
s3Storage({
collections: {
media: {
prefix: "media",
},
},
bucket: process.env.R2_BUCKET || "primalprinting-media",
config: {
endpoint: process.env.R2_S3_ENDPOINT,
credentials: {
accessKeyId: process.env.R2_ACCESS_KEY_ID || "",
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY || "",
},
region: "auto",
forcePathStyle: true,
},
}),
]
: []),
],
typescript: {
outputFile: path.resolve(dirname, "payload-types.ts"),
},
admin: {
user: Users.slug,
meta: {
titleSuffix: "- Primal Printing Admin",
},
importMap: {
baseDir: path.resolve(dirname),
},
components: {
views: {
ordersByTimeslot: {
Component: "@/components/admin/OrdersByTimeslotView",
path: "/orders-by-timeslot",
meta: {
title: "Orders by Timeslot",
},
},
pendingVerification: {
Component: "@/components/admin/PendingVerificationView",
path: "/verify-payments",
meta: {
title: "Verify Bank Transfers",
},
},
notifyTimeslots: {
Component: "@/components/admin/NotifyTimeslotsView",
path: "/notify-timeslots",
meta: {
title: "Notify Customers — Timeslots",
},
},
scheduleCalendar: {
Component: "@/components/admin/ScheduleCalendarView",
path: "/schedule-calendar",
meta: {
title: "Schedule Calendar",
},
},
},
afterNavLinks: ["@/components/admin/AdminNavLinks"],
},
},
}))();