tlsd 2.10.1 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -23
- package/package.json +2 -2
- package/rpc_static/rpc/rpc.js +1 -2
- package/scaffold/rpc/index.js +6 -8
- package/scaffold/static/index.html +48 -49
- package/scaffold/static/404/index.html +0 -16
- package/scaffold/static/local.sass +0 -15
- package/scaffold/static/local.sass.css +0 -18
package/README.md
CHANGED
|
@@ -2,36 +2,21 @@
|
|
|
2
2
|
# tlsd
|
|
3
3
|
|
|
4
4
|
This is a node.js based webserver.
|
|
5
|
+
It is designed for development work on prototype web applications.
|
|
6
|
+
It is *not* designed for production websites.
|
|
5
7
|
|
|
6
8
|
## Features
|
|
7
9
|
|
|
8
|
-
- SSL/TLS
|
|
10
|
+
- SSL/TLS via Greenlock
|
|
9
11
|
- Websockets built in
|
|
10
12
|
- Standardised Websockets/RPC protocol for front/back end communcations
|
|
11
13
|
- Utility command 'tlsd'
|
|
12
|
-
- Browser reload on src changes
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
## Installing
|
|
16
17
|
|
|
17
|
-
There are 2 ways to use this:
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
2. Install locally to an existing project directory and executed with "npx tlsd"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### Install Globally
|
|
24
|
-
|
|
25
|
-
npm install -g tlsd
|
|
26
|
-
|
|
27
|
-
You should how have a CLI command "tlsd"
|
|
28
|
-
|
|
29
|
-
tlsd
|
|
30
|
-
|
|
31
|
-
This way lets you run a project without having to have tlsd included in it.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Install Locally
|
|
19
|
+
Install tlsd into your project:
|
|
35
20
|
|
|
36
21
|
npm install tlsd
|
|
37
22
|
|
|
@@ -47,6 +32,7 @@ This way you can just use it to serve your local project in dev or production mo
|
|
|
47
32
|
|
|
48
33
|
Creates empty scaffolding files for a project:
|
|
49
34
|
|
|
35
|
+
mkdir my_project
|
|
50
36
|
tlsd init my_project
|
|
51
37
|
|
|
52
38
|
This can then be tested by starting the server:
|
|
@@ -54,7 +40,7 @@ This can then be tested by starting the server:
|
|
|
54
40
|
tlsd run dev my_project 12345 3
|
|
55
41
|
|
|
56
42
|
And then browsing to "http://localhost:12345".
|
|
57
|
-
You should see the pages being delivered and a websocket
|
|
43
|
+
You should see the pages being delivered and a websocket connection being established.
|
|
58
44
|
|
|
59
45
|
|
|
60
46
|
## tlsd run dev
|
|
@@ -64,12 +50,12 @@ This is for local (your computer) development:
|
|
|
64
50
|
|
|
65
51
|
tlsd root_dir port_num log_level
|
|
66
52
|
|
|
67
|
-
All arguments are required
|
|
53
|
+
All arguments are required.
|
|
68
54
|
|
|
69
55
|
|
|
70
56
|
## tlsd domain
|
|
71
57
|
|
|
72
|
-
Adds a domain to Greenlock
|
|
58
|
+
Adds a domain to Greenlock so that you can serve site with HTTPS:
|
|
73
59
|
|
|
74
60
|
tlsd domain example.com
|
|
75
61
|
|
|
@@ -81,7 +67,7 @@ Displays the current version of tlsd
|
|
|
81
67
|
|
|
82
68
|
### Production Mode
|
|
83
69
|
|
|
84
|
-
In
|
|
70
|
+
In HTTPS mode, you must specify the dir containing links/dirs for domains to serve
|
|
85
71
|
it will run on HTTP on 80 (redirecting to 443), HTTPS on 443, and magically
|
|
86
72
|
generate certs and serve secure sites like nodes:
|
|
87
73
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tlsd",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "A server for web app prototyping with HTTPS and Websockets",
|
|
5
5
|
"main": "tlsd.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"tlsd": "tlsd"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"dev": "./tlsd run dev scaffold
|
|
10
|
+
"dev": "./tlsd run dev scaffold 12344 5",
|
|
11
11
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
12
|
},
|
|
13
13
|
"author": "Joe Hitchens <joe@sleepless.com>",
|
package/rpc_static/rpc/rpc.js
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
if( RPC.debug ) {
|
|
29
29
|
args.unshift( "RPC:" );
|
|
30
30
|
console.log.apply( this, args );
|
|
31
|
-
//console.log( "RPC: ", args );
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
33
|
|
|
@@ -281,7 +280,7 @@
|
|
|
281
280
|
|
|
282
281
|
}, ( evt, detail ) => {
|
|
283
282
|
// event occurred
|
|
284
|
-
DBG( "Event:", evt );
|
|
283
|
+
DBG( "Event:", evt, detail );
|
|
285
284
|
if( evt === "connect" ) {
|
|
286
285
|
RPC.connected = true;
|
|
287
286
|
}
|
package/scaffold/rpc/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
the front end.
|
|
9
|
-
*/
|
|
2
|
+
// This is the back end script that handles messages from the front end.
|
|
3
|
+
// The "input" object is exactly the same thing that was given to RPC()
|
|
4
|
+
// on the front end.
|
|
5
|
+
// Use okay() to return a normal response, or fail() to return an error.
|
|
6
|
+
// These correspond to the same okay()/fail() functions given to RPC() on
|
|
7
|
+
// the front end.
|
|
10
8
|
|
|
11
9
|
module.exports = ( input, okay, fail ) => {
|
|
12
10
|
|
|
@@ -1,51 +1,50 @@
|
|
|
1
1
|
<html>
|
|
2
|
-
<head>
|
|
3
|
-
|
|
4
|
-
</head>
|
|
5
|
-
<body>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
</body>
|
|
2
|
+
<head>
|
|
3
|
+
<title>TLSD Test Page</title>
|
|
4
|
+
</head>
|
|
5
|
+
<body>
|
|
6
|
+
|
|
7
|
+
<h1>TLSD Test Page</h1>
|
|
8
|
+
|
|
9
|
+
<h2>
|
|
10
|
+
<script>
|
|
11
|
+
document.write( Date() );
|
|
12
|
+
</script>
|
|
13
|
+
<h2>
|
|
14
|
+
|
|
15
|
+
<h3 id=connect_status>...</h3>
|
|
16
|
+
|
|
17
|
+
<script src="/rpc/rpc.js"></script>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
|
|
21
|
+
// RPC is used to send msgs to the back end.
|
|
22
|
+
// If you call RPC() directly, it will decide whether or not to use
|
|
23
|
+
// Websocket or REST based on the size of the JSON encoded msg.
|
|
24
|
+
// Otherwise, you can explicitly choose the transport by using
|
|
25
|
+
// RPC.POST() or RPC.WS().
|
|
26
|
+
|
|
27
|
+
RPC.onmessage = msg => {
|
|
28
|
+
// Message originating from server (not a response to client message).
|
|
29
|
+
// Returning true will prevent tlsd from doing anything further
|
|
30
|
+
// with the message.
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
RPC.on_connect = function( evt ) {
|
|
35
|
+
// RPC is ready to be used (websocket is connected)
|
|
36
|
+
RPC( { action: "hello" }, msg => {
|
|
37
|
+
document.getElementById( "connect_status" ).innerText = msg;
|
|
38
|
+
} );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
RPC.on_disconnect = function( evt ) {
|
|
42
|
+
// The websocket connection was lost for some reason.
|
|
43
|
+
// The RPC code will reconnect automatically.
|
|
44
|
+
document.getElementById( "connect_status" ).innerText = "[ DISCONNECTED ]";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
</body>
|
|
51
50
|
</html>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Page Not Found </title>
|
|
5
|
-
</head>
|
|
6
|
-
<body>
|
|
7
|
-
<h1>Sorry, nothing there, mate!</h1>
|
|
8
|
-
<p>
|
|
9
|
-
<script>
|
|
10
|
-
let url = decodeURIComponent( document.location.search.split( "=" ).pop() );
|
|
11
|
-
document.write( "Requested URL: " + url );
|
|
12
|
-
</script>
|
|
13
|
-
</p>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
16
|
-
|