-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: add example on Remix + Payload Local API
- Loading branch information
Showing
44 changed files
with
12,519 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "remix-payload-monorepo", | ||
"version": "1.0.0", | ||
"description": "", | ||
"keywords": [], | ||
"license": "ISC", | ||
"author": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"dev:payload": "cd payload && pnpm dev", | ||
"dev:website": "cd website && pnpm dev", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DATABASE_URI=mongodb://127.0.0.1/payload-template-blank-3-0 | ||
PAYLOAD_SECRET=YOUR_SECRET_HERE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 100, | ||
"semi": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# From https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile | ||
|
||
FROM node:18-alpine AS base | ||
|
||
# Install dependencies only when needed | ||
FROM base AS deps | ||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
|
||
# Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line in case you want to disable telemetry during the build. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN \ | ||
if [ -f yarn.lock ]; then yarn run build; \ | ||
elif [ -f package-lock.json ]; then npm run build; \ | ||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
# Production image, copy all the files and run next | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
# Uncomment the following line in case you want to disable telemetry during runtime. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
# Remove this line if you do not have this folder | ||
COPY --from=builder /app/public ./public | ||
|
||
# Set the correct permission for prerender cache | ||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
|
||
# server.js is created by next build from the standalone output | ||
# https://nextjs.org/docs/pages/api-reference/next-config-js/output | ||
CMD HOSTNAME="0.0.0.0" node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# blank | ||
|
||
blank | ||
|
||
## Attributes | ||
|
||
- **Database**: mongodb | ||
- **Storage Adapter**: localDisk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
version: '3' | ||
|
||
services: | ||
payload: | ||
image: node:18-alpine | ||
ports: | ||
- '3000:3000' | ||
volumes: | ||
- .:/home/node/app | ||
- node_modules:/home/node/app/node_modules | ||
working_dir: /home/node/app/ | ||
command: sh -c "corepack enable && corepack prepare pnpm@latest --activate && pnpm install && pnpm dev" | ||
depends_on: | ||
- mongo | ||
# - postgres | ||
env_file: | ||
- .env | ||
|
||
# Ensure your DATABASE_URI uses 'mongo' as the hostname ie. mongodb://mongo/my-db-name | ||
mongo: | ||
image: mongo:latest | ||
ports: | ||
- '27017:27017' | ||
command: | ||
- --storageEngine=wiredTiger | ||
volumes: | ||
- data:/data/db | ||
logging: | ||
driver: none | ||
|
||
# Uncomment the following to use postgres | ||
# postgres: | ||
# restart: always | ||
# image: postgres:latest | ||
# volumes: | ||
# - pgdata:/var/lib/postgresql/data | ||
# ports: | ||
# - "5432:5432" | ||
|
||
volumes: | ||
data: | ||
# pgdata: | ||
node_modules: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { dirname } from 'path' | ||
import { fileURLToPath } from 'url' | ||
import { FlatCompat } from '@eslint/eslintrc' | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = dirname(__filename) | ||
|
||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
}) | ||
|
||
const eslintConfig = [ | ||
...compat.extends('next/core-web-vitals', 'next/typescript'), | ||
{ | ||
rules: { | ||
'@typescript-eslint/ban-ts-comment': 'warn', | ||
'@typescript-eslint/no-empty-object-type': 'warn', | ||
'@typescript-eslint/no-explicit-any': 'warn', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'warn', | ||
{ | ||
vars: 'all', | ||
args: 'after-used', | ||
ignoreRestSiblings: false, | ||
argsIgnorePattern: '^_', | ||
varsIgnorePattern: '^_', | ||
destructuredArrayIgnorePattern: '^_', | ||
caughtErrorsIgnorePattern: '^(_|ignore)', | ||
}, | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
export default eslintConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { withPayload } from '@payloadcms/next/withPayload' | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
// Your Next.js config here | ||
} | ||
|
||
export default withPayload(nextConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "payload-app", | ||
"version": "1.0.0", | ||
"description": "A blank template to get started with Payload 3.0", | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./src/index.ts", | ||
"types": "./src/index.ts", | ||
"default": "./src/index.ts" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "next build", | ||
"dev": "next dev", | ||
"devsafe": "rm -rf .next && next dev", | ||
"generate:importmap": "payload generate:importmap", | ||
"generate:types": "payload generate:types", | ||
"lint": "next lint", | ||
"payload": "payload", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"@payloadcms/db-mongodb": "3.11.0", | ||
"@payloadcms/next": "3.11.0", | ||
"@payloadcms/richtext-lexical": "3.11.0", | ||
"cross-env": "^7.0.3", | ||
"graphql": "^16.8.1", | ||
"next": "15.1.0", | ||
"payload": "3.11.0", | ||
"react": "19.0.0", | ||
"react-dom": "19.0.0", | ||
"sharp": "0.32.6" | ||
}, | ||
"devDependencies": { | ||
"@eslint/eslintrc": "^3.2.0", | ||
"@types/node": "^22.5.4", | ||
"@types/react": "19.0.1", | ||
"@types/react-dom": "19.0.1", | ||
"eslint": "^9.16.0", | ||
"eslint-config-next": "15.1.0", | ||
"prettier": "^3.4.2", | ||
"typescript": "5.7.2" | ||
}, | ||
"engines": { | ||
"node": "^18.20.2 || >=20.9.0" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
examples/remix/payload/src/app/(payload)/admin/[[...segments]]/not-found.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ | ||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ | ||
import type { Metadata } from 'next' | ||
|
||
import config from '@payload-config' | ||
import { NotFoundPage, generatePageMetadata } from '@payloadcms/next/views' | ||
import { importMap } from '../importMap' | ||
|
||
type Args = { | ||
params: Promise<{ | ||
segments: string[] | ||
}> | ||
searchParams: Promise<{ | ||
[key: string]: string | string[] | ||
}> | ||
} | ||
|
||
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> => | ||
generatePageMetadata({ config, params, searchParams }) | ||
|
||
const NotFound = ({ params, searchParams }: Args) => | ||
NotFoundPage({ config, params, searchParams, importMap }) | ||
|
||
export default NotFound |
24 changes: 24 additions & 0 deletions
24
examples/remix/payload/src/app/(payload)/admin/[[...segments]]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ | ||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ | ||
import type { Metadata } from 'next' | ||
|
||
import config from '@payload-config' | ||
import { RootPage, generatePageMetadata } from '@payloadcms/next/views' | ||
import { importMap } from '../importMap' | ||
|
||
type Args = { | ||
params: Promise<{ | ||
segments: string[] | ||
}> | ||
searchParams: Promise<{ | ||
[key: string]: string | string[] | ||
}> | ||
} | ||
|
||
export const generateMetadata = ({ params, searchParams }: Args): Promise<Metadata> => | ||
generatePageMetadata({ config, params, searchParams }) | ||
|
||
const Page = ({ params, searchParams }: Args) => | ||
RootPage({ config, params, searchParams, importMap }) | ||
|
||
export default Page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const importMap = {} |
19 changes: 19 additions & 0 deletions
19
examples/remix/payload/src/app/(payload)/api/[...slug]/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ | ||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ | ||
import config from '@payload-config' | ||
import '@payloadcms/next/css' | ||
import { | ||
REST_DELETE, | ||
REST_GET, | ||
REST_OPTIONS, | ||
REST_PATCH, | ||
REST_POST, | ||
REST_PUT, | ||
} from '@payloadcms/next/routes' | ||
|
||
export const GET = REST_GET(config) | ||
export const POST = REST_POST(config) | ||
export const DELETE = REST_DELETE(config) | ||
export const PATCH = REST_PATCH(config) | ||
export const PUT = REST_PUT(config) | ||
export const OPTIONS = REST_OPTIONS(config) |
7 changes: 7 additions & 0 deletions
7
examples/remix/payload/src/app/(payload)/api/graphql-playground/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ | ||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ | ||
import config from '@payload-config' | ||
import '@payloadcms/next/css' | ||
import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes' | ||
|
||
export const GET = GRAPHQL_PLAYGROUND_GET(config) |
8 changes: 8 additions & 0 deletions
8
examples/remix/payload/src/app/(payload)/api/graphql/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ | ||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ | ||
import config from '@payload-config' | ||
import { GRAPHQL_POST, REST_OPTIONS } from '@payloadcms/next/routes' | ||
|
||
export const POST = GRAPHQL_POST(config) | ||
|
||
export const OPTIONS = REST_OPTIONS(config) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ | ||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ | ||
import config from '@payload-config' | ||
import '@payloadcms/next/css' | ||
import type { ServerFunctionClient } from 'payload' | ||
import { handleServerFunctions, RootLayout } from '@payloadcms/next/layouts' | ||
import React from 'react' | ||
|
||
import { importMap } from './admin/importMap.js' | ||
import './custom.scss' | ||
|
||
type Args = { | ||
children: React.ReactNode | ||
} | ||
|
||
const serverFunction: ServerFunctionClient = async function (args) { | ||
'use server' | ||
return handleServerFunctions({ | ||
...args, | ||
config, | ||
importMap, | ||
}) | ||
} | ||
|
||
const Layout = ({ children }: Args) => ( | ||
<RootLayout config={config} importMap={importMap} serverFunction={serverFunction}> | ||
{children} | ||
</RootLayout> | ||
) | ||
|
||
export default Layout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import configPromise from '@payload-config' | ||
import { getPayload } from 'payload' | ||
|
||
export const GET = async () => { | ||
const payload = await getPayload({ | ||
config: configPromise, | ||
}) | ||
|
||
const data = await payload.find({ | ||
collection: 'users', | ||
}) | ||
|
||
return Response.json(data) | ||
} |
Oops, something went wrong.