155 lines
5.0 KiB
TypeScript
155 lines
5.0 KiB
TypeScript
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { buildConfig } from 'payload'
|
|
import { postgresAdapter } from '@payloadcms/db-postgres'
|
|
import { en } from '@payloadcms/translations/languages/en'
|
|
import { zh } from '@payloadcms/translations/languages/zh'
|
|
import sharp from 'sharp'
|
|
import { eversoloRichTextEditor } from './payload/rich-text-editor'
|
|
import { Media } from './payload/collections/Media'
|
|
import { Files } from './payload/collections/Files'
|
|
import { Videos } from './payload/collections/Videos'
|
|
import { Products } from './payload/collections/Products'
|
|
import { ProductCategories } from './payload/collections/ProductCategories'
|
|
import { Downloads } from './payload/collections/Downloads'
|
|
import { FAQs } from './payload/collections/FAQs'
|
|
import { Dealers } from './payload/collections/Dealers'
|
|
import { News } from './payload/collections/News'
|
|
import { NewsCategories } from './payload/collections/NewsCategories'
|
|
import { Redirects } from './payload/collections/Redirects'
|
|
import { Users } from './payload/collections/Users'
|
|
import { ProductVideos } from './payload/collections/ProductVideos'
|
|
import { ProductReviews } from './payload/collections/ProductReviews'
|
|
import { SupportTutorialVideos } from './payload/collections/SupportTutorialVideos'
|
|
import { AfterServiceRequests } from './payload/collections/AfterServiceRequests'
|
|
import { DistributorRequests } from './payload/collections/DistributorRequests'
|
|
import { OemRequests } from './payload/collections/OemRequests'
|
|
import { Homepage } from './payload/globals/Homepage'
|
|
import { GlobalSettings } from './payload/globals/GlobalSettings'
|
|
import { AboutPage } from './payload/globals/AboutPage'
|
|
import { SupportPage } from './payload/globals/SupportPage'
|
|
import { ContactPage } from './payload/globals/ContactPage'
|
|
import { ContactUsPage } from './payload/globals/ContactUsPage'
|
|
import { DealersPage } from './payload/globals/DealersPage'
|
|
import { NewsPage } from './payload/globals/NewsPage'
|
|
import { WarrantyPage } from './payload/globals/WarrantyPage'
|
|
import { ProductsPage } from './payload/globals/ProductsPage'
|
|
import { DownloadsPage } from './payload/globals/DownloadsPage'
|
|
import { ReviewsPage } from './payload/globals/ReviewsPage'
|
|
import { SupportTutorialPage } from './payload/globals/SupportTutorialPage'
|
|
import { migrations } from './migrations'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
const shouldPushSchema =
|
|
process.env.PAYLOAD_DB_PUSH === 'true' ||
|
|
(process.env.NODE_ENV !== 'production' && process.env.PAYLOAD_DB_PUSH !== 'false')
|
|
const shouldRunProdMigrationsOnStart = process.env.PAYLOAD_RUN_MIGRATIONS_ON_START === 'true'
|
|
const payloadSecret = process.env.PAYLOAD_SECRET
|
|
|
|
if (
|
|
process.env.NODE_ENV === 'production' &&
|
|
(!payloadSecret || payloadSecret === 'change-me' || payloadSecret === 'replace-me-with-a-long-random-string')
|
|
) {
|
|
throw new Error('PAYLOAD_SECRET must be set to a strong production value before starting Payload.')
|
|
}
|
|
|
|
export default buildConfig({
|
|
admin: {
|
|
avatar: {
|
|
Component: {
|
|
path: '@/app/(payload)/admin/_components/admin-avatar-menu',
|
|
exportName: 'AdminAvatarMenu',
|
|
},
|
|
},
|
|
components: {
|
|
graphics: {
|
|
Icon: {
|
|
path: '@/app/(payload)/admin/_components/eversolo-admin-logo',
|
|
exportName: 'EversoloAdminIcon',
|
|
},
|
|
Logo: {
|
|
path: '@/app/(payload)/admin/_components/eversolo-admin-logo',
|
|
exportName: 'EversoloAdminLogo',
|
|
},
|
|
},
|
|
providers: [
|
|
{
|
|
path: '@/app/(payload)/admin/_components/eversolo-paste-url-fetch-provider',
|
|
exportName: 'EversoloPasteURLFetchProvider',
|
|
},
|
|
],
|
|
},
|
|
user: Users.slug,
|
|
},
|
|
i18n: {
|
|
fallbackLanguage: 'en',
|
|
supportedLanguages: {
|
|
en,
|
|
zh,
|
|
},
|
|
},
|
|
editor: eversoloRichTextEditor,
|
|
collections: [
|
|
Users,
|
|
Media,
|
|
Files,
|
|
Videos,
|
|
Products,
|
|
ProductCategories,
|
|
Downloads,
|
|
FAQs,
|
|
Dealers,
|
|
NewsCategories,
|
|
News,
|
|
ProductVideos,
|
|
ProductReviews,
|
|
SupportTutorialVideos,
|
|
AfterServiceRequests,
|
|
DistributorRequests,
|
|
OemRequests,
|
|
Redirects,
|
|
],
|
|
globals: [
|
|
Homepage,
|
|
GlobalSettings,
|
|
AboutPage,
|
|
ContactUsPage,
|
|
SupportPage,
|
|
ContactPage,
|
|
WarrantyPage,
|
|
ProductsPage,
|
|
DownloadsPage,
|
|
ReviewsPage,
|
|
SupportTutorialPage,
|
|
NewsPage,
|
|
DealersPage,
|
|
],
|
|
localization: {
|
|
locales: [
|
|
{ label: 'English', code: 'en' },
|
|
{ label: '简体中文', code: 'zh' },
|
|
],
|
|
defaultLocale: 'en',
|
|
fallback: false,
|
|
},
|
|
secret: payloadSecret ?? 'development-payload-secret',
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
db: postgresAdapter({
|
|
pool: {
|
|
connectionString: process.env.DATABASE_URI ?? '',
|
|
},
|
|
migrationDir: path.resolve(dirname, 'migrations'),
|
|
push: shouldPushSchema,
|
|
prodMigrations: shouldRunProdMigrationsOnStart ? migrations : undefined,
|
|
}),
|
|
upload: {
|
|
limits: {
|
|
fileSize: 500 * 1024 * 1024,
|
|
},
|
|
},
|
|
sharp,
|
|
})
|