74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { buildConfig } from 'payload';
|
|
import { postgresAdapter } from '@payloadcms/db-postgres';
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
|
|
import { Users } from './payload/collections/Users';
|
|
import { Services } from './payload/collections/Services';
|
|
import { Realisations } from './payload/collections/Realisations';
|
|
import { Articles } from './payload/collections/Articles';
|
|
import { Testimonials } from './payload/collections/Testimonials';
|
|
import { FAQ } from './payload/collections/FAQ';
|
|
import { Media } from './payload/collections/Media';
|
|
|
|
import nodemailer, { type Transporter } from 'nodemailer';
|
|
|
|
const serverURL = process.env.NEXT_PUBLIC_SERVER_URL || '';
|
|
|
|
const transporter: Transporter = nodemailer.createTransport({
|
|
host: process.env.SMTP_HOST,
|
|
port: Number(process.env.SMTP_PORT) || 587,
|
|
secure: false,
|
|
auth: {
|
|
user: process.env.SMTP_USER,
|
|
pass: process.env.SMTP_PASS,
|
|
},
|
|
});
|
|
|
|
// on tape en `any` pour ne plus se battre avec EmailAdapter
|
|
const emailAdapter: any = {
|
|
sendEmail: async ({
|
|
to,
|
|
subject,
|
|
html,
|
|
text,
|
|
from,
|
|
}: {
|
|
to: string | string[];
|
|
subject: string;
|
|
html: string;
|
|
text: string;
|
|
from?: string;
|
|
}) => {
|
|
await transporter.sendMail({
|
|
from: from ?? '"OBC Maçonnerie" <no-reply@obc-maconnerie.com>',
|
|
to,
|
|
subject,
|
|
html,
|
|
text,
|
|
});
|
|
},
|
|
};
|
|
|
|
export default buildConfig({
|
|
secret: process.env.PAYLOAD_SECRET || 'change-moi',
|
|
serverURL,
|
|
cors: serverURL ? [serverURL] : '*',
|
|
editor: lexicalEditor(),
|
|
routes: {
|
|
admin: '/gestion59',
|
|
api: '/gestion59/api',
|
|
},
|
|
admin: {
|
|
user: 'users',
|
|
},
|
|
email: emailAdapter,
|
|
db: postgresAdapter({
|
|
pool: {
|
|
connectionString: process.env.DATABASE_URL!,
|
|
},
|
|
push: true,
|
|
}),
|
|
collections: [Users, Services, Realisations, Articles, Testimonials, FAQ, Media],
|
|
globals: [],
|
|
});
|