feat: correctly subs out ability to boot REST API within same process
This commit is contained in:
3
test/REST_API/.env.test
Normal file
3
test/REST_API/.env.test
Normal file
@@ -0,0 +1,3 @@
|
||||
PAYLOAD_SECRET=PAYLOAD_CUSTOM_SERVER_EXAMPLE_SECRET_KEY
|
||||
APP_ENV=test
|
||||
__NEXT_TEST_MODE=jest
|
||||
5
test/REST_API/next-env.d.ts
vendored
Normal file
5
test/REST_API/next-env.d.ts
vendored
Normal file
@@ -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/basic-features/typescript for more information.
|
||||
37
test/REST_API/next.config.js
Normal file
37
test/REST_API/next.config.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
experimental: {
|
||||
outputFileTracingExcludes: {
|
||||
'**/*': ['drizzle-kit', 'drizzle-kit/utils'],
|
||||
},
|
||||
serverComponentsExternalPackages: [
|
||||
'drizzle-kit',
|
||||
'drizzle-kit/utils',
|
||||
'pino',
|
||||
'pino-pretty',
|
||||
'mongodb-memory-server',
|
||||
],
|
||||
},
|
||||
reactStrictMode: false,
|
||||
// transpilePackages: ['@payloadcms/db-mongodb', 'mongoose'],
|
||||
webpack: (config) => {
|
||||
if (process.env.PAYLOAD_CONFIG_PATH) {
|
||||
config.resolve.alias['payload-config'] = process.env.PAYLOAD_CONFIG_PATH
|
||||
}
|
||||
|
||||
return {
|
||||
...config,
|
||||
externals: [
|
||||
...config.externals,
|
||||
'drizzle-kit',
|
||||
'drizzle-kit/utils',
|
||||
'pino',
|
||||
'pino-pretty',
|
||||
'mongoose',
|
||||
'sharp',
|
||||
],
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = nextConfig
|
||||
26
test/REST_API/package.json
Normal file
26
test/REST_API/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "dev",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@payloadcms/db-mongodb": "workspace:*",
|
||||
"@payloadcms/next": "workspace:*",
|
||||
"next": "14.1.1-canary.26",
|
||||
"payload": "workspace:*",
|
||||
"react": "18.3.0-canary-247738465-20240130",
|
||||
"react-dom": "18.3.0-canary-247738465-20240130"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"sass": "^1.69.5",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
4
test/REST_API/src/app/(payload)/api/[...slug]/route.ts
Normal file
4
test/REST_API/src/app/(payload)/api/[...slug]/route.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
/* DO NOT MODIFY it because it could be re-written at any time. */
|
||||
|
||||
export { DELETE, GET, PATCH, POST } from '@payloadcms/next/routes'
|
||||
3
test/REST_API/src/app/(payload)/api/test/route.ts
Normal file
3
test/REST_API/src/app/(payload)/api/test/route.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const GET = async (request: Request) => {
|
||||
return Response.json({ message: 'Hello world!' })
|
||||
}
|
||||
32
test/REST_API/tsconfig.json
Normal file
32
test/REST_API/tsconfig.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
"noEmit": true,
|
||||
"incremental": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"target": "ESNext",
|
||||
"composite": true, // Make sure typescript knows that this module depends on their references
|
||||
"allowImportingTsExtensions": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@payloadcms/db-mongodb": ["../../packages/db-mongodb/src"],
|
||||
"@payloadcms/next/*": ["../../packages/next/src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"],
|
||||
"composite": true, // Make sure typescript knows that this module depends on their references
|
||||
"references": [{ "path": "../../packages/next" }, { "path": "../../packages/db-mongodb" }]
|
||||
}
|
||||
Reference in New Issue
Block a user