Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit a925a3a

Browse files
committed
Fix outdated example
1 parent 42cc437 commit a925a3a

File tree

7 files changed

+56
-78
lines changed

7 files changed

+56
-78
lines changed

Diff for: en/examples/auth-routes.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ yarn add express express-session body-parser whatwg-fetch
2323

2424
Then we create our `server.js`:
2525
```js
26-
const Nuxt = require('nuxt')
26+
const { Nuxt, Builder } = require('nuxt')
2727
const bodyParser = require('body-parser')
2828
const session = require('express-session')
2929
const app = require('express')()
@@ -58,16 +58,13 @@ app.post('/api/logout', function (req, res) {
5858
const isProd = process.env.NODE_ENV === 'production'
5959
const nuxt = new Nuxt({ dev: !isProd })
6060
// No build in production
61-
const promise = (isProd ? Promise.resolve() : nuxt.build())
62-
promise.then(() => {
63-
app.use(nuxt.render)
64-
app.listen(3000)
65-
console.log('Server is listening on http://localhost:3000')
66-
})
67-
.catch((error) => {
68-
console.error(error)
69-
process.exit(1)
70-
})
61+
if (!isProd) {
62+
const builder = new Builder(nuxt)
63+
builder.build()
64+
}
65+
app.use(nuxt.render)
66+
app.listen(3000)
67+
console.log('Server is listening on http://localhost:3000')
7168
```
7269

7370
And we update our `package.json` scripts:

Diff for: es/examples/auth-routes.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ yarn add express express-session body-parser whatwg-fetch
2323

2424
Then we create our `server.js`:
2525
```js
26-
const Nuxt = require('nuxt')
26+
const { Nuxt, Builder } = require('nuxt')
2727
const bodyParser = require('body-parser')
2828
const session = require('express-session')
2929
const app = require('express')()
@@ -58,16 +58,13 @@ app.post('/api/logout', function (req, res) {
5858
const isProd = process.env.NODE_ENV === 'production'
5959
const nuxt = new Nuxt({ dev: !isProd })
6060
// No build in production
61-
const promise = (isProd ? Promise.resolve() : nuxt.build())
62-
promise.then(() => {
63-
app.use(nuxt.render)
64-
app.listen(3000)
65-
console.log('Server is listening on http://localhost:3000')
66-
})
67-
.catch((error) => {
68-
console.error(error)
69-
process.exit(1)
70-
})
61+
if (!isProd) {
62+
const builder = new Builder(nuxt)
63+
builder.build()
64+
}
65+
app.use(nuxt.render)
66+
app.listen(3000)
67+
console.log('Server is listening on http://localhost:3000')
7168
```
7269

7370
And we update our `package.json` scripts:

Diff for: fr/examples/auth-routes.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ yarn add express express-session body-parser whatwg-fetch
2323

2424
Puis nous créons notre `server.js`:
2525
```js
26-
const Nuxt = require('nuxt')
26+
const { Nuxt, Builder } = require('nuxt')
2727
const bodyParser = require('body-parser')
2828
const session = require('express-session')
2929
const app = require('express')()
@@ -58,16 +58,13 @@ app.post('/api/logout', function (req, res) {
5858
const isProd = process.env.NODE_ENV === 'production'
5959
const nuxt = new Nuxt({ dev: !isProd })
6060
// No build in production
61-
const promise = (isProd ? Promise.resolve() : nuxt.build())
62-
promise.then(() => {
63-
app.use(nuxt.render)
64-
app.listen(3000)
65-
console.log('Server is listening on http://localhost:3000')
66-
})
67-
.catch((error) => {
68-
console.error(error)
69-
process.exit(1)
70-
})
61+
if (!isProd) {
62+
const builder = new Builder(nuxt)
63+
builder.build()
64+
}
65+
app.use(nuxt.render)
66+
app.listen(3000)
67+
console.log('Server is listening on http://localhost:3000')
7168
```
7269

7370
Et nous modifions nos script dans `package.json`:

Diff for: ja/examples/auth-routes.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ yarn add express express-session body-parser whatwg-fetch
2525
それから `server.js` ファイルを作成します:
2626

