tlsd 2.1.2 → 2.2.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.
@@ -0,0 +1,13 @@
1
+
2
+ module.exports = ( input, okay, fail ) => {
3
+
4
+ const action = input.action;
5
+
6
+ if( action == "hello" ) {
7
+ return okay( "welcome" );
8
+ }
9
+
10
+ fail( "Invalid action: "+action );
11
+
12
+ };
13
+
@@ -0,0 +1,15 @@
1
+ <html>
2
+ <body>
3
+
4
+ <h1> Hello </h1>
5
+
6
+ <script src="/rpc/rpc.js"></script>
7
+
8
+ <script>
9
+ RPC.on_connect = evt => {
10
+ RPC( { action: "hello" }, console.log, alert );
11
+ };
12
+ </script>
13
+
14
+ </body>
15
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tlsd",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "An server for web app prototyping with HTTPS and Websockets",
5
5
  "main": "tlsd.js",
6
6
  "bin": {
@@ -0,0 +1,13 @@
1
+
2
+ module.exports = ( input, okay, fail ) => {
3
+
4
+ const action = input.action;
5
+
6
+ if( action == "hello" ) {
7
+ return okay( "welcome" );
8
+ }
9
+
10
+ fail( "Invalid action: "+action );
11
+
12
+ };
13
+
@@ -0,0 +1,15 @@
1
+ <html>
2
+ <body>
3
+
4
+ <h1> Hello </h1>
5
+
6
+ <script src="/rpc/rpc.js"></script>
7
+
8
+ <script>
9
+ RPC.on_connect = evt => {
10
+ RPC( { action: "hello" }, console.log, alert );
11
+ };
12
+ </script>
13
+
14
+ </body>
15
+ </html>
package/tlsd CHANGED
@@ -1,12 +1,8 @@
1
1
  #!/bin/bash
2
2
 
3
- cwd=`pwd -P`
4
- bin=`realpath "$0"`
3
+ bin=`readlink -f "$0"`
5
4
  home=`dirname "$bin"`
6
5
 
7
- cd "$home"
8
-
9
-
10
6
  cmd="$1"
11
7
 
12
8
  if [ "$cmd" = "run" ] ; then
@@ -28,7 +24,7 @@ if [ "$cmd" = "run" ] ; then
28
24
 
29
25
  echo "Using node.js `node -v`"
30
26
 
31
- if DOMAINS_ROOT="domains" MAINTAINER_EMAIL="$email" VERBOSITY=3 node "./tlsd.js" ; then
27
+ if DOMAINS_ROOT="domains" MAINTAINER_EMAIL="$email" VERBOSITY=3 node "$home/tlsd.js" ; then
32
28
  echo "`date` ____________ Graceful exit "
33
29
  break
34
30
  else
@@ -43,15 +39,25 @@ if [ "$cmd" = "run" ] ; then
43
39
 
44
40
  echo "Using node.js `node -v`"
45
41
 
46
- while true ; do
47
-
48
- node "./tlsd.js" "$cwd" 12345 5
49
- if [ $? != 0 ] ; then
50
- echo "\n(( restart in 15 seconds ))"
51
- sleep 15
52
- fi
42
+ root_dir="$3"
43
+ port="$4"
44
+ verbosity="$5"
53
45
 
54
- done
46
+ if [ "$verbosity" = "" ] ; then
47
+ echo "Usage: tlsd run dev root_dir port verbosity"
48
+ exit 1
49
+ else
50
+ while true ; do
51
+
52
+ node "$home/tlsd.js" "$root_dir" "$port" "$verbosity"
53
+ if [ $? != 0 ] ; then
54
+ echo
55
+ echo "(( restart in 15 seconds ))"
56
+ sleep 15
57
+ fi
58
+
59
+ done
60
+ fi
55
61
 
56
62
  fi
57
63
 
@@ -60,6 +66,36 @@ if [ "$cmd" = "run" ] ; then
60
66
 
61
67
  fi
62
68
 
63
- echo "Usage: tlsd run prod|dev"
69
+
70
+ if [ "$cmd" = "init" ] ; then
71
+
72
+ dir=`readlink -f "$2"`
73
+
74
+ if test -d "$dir" ; then
75
+
76
+ if test -d "./static" ; then
77
+ echo "Initialization aborted: 'static' directory already exists"
78
+ exit 1
79
+ fi
80
+ if test -d "./rpc" ; then
81
+ echo "Initialization aborted: 'rpc' directory already exists"
82
+ exit 1
83
+ fi
84
+
85
+ rsync -ar "$home/scaffold/" "$dir"
86
+
87
+ echo Initialized $dir
88
+
89
+ exit 0
90
+
91
+ else
92
+ echo "Usage: tlsd init directory_to_initalize"
93
+ exit 1
94
+ fi
95
+
96
+ fi
97
+
98
+
99
+ echo "Usage: tlsd init|run ..."
64
100
  exit 1
65
101
 
package/tlsd.js CHANGED
@@ -276,7 +276,7 @@ const ws_attach = function( httpServer, msg_handler ) {
276
276
 
277
277
  } );
278
278
 
279
- D( "WS: initizlized" );
279
+ D( "WS: initialized" );
280
280
 
281
281
  return wsd;
282
282