forked from deleteman/jwhisper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver-sample.js
77 lines (64 loc) · 1.62 KB
/
server-sample.js
1
2
3
4
5
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const Server = require("./lib/server")
class Test {
constructor() {
}
add(a,b) {
console.log("Adding numbers: ", a, b)
return a + b
}
mult(a,b) {
return a * b
}
}
class Users {
constructor() {
this.users = []
}
addUser(u) {
this.users.push(u)
return u
}
}
let services = {
"Test": {
"service_class": Test,
"methods": {
"add": {
"doc_lines": ["Adds 2 numbers"],
"params": {
"first_number": {
"def_order": 1,
"doc_lines": ["first number to add"],
"type": "number",
"optional": false
},
"second_number": {
"def_order": 2,
"doc_lines": ["second number to add"],
"type": "number",
"optional": false
}
},
"ret_info": {
"doc_lines": ["the result of the addition "],
"type": ["number"]
}
}
}
}
}
let types = {
"User": {
"name": "string",
"age": "number"
}
}
const myServer = new Server({
specs: {
"servicename": "Test Service",
"url": ""
},
services: services,
types: types
})
myServer.start(8080, 'http://localhost')