11import sharp from "sharp" ;
22import { lexicalEditor } from "@payloadcms/richtext-lexical" ;
33import { mongooseAdapter } from "@payloadcms/db-mongodb" ;
4+ import { nodemailerAdapter } from "@payloadcms/email-nodemailer" ;
45import { buildConfig , CollectionConfig , GlobalConfig } from "payload" ;
56import path from "path" ;
67import { fileURLToPath } from "url" ;
@@ -23,9 +24,27 @@ const csrf =
2324 ?. map ( ( d ) => d . trim ( ) )
2425 ?. filter ( Boolean ) ?? [ ] ;
2526
27+ let email = nodemailerAdapter ( ) ;
28+ if ( process . env . SMTP_HOST && process . env . SMTP_PASS ) {
29+ const smtpPort = Number ( process . env . SMTP_PORT ) || 587 ;
30+ email = nodemailerAdapter ( {
31+ defaultFromAddress :
32+ process . env . SMTP_FROM_ADDRESS || "[email protected] " , 33+ defaultFromName : process . env . SENDGRID_FROM_NAME || "TrustLab CMS" ,
34+ // Any Nodemailer transport can be used
35+ transportOptions : {
36+ host : process . env . SMTP_HOST ,
37+ port : smtpPort ,
38+ secure : smtpPort === 465 , // true for port 465, false (the default) for others
39+ auth : {
40+ user : process . env . SMTP_USER || "apikey" ,
41+ pass : process . env . SMTP_PASS ,
42+ } ,
43+ } ,
44+ } ) ;
45+ }
46+
2647export default buildConfig ( {
27- serverURL : process . env . NEXT_PUBLIC_APP_URL ,
28- editor : lexicalEditor ( ) ,
2948 admin : {
3049 importMap : {
3150 baseDir : path . resolve ( dirname ) ,
@@ -34,6 +53,11 @@ export default buildConfig({
3453 collections : [ Pages , Media , Users ] as CollectionConfig [ ] ,
3554 cors,
3655 csrf,
56+ db : mongooseAdapter ( {
57+ url : process . env . MONGO_URL || "" ,
58+ } ) ,
59+ email,
60+ editor : lexicalEditor ( ) ,
3761 globals : [ SiteSettings ] as GlobalConfig [ ] ,
3862 ...( locales ?. length
3963 ? {
@@ -44,14 +68,11 @@ export default buildConfig({
4468 } ,
4569 }
4670 : undefined ) ,
71+ plugins : [ ...plugins ] ,
4772 secret : process . env . PAYLOAD_SECRET || "" ,
48- db : mongooseAdapter ( {
49- url : process . env . MONGO_URL || "" ,
50- } ) ,
73+ serverURL : process . env . NEXT_PUBLIC_APP_URL ,
74+ sharp,
5175 typescript : {
5276 outputFile : path . resolve ( dirname , "payload-types.ts" ) ,
5377 } ,
54- plugins : [ ...plugins ] ,
55-
56- sharp,
5778} ) ;
0 commit comments