Skip to content

Commit fdfa07b

Browse files
authored
feat(examples): add custom server example [skip-lint] (#9641)
Example using [Next.js Custom Server](https://nextjs.org/docs/pages/building-your-application/configuring/custom-server) with express. Made from official [examples/custom-server](https://github.com/vercel/next.js/tree/canary/examples/custom-server) from Next.js repository.
1 parent 519752f commit fdfa07b

File tree

23 files changed

+933
-0
lines changed

23 files changed

+933
-0
lines changed

examples/custom-server/.gitignore

Lines changed: 367 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,367 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/node,macos,windows,webstorm,sublimetext,visualstudiocode
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=node,macos,windows,webstorm,sublimetext,visualstudiocode
3+
4+
### macOS ###
5+
# General
6+
.DS_Store
7+
.AppleDouble
8+
.LSOverride
9+
10+
# Icon must end with two \r
11+
Icon
12+
13+
# Thumbnails
14+
._*
15+
16+
# Files that might appear in the root of a volume
17+
.DocumentRevisions-V100
18+
.fseventsd
19+
.Spotlight-V100
20+
.TemporaryItems
21+
.Trashes
22+
.VolumeIcon.icns
23+
.com.apple.timemachine.donotpresent
24+
25+
# Directories potentially created on remote AFP share
26+
.AppleDB
27+
.AppleDesktop
28+
Network Trash Folder
29+
Temporary Items
30+
.apdisk
31+
32+
### macOS Patch ###
33+
# iCloud generated files
34+
*.icloud
35+
36+
### Node ###
37+
# Logs
38+
logs
39+
*.log
40+
npm-debug.log*
41+
yarn-debug.log*
42+
yarn-error.log*
43+
lerna-debug.log*
44+
.pnpm-debug.log*
45+
46+
# Diagnostic reports (https://nodejs.org/api/report.html)
47+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
48+
49+
# Runtime data
50+
pids
51+
*.pid
52+
*.seed
53+
*.pid.lock
54+
55+
# Directory for instrumented libs generated by jscoverage/JSCover
56+
lib-cov
57+
58+
# Coverage directory used by tools like istanbul
59+
coverage
60+
*.lcov
61+
62+
# nyc test coverage
63+
.nyc_output
64+
65+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
66+
.grunt
67+
68+
# Bower dependency directory (https://bower.io/)
69+
bower_components
70+
71+
# node-waf configuration
72+
.lock-wscript
73+
74+
# Compiled binary addons (https://nodejs.org/api/addons.html)
75+
build/Release
76+
77+
# Dependency directories
78+
node_modules/
79+
jspm_packages/
80+
81+
# Snowpack dependency directory (https://snowpack.dev/)
82+
web_modules/
83+
84+
# TypeScript cache
85+
*.tsbuildinfo
86+
87+
# Optional npm cache directory
88+
.npm
89+
90+
# Optional eslint cache
91+
.eslintcache
92+
93+
# Optional stylelint cache
94+
.stylelintcache
95+
96+
# Microbundle cache
97+
.rpt2_cache/
98+
.rts2_cache_cjs/
99+
.rts2_cache_es/
100+
.rts2_cache_umd/
101+
102+
# Optional REPL history
103+
.node_repl_history
104+
105+
# Output of 'npm pack'
106+
*.tgz
107+
108+
# Yarn Integrity file
109+
.yarn-integrity
110+
111+
# dotenv environment variable files
112+
.env
113+
.env.development.local
114+
.env.test.local
115+
.env.production.local
116+
.env.local
117+
118+
# parcel-bundler cache (https://parceljs.org/)
119+
.cache
120+
.parcel-cache
121+
122+
# Next.js build output
123+
.next
124+
out
125+
126+
# Nuxt.js build / generate output
127+
.nuxt
128+
dist
129+
130+
# Gatsby files
131+
.cache/
132+
# Comment in the public line in if your project uses Gatsby and not Next.js
133+
# https://nextjs.org/blog/next-9-1#public-directory-support
134+
# public
135+
136+
# vuepress build output
137+
.vuepress/dist
138+
139+
# vuepress v2.x temp and cache directory
140+
.temp
141+
142+
# Docusaurus cache and generated files
143+
.docusaurus
144+
145+
# Serverless directories
146+
.serverless/
147+
148+
# FuseBox cache
149+
.fusebox/
150+
151+
# DynamoDB Local files
152+
.dynamodb/
153+
154+
# TernJS port file
155+
.tern-port
156+
157+
# Stores VSCode versions used for testing VSCode extensions
158+
.vscode-test
159+
160+
# yarn v2
161+
.yarn/cache
162+
.yarn/unplugged
163+
.yarn/build-state.yml
164+
.yarn/install-state.gz
165+
.pnp.*
166+
167+
### Node Patch ###
168+
# Serverless Webpack directories
169+
.webpack/
170+
171+
# Optional stylelint cache
172+
173+
# SvelteKit build / generate output
174+
.svelte-kit
175+
176+
### SublimeText ###
177+
# Cache files for Sublime Text
178+
*.tmlanguage.cache
179+
*.tmPreferences.cache
180+
*.stTheme.cache
181+
182+
# Workspace files are user-specific
183+
*.sublime-workspace
184+
185+
# Project files should be checked into the repository, unless a significant
186+
# proportion of contributors will probably not be using Sublime Text
187+
# *.sublime-project
188+
189+
# SFTP configuration file
190+
sftp-config.json
191+
sftp-config-alt*.json
192+
193+
# Package control specific files
194+
Package Control.last-run
195+
Package Control.ca-list
196+
Package Control.ca-bundle
197+
Package Control.system-ca-bundle
198+
Package Control.cache/
199+
Package Control.ca-certs/
200+
Package Control.merged-ca-bundle
201+
Package Control.user-ca-bundle
202+
oscrypto-ca-bundle.crt
203+
bh_unicode_properties.cache
204+
205+
# Sublime-github package stores a github token in this file
206+
# https://packagecontrol.io/packages/sublime-github
207+
GitHub.sublime-settings
208+
209+
### VisualStudioCode ###
210+
.vscode/*
211+
!.vscode/settings.json
212+
!.vscode/tasks.json
213+
!.vscode/launch.json
214+
!.vscode/extensions.json
215+
!.vscode/*.code-snippets
216+
217+
# Local History for Visual Studio Code
218+
.history/
219+
220+
# Built Visual Studio Code Extensions
221+
*.vsix
222+
223+
### VisualStudioCode Patch ###
224+
# Ignore all local history of files
225+
.history
226+
.ionide
227+
228+
### WebStorm ###
229+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
230+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
231+
232+
# User-specific stuff
233+
.idea/**/workspace.xml
234+
.idea/**/tasks.xml
235+
.idea/**/usage.statistics.xml
236+
.idea/**/dictionaries
237+
.idea/**/shelf
238+
239+
# AWS User-specific
240+
.idea/**/aws.xml
241+
242+
# Generated files
243+
.idea/**/contentModel.xml
244+
245+
# Sensitive or high-churn files
246+
.idea/**/dataSources/
247+
.idea/**/dataSources.ids
248+
.idea/**/dataSources.local.xml
249+
.idea/**/sqlDataSources.xml
250+
.idea/**/dynamic.xml
251+
.idea/**/uiDesigner.xml
252+
.idea/**/dbnavigator.xml
253+
254+
# Gradle
255+
.idea/**/gradle.xml
256+
.idea/**/libraries
257+
258+
# Gradle and Maven with auto-import
259+
# When using Gradle or Maven with auto-import, you should exclude module files,
260+
# since they will be recreated, and may cause churn. Uncomment if using
261+
# auto-import.
262+
# .idea/artifacts
263+
# .idea/compiler.xml
264+
# .idea/jarRepositories.xml
265+
# .idea/modules.xml
266+
# .idea/*.iml
267+
# .idea/modules
268+
# *.iml
269+
# *.ipr
270+
271+
# CMake
272+
cmake-build-*/
273+
274+
# Mongo Explorer plugin
275+
.idea/**/mongoSettings.xml
276+
277+
# File-based project format
278+
*.iws
279+
280+
# IntelliJ
281+
out/
282+
283+
# mpeltonen/sbt-idea plugin
284+
.idea_modules/
285+
286+
# JIRA plugin
287+
atlassian-ide-plugin.xml
288+
289+
# Cursive Clojure plugin
290+
.idea/replstate.xml
291+
292+
# SonarLint plugin
293+
.idea/sonarlint/
294+
295+
# Crashlytics plugin (for Android Studio and IntelliJ)
296+
com_crashlytics_export_strings.xml
297+
crashlytics.properties
298+
crashlytics-build.properties
299+
fabric.properties
300+
301+
# Editor-based Rest Client
302+
.idea/httpRequests
303+
304+
# Android studio 3.1+ serialized cache file
305+
.idea/caches/build_file_checksums.ser
306+
307+
### WebStorm Patch ###
308+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
309+
310+
# *.iml
311+
# modules.xml
312+
# .idea/misc.xml
313+
# *.ipr
314+
315+
# Sonarlint plugin
316+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
317+
.idea/**/sonarlint/
318+
319+
# SonarQube Plugin
320+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
321+
.idea/**/sonarIssues.xml
322+
323+
# Markdown Navigator plugin
324+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
325+
.idea/**/markdown-navigator.xml
326+
.idea/**/markdown-navigator-enh.xml
327+
.idea/**/markdown-navigator/
328+
329+
# Cache file creation bug
330+
# See https://youtrack.jetbrains.com/issue/JBR-2257
331+
.idea/$CACHE_FILE$
332+
333+
# CodeStream plugin
334+
# https://plugins.jetbrains.com/plugin/12206-codestream
335+
.idea/codestream.xml
336+
337+
# Azure Toolkit for IntelliJ plugin
338+
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
339+
.idea/**/azureSettings.xml
340+
341+
### Windows ###
342+
# Windows thumbnail cache files
343+
Thumbs.db
344+
Thumbs.db:encryptable
345+
ehthumbs.db
346+
ehthumbs_vista.db
347+
348+
# Dump file
349+
*.stackdump
350+
351+
# Folder config file
352+
[Dd]esktop.ini
353+
354+
# Recycle Bin used on file shares
355+
$RECYCLE.BIN/
356+
357+
# Windows Installer files
358+
*.cab
359+
*.msi
360+
*.msix
361+
*.msm
362+
*.msp
363+
364+
# Windows shortcuts
365+
*.lnk
366+
367+
# End of https://www.toptal.com/developers/gitignore/api/node,macos,windows,webstorm,sublimetext,visualstudiocode

examples/custom-server/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Payload 3 with Custom Server
2+
3+
Uses a [Next.js Custom Server](https://nextjs.org/docs/pages/building-your-application/configuring/custom-server) with express.
4+
5+
Made from official [examples/custom-server](https://github.com/vercel/next.js/tree/canary/examples/custom-server) from Next.js repository.

examples/custom-server/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

examples/custom-server/next.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { withPayload } from "@payloadcms/next/withPayload";
2+
import type { NextConfig } from 'next'
3+
4+
const nextConfig: NextConfig = {}
5+
6+
export default withPayload(nextConfig)

examples/custom-server/nodemon.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"watch": ["src/server.ts"],
3+
"exec": "tsx src/server.ts",
4+
"ext": "ts"
5+
}

0 commit comments

Comments
 (0)