fix(learn): update the required package name (#40056)
This commit is contained in:
@@ -11,7 +11,7 @@ title: 设置环境
|
|||||||
|
|
||||||
在接下来的挑战中,我们将会用到 <code>chat.pug</code> 文件。首先,你需要在你的 <code>routes.js</code> 文件中为 <code>/chat</code> 添加一个处理 GET 请求的路由,并给它传入 <code>ensureAuthenticated</code>。在回调函数中,我们需要让它 render <code>chat.pug</code> 文件,并在响应中包含 <code>{ user: req.user }</code> 信息。现在,请修改 <code>/auth/github/callback</code> 路由,让它可以像这样设置 user_id:<code>req.session.user_id = req.user.id</code>,并在设置完成后重定向至 <code>/chat</code>。
|
在接下来的挑战中,我们将会用到 <code>chat.pug</code> 文件。首先,你需要在你的 <code>routes.js</code> 文件中为 <code>/chat</code> 添加一个处理 GET 请求的路由,并给它传入 <code>ensureAuthenticated</code>。在回调函数中,我们需要让它 render <code>chat.pug</code> 文件,并在响应中包含 <code>{ user: req.user }</code> 信息。现在,请修改 <code>/auth/github/callback</code> 路由,让它可以像这样设置 user_id:<code>req.session.user_id = req.user.id</code>,并在设置完成后重定向至 <code>/chat</code>。
|
||||||
|
|
||||||
我们还需要添加 <code>html</code> 和 <code>socket.io</code> 两个依赖项,并且像这样引入:
|
我们还需要添加 <code>http</code> 和 <code>socket.io</code> 两个依赖项,并且像这样引入:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const http = require('http').createServer(app);
|
const http = require('http').createServer(app);
|
||||||
@@ -62,7 +62,7 @@ tests:
|
|||||||
- text: 应添加 Socket.IO 作为依赖。
|
- text: 应添加 Socket.IO 作为依赖。
|
||||||
testString: getUserInput => $.get(getUserInput('url')+ '/_api/package.json') .then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'socket.io', 'Your project should list "socket.io" as a dependency'); }, xhr => { throw new Error(xhr.statusText); })
|
testString: getUserInput => $.get(getUserInput('url')+ '/_api/package.json') .then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'socket.io', 'Your project should list "socket.io" as a dependency'); }, xhr => { throw new Error(xhr.statusText); })
|
||||||
- text: 应正确引入 <code>http</code>,并示例化为 <code>http</code>。
|
- text: 应正确引入 <code>http</code>,并示例化为 <code>http</code>。
|
||||||
testString: getUserInput => $.get(getUserInput('url')+ '/_api/server.js') .then(data => { assert.match(data, /http.*=.*require.*('|")http\1/gi, 'Your project should list "html" as a dependency'); }, xhr => { throw new Error(xhr.statusText); })
|
testString: getUserInput => $.get(getUserInput('url')+ '/_api/server.js') .then(data => { assert.match(data, /http.*=.*require.*('|")http\1/gi, 'Your project should list "http" as a dependency'); }, xhr => { throw new Error(xhr.statusText); })
|
||||||
- text: 应正确引入 <code>socket.io</code>,并示例化为 <code>io</code>。
|
- text: 应正确引入 <code>socket.io</code>,并示例化为 <code>io</code>。
|
||||||
testString: getUserInput => $.get(getUserInput('url')+ '/_api/server.js').then(data => {assert.match(data, /io.*=.*require.*('|")socket.io\1.*http/gi, 'You should correctly require and instantiate socket.io as io.');}, xhr => { throw new Error(xhr.statusText); })
|
testString: getUserInput => $.get(getUserInput('url')+ '/_api/server.js').then(data => {assert.match(data, /io.*=.*require.*('|")socket.io\1.*http/gi, 'You should correctly require and instantiate socket.io as io.');}, xhr => { throw new Error(xhr.statusText); })
|
||||||
- text: Socket.IO 应监听连接。
|
- text: Socket.IO 应监听连接。
|
||||||
|
@@ -11,7 +11,7 @@ forumTopicId: 301566
|
|||||||
|
|
||||||
The following challenges will make use of the <code>chat.pug</code> file. So, in your <code>routes.js</code> file, add a GET route pointing to <code>/chat</code> which makes use of <code>ensureAuthenticated</code>, and renders <code>chat.pug</code>, with <code>{ user: req.user }</code> passed as an argument to the response. Now, alter your existing <code>/auth/github/callback</code> route to set the <code>req.session.user_id = req.user.id</code>, and redirect to <code>/chat</code>.
|
The following challenges will make use of the <code>chat.pug</code> file. So, in your <code>routes.js</code> file, add a GET route pointing to <code>/chat</code> which makes use of <code>ensureAuthenticated</code>, and renders <code>chat.pug</code>, with <code>{ user: req.user }</code> passed as an argument to the response. Now, alter your existing <code>/auth/github/callback</code> route to set the <code>req.session.user_id = req.user.id</code>, and redirect to <code>/chat</code>.
|
||||||
|
|
||||||
Add <code>html</code> and <code>socket.io</code> as a dependency and require/instantiate them in your server defined as follows:
|
Add <code>http</code> and <code>socket.io</code> as a dependency and require/instantiate them in your server defined as follows:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const http = require('http').createServer(app);
|
const http = require('http').createServer(app);
|
||||||
@@ -62,7 +62,7 @@ tests:
|
|||||||
- text: <code>socket.io</code> should be a dependency.
|
- text: <code>socket.io</code> should be a dependency.
|
||||||
testString: getUserInput => $.get(getUserInput('url')+ '/_api/package.json') .then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'socket.io', 'Your project should list "socket.io" as a dependency'); }, xhr => { throw new Error(xhr.statusText); })
|
testString: getUserInput => $.get(getUserInput('url')+ '/_api/package.json') .then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'socket.io', 'Your project should list "socket.io" as a dependency'); }, xhr => { throw new Error(xhr.statusText); })
|
||||||
- text: You should correctly require and instantiate <code>http</code> as <code>http</code>.
|
- text: You should correctly require and instantiate <code>http</code> as <code>http</code>.
|
||||||
testString: getUserInput => $.get(getUserInput('url')+ '/_api/server.js') .then(data => { assert.match(data, /http.*=.*require.*('|")http\1/gi, 'Your project should list "html" as a dependency'); }, xhr => { throw new Error(xhr.statusText); })
|
testString: getUserInput => $.get(getUserInput('url')+ '/_api/server.js') .then(data => { assert.match(data, /http.*=.*require.*('|")http\1/gi, 'Your project should list "http" as a dependency'); }, xhr => { throw new Error(xhr.statusText); })
|
||||||
- text: You should correctly require and instantiate <code>socket.io</code> as <code>io</code>.
|
- text: You should correctly require and instantiate <code>socket.io</code> as <code>io</code>.
|
||||||
testString: getUserInput => $.get(getUserInput('url')+ '/_api/server.js').then(data => {assert.match(data, /io.*=.*require.*('|")socket.io\1.*http/gi, 'You should correctly require and instantiate socket.io as io.');}, xhr => { throw new Error(xhr.statusText); })
|
testString: getUserInput => $.get(getUserInput('url')+ '/_api/server.js').then(data => {assert.match(data, /io.*=.*require.*('|")socket.io\1.*http/gi, 'You should correctly require and instantiate socket.io as io.');}, xhr => { throw new Error(xhr.statusText); })
|
||||||
- text: Socket.IO should be listening for connections.
|
- text: Socket.IO should be listening for connections.
|
||||||
|
Reference in New Issue
Block a user