Skip to content

Commit

Permalink
chore: update Next.js custom-server integration in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zthxxx committed Jun 30, 2024
1 parent 9dd936c commit 508cb24
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
process.env.ESLINT_TSCONFIG = 'tsconfig.json'
const jsonExtJsoncFiles = ['**/tsconfig.*.json', '.vscode/*.json']
const jsonExtJsoncFiles = [
'**/tsconfig.json',
'**/tsconfig.*.json',
'.vscode/*.json',
]

module.exports = {
root: true,
Expand Down
2 changes: 1 addition & 1 deletion docs/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://nextjs.org/docs/advanced-features/customizing-babel-config
// https://nextjs.org/docs/pages/building-your-application/configuring/babel
module.exports = {
presets: [
'next/babel',
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs/compiler-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Follow the docs of [Nextjs Babel configuration](https://nextjs.org/docs/pages/bu
add plugin to `.babelrc.js` or `babel.config.js`:

```tsx filename=".babelrc.js" showLineNumbers {8}
// https://nextjs.org/docs/advanced-features/customizing-babel-config
// https://nextjs.org/docs/pages/building-your-application/configuring/babel
module.exports = {
presets: [
'next/babel',
Expand Down
11 changes: 5 additions & 6 deletions docs/pages/docs/integration/nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Here provide a example template for your to create a `server.mjs` as custom serv

```js filename="server.mjs" showLineNumbers {6,27}
/**
* https://nextjs.org/docs/advanced-features/custom-server
* https://nextjs.org/docs/pages/building-your-application/configuring/custom-server
*/
import { createServer } from 'node:http'
import next from 'next'
Expand Down Expand Up @@ -80,12 +80,11 @@ app.prepare().then(() => {
}
})
.once('error', (err) => {
console.error(err)
process.exit(1)
})
console.error(err)
process.exit(1)
})
.listen(port, () => {
console.debug(`\n > Ready on http://${hostname}:${port} \n`)
})
console.debug(`\n > Ready on http://${hostname}:${port} \n`)
})
```
Expand Down
12 changes: 8 additions & 4 deletions docs/server.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* https://nextjs.org/docs/advanced-features/custom-server
* https://nextjs.org/docs/pages/building-your-application/configuring/custom-server
*/
import { createServer } from 'node:http'
import next from 'next'
Expand Down Expand Up @@ -49,8 +49,12 @@ app.prepare().then(() => {
res.statusCode = 500
res.end('internal server error')
}
}).listen(port, (err) => {
if (err) throw err
console.debug(`\n > Ready on http://${hostname}:${port} \n`)
})
.once('error', (err) => {
console.error(err)
process.exit(1)
})
.listen(port, () => {
console.debug(`\n > Ready on http://${hostname}:${port} \n`)
})
})
2 changes: 1 addition & 1 deletion examples/nextjs-custom-server/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://nextjs.org/docs/advanced-features/customizing-babel-config
// https://nextjs.org/docs/pages/building-your-application/configuring/babel
module.exports = {
presets: [
'next/babel',
Expand Down
12 changes: 8 additions & 4 deletions examples/nextjs-custom-server/server.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* https://nextjs.org/docs/advanced-features/custom-server
* https://nextjs.org/docs/pages/building-your-application/configuring/custom-server
*/
import { createServer } from 'node:http'
import next from 'next'
Expand Down Expand Up @@ -49,8 +49,12 @@ app.prepare().then(() => {
res.statusCode = 500
res.end('internal server error')
}
}).listen(port, (err) => {
if (err) throw err
console.debug(`\n > Ready on http://${hostname}:${port} \n`)
})
.once('error', (err) => {
console.error(err)
process.exit(1)
})
.listen(port, () => {
console.debug(`\n > Ready on http://${hostname}:${port} \n`)
})
})

0 comments on commit 508cb24

Please sign in to comment.