wtf
This commit is contained in:
+6
-4
@@ -1,7 +1,9 @@
|
||||
node_modules
|
||||
|
||||
*/**/*.js
|
||||
*/**/*.d.ts
|
||||
src/**/*.js
|
||||
src/**/*.d.ts
|
||||
|
||||
!lib/Backend.js
|
||||
!lib/Frontend.js
|
||||
test/**/*.js
|
||||
test/**/*.d.ts
|
||||
|
||||
lib
|
||||
-167
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Generated
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rpclib",
|
||||
"version": "1.0.0",
|
||||
"name": "rpclibrary",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
+8
-7
@@ -1,12 +1,14 @@
|
||||
{
|
||||
"name": "rpclib",
|
||||
"version": "1.0.0",
|
||||
"name": "rpclibrary",
|
||||
"version": "1.0.1",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "npm run clean; npm run tsc; npm run webpack",
|
||||
"tsc": "tsc",
|
||||
"webpack": "webpack --config src/webpack.prod.js --progress --colors",
|
||||
"clean": "rm -rf lib"
|
||||
"webpack": "webpack",
|
||||
"build-lib": "npm run webpack --config ./src/webpack.js",
|
||||
"build-test": "npm run webpack --config ./test/webpack.js",
|
||||
"build": "npm run clean && npm run tsc && npm run build-lib && npm run build-test",
|
||||
"clean": "rm -rf lib ./*.js ./*.d.ts"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
@@ -25,7 +27,6 @@
|
||||
"uuid": "^3.3.3"
|
||||
},
|
||||
"files": [
|
||||
"./lib/Backend.js",
|
||||
"./lib/Frontend.js"
|
||||
"lib/*.js"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,8 +6,16 @@ import bsock = require('bsock');
|
||||
import * as T from './Types';
|
||||
import * as U from './Utils';
|
||||
import * as I from './Interfaces';
|
||||
import * as R from './Responses';
|
||||
|
||||
export class Server{
|
||||
export {
|
||||
T as Types,
|
||||
U as Utils,
|
||||
I as Interfaces,
|
||||
R as Responses
|
||||
}
|
||||
|
||||
export class Backend{
|
||||
private ws = http.createServer()
|
||||
private io = bsock.createServer()
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
|
||||
var bsock = require('bsock')
|
||||
|
||||
import * as I from './Interfaces';
|
||||
import * as T from './Types';
|
||||
import * as I from './Interfaces';
|
||||
|
||||
export {
|
||||
T as Types,
|
||||
I as Interfaces,
|
||||
}
|
||||
|
||||
|
||||
//fix args with defaults like "force = true" -> "force"
|
||||
@@ -11,7 +16,7 @@ function stripAfterEquals(str:string){
|
||||
return str.split("=")[0]
|
||||
}
|
||||
|
||||
export class Client implements I.Socket{
|
||||
export class Frontend implements I.Socket{
|
||||
|
||||
private socket: I.Socket
|
||||
constructor(public port:number, private server: string, private tls: boolean = false){
|
||||
@@ -1,66 +0,0 @@
|
||||
const path = require('path');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
|
||||
const frontendConf = {
|
||||
mode: 'production',
|
||||
target: "web",
|
||||
entry: path.resolve(__dirname, 'Client.ts'),
|
||||
output: {
|
||||
path: path.resolve(__dirname, '../lib'),
|
||||
filename: 'Frontend.js',
|
||||
libraryTarget: 'commonjs',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.ts?$/, loader: "ts-loader" }
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".ts", ".tsx", ".js"]
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
parallel: true,
|
||||
exclude: [
|
||||
/\.\/(.*)\/.ts/,
|
||||
/\.\/(.*).ts/,
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
const backendConf = {
|
||||
mode: 'production',
|
||||
target: "node",
|
||||
entry: path.resolve(__dirname, 'Server.ts'),
|
||||
output: {
|
||||
path: path.resolve(__dirname, '../lib'),
|
||||
filename: 'Backend.js',
|
||||
libraryTarget: 'commonjs',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.ts?$/, loader: "ts-loader" }
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".ts", ".tsx", ".js"]
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
parallel: true,
|
||||
exclude: [
|
||||
/\.\/(.*)\/.ts/,
|
||||
/\.\/(.*).ts/,
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = [frontendConf, backendConf]
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Backend } from '../src/Backend'
|
||||
|
||||
const testServer = new Backend(20000, [{
|
||||
name: "HelloWorldRPCGroup",
|
||||
publicRPCs: () => [],
|
||||
localRPCs: () => [{
|
||||
type: 'Call',
|
||||
name: 'echo',
|
||||
call: async (s:string) => s,
|
||||
}]
|
||||
}])
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Frontend } from '../src/Frontend'
|
||||
|
||||
const testClient = new Frontend(20000, 'localhost')
|
||||
testClient.connect().then(_ => {
|
||||
testClient.info().then(console.log)
|
||||
testClient["HelloWorldRPCGroup"].echo("x").then(console.log)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
import { Server } from '../src/Server'
|
||||
import {Client} from '../src/Client'
|
||||
|
||||
new Server(20000, [{
|
||||
name: "HelloWorldRPCGroup",
|
||||
publicRPCs: () => [],
|
||||
localRPCs: () => [{
|
||||
type: 'Call',
|
||||
name: 'echo',
|
||||
call: async (s:string) => s,
|
||||
}]
|
||||
}])
|
||||
|
||||
const caller = new Client(20000, 'localhost')
|
||||
caller.connect().then(_ => {
|
||||
caller.info().then(console.log)
|
||||
caller["HelloWorldRPCGroup"].echo("x").then(console.log)
|
||||
})
|
||||
@@ -5,6 +5,7 @@
|
||||
"target": "ESnext",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"outDir": "./lib",
|
||||
"strict": true,
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user