Browse Source

it werks

master
Daniel Hübleitner 5 years ago
parent
commit
db9449aa2d
7 changed files with 31 additions and 37 deletions
  1. 9
    1
      Index.ts
  2. 1
    9
      src/Backend.ts
  3. 1
    11
      src/Frontend.ts
  4. 0
    1
      src/Responses.ts
  5. 13
    8
      src/webpack.js
  6. 2
    2
      test/TestBackend.ts
  7. 5
    5
      test/TestFrontend.ts

+ 9
- 1
Index.ts View File

@@ -1,7 +1,15 @@
1 1
 import * as Back from './src/Backend';
2 2
 import * as Front from './src/Frontend';
3
+import * as Types from './src/Types'; 
4
+import * as Utils from './src/Utils'; 
5
+import * as Interfaces from './src/Interfaces';
6
+import * as Responses from './src/Responses';
3 7
 
4 8
 export {
5 9
     Back as Backend,
6
-    Front as Frontend
10
+    Front as Frontend,
11
+    Types, 
12
+    Utils, 
13
+    Interfaces,
14
+    Responses
7 15
 }

+ 1
- 9
src/Backend.ts View File

@@ -6,16 +6,8 @@ import bsock = require('bsock');
6 6
 import * as T from './Types'; 
7 7
 import * as U from './Utils'; 
8 8
 import * as I from './Interfaces';
9
-import * as R from './Responses';
10 9
 
11
-export { 
12
-    T as Types, 
13
-    U as Utils, 
14
-    I as Interfaces,
15
-    R as Responses
16
-}
17
-
18
-export class Server{
10
+export class RPCServer{
19 11
     private ws = http.createServer()
20 12
     private io = bsock.createServer()
21 13
 

+ 1
- 11
src/Frontend.ts View File

@@ -3,24 +3,14 @@
3 3
 var bsock = require('bsock')
4 4
 
5 5
 import * as T from './Types'; 
6
-import * as U from './Utils'; 
7 6
 import * as I from './Interfaces';
8
-import * as R from './Responses';
9
-
10
-export { 
11
-    T as Types, 
12
-    U as Utils, 
13
-    I as Interfaces,
14
-    R as Responses
15
-}
16
-
17 7
 
18 8
 //fix args with defaults like "force = true" -> "force"
19 9
 function stripAfterEquals(str:string){
20 10
     return str.split("=")[0]
21 11
 }
22 12
 
23
-export class Client implements I.Socket{
13
+export class RPCSocket implements I.Socket{
24 14
 
25 15
     private socket: I.Socket
26 16
     constructor(public port:number, private server: string, private tls: boolean = false){

+ 0
- 1
src/Responses.ts View File

@@ -1,7 +1,6 @@
1 1
 
2 2
 export type Outcome = "Success" | "Error"
3 3
 
4
-/* Responses */
5 4
 export class Response{
6 5
     constructor(
7 6
         public message?:string

+ 13
- 8
src/webpack.js View File

@@ -1,20 +1,25 @@
1 1
 const path = require('path');
2 2
 
3
-const frontendConf = {
3
+module.exports = {
4 4
   mode: 'production',
5 5
   target: "web",
6
-  entry: path.resolve(__dirname, '..', 'js', 'src', 'Frontend.js'),
6
+  entry: path.resolve(__dirname, 'Frontend.ts'),
7 7
   output: {
8
-      path: path.resolve(__dirname, '..', 'js', 'src'),
9
-      filename: "Frontend.js",
10
-      libraryTarget: 'commonjs',
8
+      path: path.resolve(__dirname, '../js'),
9
+      filename: 'Frontend.min.js',
10
+      libraryTarget: 'window',
11 11
   },
12 12
   resolve: {
13 13
     extensions: [".ts", ".tsx", ".js"]
14 14
   },
15
+  module: {
16
+    rules: [
17
+      { test: /\.ts?$/, loader: "ts-loader" }
18
+    ]
19
+  },
15 20
   optimization: {
16 21
     minimize: false,
17 22
   },
18
-}
19
-
20
-module.exports =  [frontendConf]
23
+  externals: {
24
+  }
25
+}

+ 2
- 2
test/TestBackend.ts View File

@@ -1,6 +1,6 @@
1
-import { Server } from '../src/Backend'
1
+import { RPCServer } from '../src/Backend'
2 2
 
3
-new Server(20000, [{
3
+new RPCServer(20000, [{
4 4
     name: "HelloWorldRPCGroup",
5 5
     publicRPCs: () => [],
6 6
     localRPCs: () => [{

+ 5
- 5
test/TestFrontend.ts View File

@@ -1,7 +1,7 @@
1
-import { Client } from '../src/Frontend'
1
+import { RPCSocket } from '../src/Frontend'
2 2
 
3
-const client = new Client(20000, 'localhost')
4
-client.connect().then(_ => {
5
-    client.info().then(console.log)
6
-    client["HelloWorldRPCGroup"].echo("x").then(console.log)
3
+const socket = new RPCSocket(20000, 'localhost')
4
+socket.connect().then(_ => {
5
+    socket.info().then(console.log)
6
+    socket["HelloWorldRPCGroup"].echo("x").then(console.log)
7 7
 })

Loading…
Cancel
Save