Skip to content

Commit 9eaa320

Browse files
committed
Compatibility updates for package web-dev-server 2.1.
1 parent 9391ef7 commit 9eaa320

File tree

10 files changed

+52
-16
lines changed

10 files changed

+52
-16
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = tab
7+
tab_width = 4
8+
charset = utf-8
9+
end_of_line = lf
10+
insert_final_newline = false
11+
trim_trailing_whitespace = false

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,7 @@ Temporary Items
5757

5858
# third party node modules
5959
node_modules
60-
/package-lock.json
60+
package-lock.json
61+
62+
# log files
63+
*.log

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
Workspace.code-workspace
3+
.editorconfig
4+
*.log
5+
TODO.md

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Example - Chat
22

3-
[![Latest Stable Version](https://img.shields.io/badge/Stable-v1.3.1-brightgreen.svg?style=plastic)](https://github.com/web-dev-server/example-chat/releases)
3+
[![Latest Stable Version](https://img.shields.io/badge/Stable-v2.1.0-brightgreen.svg?style=plastic)](https://github.com/web-dev-server/example-chat-angular-1/releases)
44
[![License](https://img.shields.io/badge/Licence-BSD-brightgreen.svg?style=plastic)](https://github.com/web-dev-server/example-chat-angular-1/blob/master/LICENCE.md)
55

66
Chat example with session authentication. Client scripts witten with Angular 1.
@@ -15,7 +15,7 @@ npm update
1515

1616
## Usage
1717
```shell
18-
node run-server.js
18+
node server.js
1919
```
2020
- open your first web browser on:
2121
- http://localhost:8000/chat/

Workspace.code-workspace

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {}
8+
}

chat/data/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,21 @@ App.prototype = {
191191
});
192192
ws.send(responseStr);
193193
},
194-
httpRequestHandler: function (request, response, callback) {
195-
this._completeWholeRequestInfo(request, function (requestInfo) {
196-
this._authorizeHttpRequest(requestInfo, response, callback);
194+
HandleHttpRequest: function (request, response) {
195+
return new Promise(function (resolve, reject) {
196+
this._completeWholeRequestInfo(request, function (requestInfo) {
197+
this._authorizeHttpRequest(requestInfo, response, resolve);
198+
}.bind(this));
197199
}.bind(this));
198200
},
199-
_authorizeHttpRequest: function (requestInfo, response, callback) {
201+
_authorizeHttpRequest: function (requestInfo, response, resolve) {
200202
var request = requestInfo.request;
201203
var postData = null;
202204
try {
203205
postData = JSON.parse(requestInfo.textBody);
204206
} catch (e) {
205207
response.send('{"success":false,"message":"Bad user input: ' + e.message.replace(/"/g, """) + '"}');
206-
callback();
207-
return;
208+
return resolve();
208209
}
209210

210211
// HERE IS PERFECT PLACE TO GET ANY CREDENTIALS FROM DATABASE:
@@ -226,7 +227,7 @@ App.prototype = {
226227
response.send('{"success":false,"message":"Wrong password."}');
227228
}
228229

229-
callback();
230+
resolve();
230231
},
231232
_completeWholeRequestInfo: function (request, callback) {
232233
var reqInfo = {

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"name": "web-dev-server-example-chat-angular-1",
3-
"version": "1.3.1",
3+
"version": "2.1.0",
4+
"keywords": [
5+
"chat",
6+
"javascript",
7+
"node",
8+
"angular"
9+
],
410
"description": "Chat example with session authentication in Angular 1.",
511
"homepage": "https://github.com/web-dev-server/example-chat-angular-1",
612
"repository": {
@@ -15,7 +21,7 @@
1521
},
1622
"main": "run-server.js",
1723
"dependencies": {
18-
"web-dev-server": "^1.3.0",
24+
"web-dev-server": "^2.1",
1925
"ws": "^3.3.2"
2026
}
2127
}

run-server-in-debug-mode.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
@echo Open Chrome browser and visit URL: chrome://inspect
12
::node --inspect-brk server.js
2-
node --inspect server.js
3+
@node --inspect server.js

run-server.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
node server.js
1+
@node server.js

server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var WebDevServer = require("web-dev-server");
2-
var devServerInstance = (new WebDevServer())
2+
3+
WebDevServer.Server.CreateNew()
34
.SetDocumentRoot(__dirname) // required
45
.SetPort(8000) // optional, 8000 by default
5-
// .SetDomain('localhost') // optional, localhost by default
6+
// .SetDomain('localhost') // optional, 127.0.0.1 by default
67
// .SetDevelopment(false) // optional, true by default to display Errors and directory content
78
.Run();

0 commit comments

Comments
 (0)