2727
```js
28-
const Nuxt = require('nuxt')
28+
const { Nuxt, Builder } = require('nuxt')
2929
const bodyParser = require('body-parser')
3030
const session = require('express-session')
3131
const app = require('express')()
@@ -59,18 +59,14 @@ app.post('/api/logout', function (req, res) {
5959
// オプションとともに Nuxt.js をインスタンス化
6060
const isProd = process.env.NODE_ENV === 'production'
6161
const nuxt = new Nuxt({ dev: !isProd })
62-
6362
// プロダクション環境ではビルドしない
64-
const promise = (isProd ? Promise.resolve() : nuxt.build())
65-
promise.then(() => {
66-
app.use(nuxt.render)
67-
app.listen(3000)
68-
console.log('Server is listening on http://localhost:3000')
69-
})
70-
.catch((error) => {
71-
console.error(error)
72-
process.exit(1)
73-
})
63+
if (!isProd) {
64+
const builder = new Builder(nuxt)
65+
builder.build()
66+
}
67+
app.use(nuxt.render)
68+
app.listen(3000)
69+
console.log('Server is listening on http://localhost:3000')
7470
```
7571

7672
また `package.json` scripts を更新します:

Diff for: ko/examples/auth-routes.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ yarn add express express-session body-parser whatwg-fetch
2323

2424
`server.js`를 만듭니다.:
2525
```js
26-
const Nuxt = require('nuxt')
26+
const { Nuxt, Builder } = require('nuxt')
2727
const bodyParser = require('body-parser')
2828
const session = require('express-session')
2929
const app = require('express')()
@@ -58,16 +58,13 @@ app.post('/api/logout', function (req, res) {
5858
const isProd = process.env.NODE_ENV === 'production'
5959
const nuxt = new Nuxt({ dev: !isProd })
6060
// 프로덕션 환경에서 빌드되지 않음.
61-
const promise = (isProd ? Promise.resolve() : nuxt.build())
62-
promise.then(() => {
63-
app.use(nuxt.render)
64-
app.listen(3000)
65-
console.log('Server is listening on http://localhost:3000')
66-
})
67-
.catch((error) => {
68-
console.error(error)
69-
process.exit(1)
70-
})
61+
if (!isProd) {
62+
const builder = new Builder(nuxt)
63+
builder.build()
64+
}
65+
app.use(nuxt.render)
66+
app.listen(3000)
67+
console.log('Server is listening on http://localhost:3000')
7168
```
7269

7370
`package.json` 파일 업데이트:

Diff for: ru/examples/auth-routes.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ yarn add express express-session body-parser whatwg-fetch
2323

2424
Then we create our `server.js`:
2525
```js
26-
const Nuxt = require('nuxt')
26+
const { Nuxt, Builder } = require('nuxt')
2727
const bodyParser = require('body-parser')
2828
const session = require('express-session')
2929
const app = require('express')()
@@ -58,16 +58,13 @@ app.post('/api/logout', function (req, res) {
5858
const isProd = process.env.NODE_ENV === 'production'
5959
const nuxt = new Nuxt({ dev: !isProd })
6060
// No build in production
61-
const promise = (isProd ? Promise.resolve() : nuxt.build())
62-
promise.then(() => {
63-
app.use(nuxt.render)
64-
app.listen(3000)
65-
console.log('Server is listening on http://localhost:3000')
66-
})
67-
.catch((error) => {
68-
console.error(error)
69-
process.exit(1)
70-
})
61+
if (!isProd) {
62+
const builder = new Builder(nuxt)
63+
builder.build()
64+
}
65+
app.use(nuxt.render)
66+
app.listen(3000)
67+
console.log('Server is listening on http://localhost:3000')
7168
```
7269

7370
And we update our `package.json` scripts:

Diff for: zh/examples/auth-routes.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ yarn add express express-session body-parser whatwg-fetch
2424
然后创建 `server.js`
2525

2626
```js
27-
const Nuxt = require('nuxt')
27+
const { Nuxt, Builder } = require('nuxt')
2828
const bodyParser = require('body-parser')
2929
const session = require('express-session')
3030
const app = require('express')()
@@ -59,16 +59,13 @@ app.post('/api/logout', function (req, res) {
5959
const isProd = process.env.NODE_ENV === 'production'
6060
const nuxt = new Nuxt({ dev: !isProd })
6161
// 生产模式不需要 build
62-
const promise = (isProd ? Promise.resolve() : nuxt.build())
63-
promise.then(() => {
64-
app.use(nuxt.render)
65-
app.listen(3000)
66-
console.log('Server is listening on http://localhost:3000')
67-
})
68-
.catch((error) => {
69-
console.error(error)
70-
process.exit(1)
71-
})
62+
if (!isProd) {
63+
const builder = new Builder(nuxt)
64+
builder.build()
65+
}
66+
app.use(nuxt.render)
67+
app.listen(3000)
68+
console.log('Server is listening on http://localhost:3000')
7269
```
7370

7471
然后更新我们的 `package.json` 脚本:

0 commit comments

Comments
 (0)