@rpcbase/server 0.1.0 → 0.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,47 @@
1
+ /* @flow */
2
+ const fs = require("fs")
3
+ const path = require("path")
4
+ const glob = require("glob")
5
+
6
+ const src_path = path.join(process.cwd(), "./src/")
7
+ const build_dir = path.join(process.cwd(), "build/")
8
+
9
+
10
+ const async_wrapper = fn => (req, res, next) => {
11
+ Promise.resolve(fn(req, res, next))
12
+ .catch(next)
13
+ }
14
+
15
+
16
+ const client_router = (app) => {
17
+
18
+ app.get("*", async_wrapper(async(req, res, next) => {
19
+ console.log("client router wow", req)
20
+ next()
21
+ }))
22
+
23
+ // const rpc_routes = glob.sync(path.join(build_dir, "./rpc/*"))
24
+ //
25
+ // rpc_routes.forEach((file_path) => {
26
+ // const basename = path.basename(file_path)
27
+ // const route_path = basename.replace(/__slash__/g, "/")
28
+ // const module_path = path.join(src_path, `${route_path}.js`)
29
+ //
30
+ // // if module not found, remove created route file
31
+ // if (!fs.existsSync(module_path)) {
32
+ // fs.unlinkSync(file_path)
33
+ // console.log("removed inexistant rpc route", basename, "with module path", module_path)
34
+ // }
35
+ //
36
+ // const rpc_fn = require(module_path)
37
+ // app.post(`/rpc/${route_path}`, async_wrapper(async(req, res) => {
38
+ // // console.log("GOT REQ", req.body)
39
+ // const result = await rpc_fn(req.body, req)
40
+ // // console.log("rpc", route_path, result)
41
+ // res.json(result)
42
+ // }))
43
+ // })
44
+
45
+ }
46
+
47
+ module.exports = client_router
package/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  /* @flow */
2
2
  const rpc_router = require("./rpc/rpc_router")
3
+ const client_router = require("./client/client_router")
3
4
 
4
5
  module.exports = {
5
- rpc_router
6
+ rpc_router,
7
+ client_router,
6
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "scripts": {