This commit is contained in:
龟男日记\www 2026-02-08 23:40:05 +08:00
parent 1692cee9aa
commit a7da4da87c
6 changed files with 1828 additions and 35 deletions

View File

@ -10,23 +10,23 @@ services:
- node_modules:/home/node/app/node_modules - node_modules:/home/node/app/node_modules
working_dir: /home/node/app/ working_dir: /home/node/app/
command: sh -c "corepack enable && corepack prepare pnpm@latest --activate && pnpm install && pnpm dev" command: sh -c "corepack enable && corepack prepare pnpm@latest --activate && pnpm install && pnpm dev"
depends_on: # depends_on:
- mongo # - mongo
# - postgres # - postgres
env_file: env_file:
- .env - .env
# Ensure your DATABASE_URL uses 'mongo' as the hostname ie. mongodb://mongo/my-db-name # Ensure your DATABASE_URL uses 'mongo' as the hostname ie. mongodb://mongo/my-db-name
mongo: # mongo:
image: mongo:latest # image: mongo:latest
ports: # ports:
- '27017:27017' # - '27017:27017'
command: # command:
- --storageEngine=wiredTiger # - --storageEngine=wiredTiger
volumes: # volumes:
- data:/data/db # - data:/data/db
logging: # logging:
driver: none # driver: none
# Uncomment the following to use postgres # Uncomment the following to use postgres
# postgres: # postgres:

View File

@ -18,8 +18,12 @@
"test:int": "cross-env NODE_OPTIONS=--no-deprecation vitest run --config ./vitest.config.mts" "test:int": "cross-env NODE_OPTIONS=--no-deprecation vitest run --config ./vitest.config.mts"
}, },
"dependencies": { "dependencies": {
"@payloadcms/db-postgres": "3.75.0",
"@payloadcms/next": "3.75.0", "@payloadcms/next": "3.75.0",
"@payloadcms/plugin-cloud": "^3.0.2",
"@payloadcms/plugin-cloud-storage": "^3.75.0",
"@payloadcms/richtext-lexical": "3.75.0", "@payloadcms/richtext-lexical": "3.75.0",
"@payloadcms/storage-s3": "^3.75.0",
"@payloadcms/ui": "3.75.0", "@payloadcms/ui": "3.75.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"dotenv": "16.4.7", "dotenv": "16.4.7",
@ -28,8 +32,7 @@
"payload": "3.75.0", "payload": "3.75.0",
"react": "19.2.1", "react": "19.2.1",
"react-dom": "19.2.1", "react-dom": "19.2.1",
"sharp": "0.34.2", "sharp": "0.34.2"
"@payloadcms/db-postgres": "3.75.0"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "1.56.1", "@playwright/test": "1.56.1",

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
import { S3ClientUploadHandler as S3ClientUploadHandler_f97aa6c64367fa259c5bc0567239ef24 } from '@payloadcms/storage-s3/client'
import { CollectionCards as CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1 } from '@payloadcms/next/rsc' import { CollectionCards as CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1 } from '@payloadcms/next/rsc'
export const importMap = { export const importMap = {
'@payloadcms/next/rsc#CollectionCards': CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1, "@payloadcms/storage-s3/client#S3ClientUploadHandler": S3ClientUploadHandler_f97aa6c64367fa259c5bc0567239ef24,
"@payloadcms/next/rsc#CollectionCards": CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1
} }

View File

@ -84,7 +84,7 @@ export interface Config {
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>; 'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
}; };
db: { db: {
defaultIDType: string; defaultIDType: number;
}; };
fallbackLocale: null; fallbackLocale: null;
globals: {}; globals: {};
@ -119,7 +119,7 @@ export interface UserAuthOperations {
* via the `definition` "users". * via the `definition` "users".
*/ */
export interface User { export interface User {
id: string; id: number;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
email: string; email: string;
@ -144,7 +144,7 @@ export interface User {
* via the `definition` "media". * via the `definition` "media".
*/ */
export interface Media { export interface Media {
id: string; id: number;
alt: string; alt: string;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
@ -163,7 +163,7 @@ export interface Media {
* via the `definition` "payload-kv". * via the `definition` "payload-kv".
*/ */
export interface PayloadKv { export interface PayloadKv {
id: string; id: number;
key: string; key: string;
data: data:
| { | {
@ -180,20 +180,20 @@ export interface PayloadKv {
* via the `definition` "payload-locked-documents". * via the `definition` "payload-locked-documents".
*/ */
export interface PayloadLockedDocument { export interface PayloadLockedDocument {
id: string; id: number;
document?: document?:
| ({ | ({
relationTo: 'users'; relationTo: 'users';
value: string | User; value: number | User;
} | null) } | null)
| ({ | ({
relationTo: 'media'; relationTo: 'media';
value: string | Media; value: number | Media;
} | null); } | null);
globalSlug?: string | null; globalSlug?: string | null;
user: { user: {
relationTo: 'users'; relationTo: 'users';
value: string | User; value: number | User;
}; };
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
@ -203,10 +203,10 @@ export interface PayloadLockedDocument {
* via the `definition` "payload-preferences". * via the `definition` "payload-preferences".
*/ */
export interface PayloadPreference { export interface PayloadPreference {
id: string; id: number;
user: { user: {
relationTo: 'users'; relationTo: 'users';
value: string | User; value: number | User;
}; };
key?: string | null; key?: string | null;
value?: value?:
@ -226,7 +226,7 @@ export interface PayloadPreference {
* via the `definition` "payload-migrations". * via the `definition` "payload-migrations".
*/ */
export interface PayloadMigration { export interface PayloadMigration {
id: string; id: number;
name?: string | null; name?: string | null;
batch?: number | null; batch?: number | null;
updatedAt: string; updatedAt: string;

View File

@ -7,6 +7,7 @@ import sharp from 'sharp'
import { Users } from './collections/Users' import { Users } from './collections/Users'
import { Media } from './collections/Media' import { Media } from './collections/Media'
import { s3Storage } from '@payloadcms/storage-s3'
const filename = fileURLToPath(import.meta.url) const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename) const dirname = path.dirname(filename)
@ -30,5 +31,26 @@ export default buildConfig({
}, },
}), }),
sharp, sharp,
plugins: [], plugins: [
// Cloudflare R2 Storage via S3 API
s3Storage({
collections: {
media: {
disableLocalStorage: true,
generateFileURL: ({ filename }) => {
return `${process.env.CLOUDFLARE_R2_PUBLIC_URL}/${filename}`
},
},
},
bucket: process.env.CLOUDFLARE_R2_BUCKET || '',
config: {
credentials: {
accessKeyId: process.env.CLOUDFLARE_R2_ACCESS_KEY_ID || '',
secretAccessKey: process.env.CLOUDFLARE_R2_SECRET_ACCESS_KEY || '',
},
region: process.env.CLOUDFLARE_R2_REGION || 'auto',
endpoint: process.env.CLOUDFLARE_R2_ENDPOINT || '',
},
}),
],
}) })