orator-serviceserver-restify 2.0.7 → 2.0.8
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,10 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import pluginJs from "@eslint/js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{ files: ["source/**", "test/**"], languageOptions: { sourceType: "commonjs" } },
|
|
7
|
+
{ languageOptions: { globals: { ...globals.browser, ...globals.mocha, } } },
|
|
8
|
+
pluginJs.configs.recommended,
|
|
9
|
+
{ rules: { "no-prototype-builtins": "off", "no-unused-vars": "warn" } },
|
|
10
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orator-serviceserver-restify",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Restify Service Server for Orator",
|
|
5
5
|
"main": "source/Orator-ServiceServer-Restify.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
"build": "npx quack build",
|
|
12
12
|
"docker-dev-build": "docker build ./ -f Dockerfile_LUXURYCode -t orator-serviceserver-restify-image:local",
|
|
13
13
|
"docker-dev-run": "docker run -it -d --name orator-serviceserver-restify-dev -p 14617:8080 -p 24395:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/orator-serviceserver-restify\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" orator-serviceserver-restify-image:local",
|
|
14
|
-
"docker-dev-shell": "docker exec -it orator-serviceserver-restify-dev /bin/bash"
|
|
14
|
+
"docker-dev-shell": "docker exec -it orator-serviceserver-restify-dev /bin/bash",
|
|
15
|
+
"lint": "eslint source/**/*.js test/**/*.js",
|
|
16
|
+
"check": "tsc -p ./tsconfig.json --noEmit",
|
|
17
|
+
"types": "tsc -p ./tsconfig.build.json"
|
|
15
18
|
},
|
|
19
|
+
"types": "types/Orator-ServiceServer-Restify.d.ts",
|
|
16
20
|
"mocha": {
|
|
17
21
|
"diff": true,
|
|
18
22
|
"extension": [
|
|
@@ -42,12 +46,20 @@
|
|
|
42
46
|
},
|
|
43
47
|
"homepage": "https://github.com/stevenvelozo/orator-serviceserver-restify#readme",
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"orator-serviceserver-base": "^1.0.
|
|
49
|
+
"orator-serviceserver-base": "^1.0.5",
|
|
46
50
|
"restify": "^11.1.0"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
53
|
+
"@eslint/js": "^9.39.1",
|
|
54
|
+
"@types/jquery": "^3.5.33",
|
|
55
|
+
"@types/mocha": "^10.0.10",
|
|
56
|
+
"@types/node": "^16.18.126",
|
|
57
|
+
"@types/sinon": "^17.0.4",
|
|
58
|
+
"eslint": "^9.39.1",
|
|
59
|
+
"fable": "^3.1.61",
|
|
60
|
+
"globals": "^16.5.0",
|
|
61
|
+
"orator": "^6.0.2",
|
|
62
|
+
"quackage": "^1.0.56",
|
|
63
|
+
"typescript": "^5.9.3"
|
|
52
64
|
}
|
|
53
65
|
}
|
|
@@ -7,6 +7,11 @@ const _DefaultRestifyConfiguration =
|
|
|
7
7
|
};
|
|
8
8
|
class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
9
9
|
{
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('fable')|Record<string, any>} [pFable] - (optional) The fable instance, or the options object if there is no fable
|
|
12
|
+
* @param {Record<string, any>|string} [pOptions] - (optional) The options object, or the service hash if there is no fable
|
|
13
|
+
* @param {string} [pServiceHash] - (optional) The service hash to identify this service instance
|
|
14
|
+
*/
|
|
10
15
|
constructor(pFable, pOptions, pServiceHash)
|
|
11
16
|
{
|
|
12
17
|
super(pFable, pOptions, pServiceHash);
|
|
@@ -17,12 +22,19 @@ class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
|
17
22
|
(this.fable.settings.hasOwnProperty('RestifyConfiguration')) ? this.fable.settings.RestifyConfiguration :
|
|
18
23
|
{};
|
|
19
24
|
|
|
25
|
+
/** @type {libRestify} */
|
|
20
26
|
this.server = libRestify.createServer(Object.assign({}, _DefaultRestifyConfiguration, tmpRestifyConfiguration));
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
/*
|
|
24
30
|
* Service Lifecycle Functions
|
|
25
31
|
*************************************************************************/
|
|
32
|
+
/**
|
|
33
|
+
* Listens for network calls on the specified port (or starts a virtual serviceserver for that "port").
|
|
34
|
+
* @param {number} pPort - The port number to listen on.
|
|
35
|
+
* @param {(pError?: Error) => void} fCallback - The callback function to execute after listening.
|
|
36
|
+
* @return {any} The result of the callback function.
|
|
37
|
+
*/
|
|
26
38
|
listen(pPort, fCallback)
|
|
27
39
|
{
|
|
28
40
|
this.server.listen(pPort, (pError) =>
|
|
@@ -34,6 +46,12 @@ class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
|
34
46
|
});
|
|
35
47
|
}
|
|
36
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Closes the service server.
|
|
51
|
+
*
|
|
52
|
+
* @param {(pError?: Error) => any} fCallback - The callback function to be executed after closing the server.
|
|
53
|
+
* @return {any} - The result of the callback function.
|
|
54
|
+
*/
|
|
37
55
|
close(fCallback)
|
|
38
56
|
{
|
|
39
57
|
this.server.close((pError) =>
|
|
@@ -47,6 +65,12 @@ class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
|
47
65
|
* End of Service Lifecycle Functions
|
|
48
66
|
*/
|
|
49
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Registers a global handler function to be used by the Orator service server.
|
|
70
|
+
*
|
|
71
|
+
* @param {import('orator-serviceserver-base').RequestHandler} fHandlerFunction - The handler function to be registered. It should have the prototype function(Request, Response, Next).
|
|
72
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
73
|
+
*/
|
|
50
74
|
use(fHandlerFunction)
|
|
51
75
|
{
|
|
52
76
|
if (!super.use(fHandlerFunction))
|
|
@@ -58,6 +82,12 @@ class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
|
58
82
|
this.server.use(fHandlerFunction);
|
|
59
83
|
}
|
|
60
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Registers a global handler function to be used by the Orator service server that runs before routing.
|
|
87
|
+
*
|
|
88
|
+
* @param {function} fHandlerFunction - The handler function to be registered. It should have the prototype function(Request, Response, Next).
|
|
89
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
90
|
+
*/
|
|
61
91
|
pre(fHandlerFunction)
|
|
62
92
|
{
|
|
63
93
|
if (!super.pre(fHandlerFunction))
|
|
@@ -69,11 +99,17 @@ class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
|
69
99
|
this.server.pre(fHandlerFunction);
|
|
70
100
|
}
|
|
71
101
|
|
|
72
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Middleware function for parsing the request body.
|
|
104
|
+
*
|
|
105
|
+
* @param {Record<string, any>} [pOptions] - The options for the body parser.
|
|
106
|
+
* @return {import('orator-serviceserver-base').RequestHandler} - The middleware function.
|
|
107
|
+
*/
|
|
108
|
+
bodyParser(pOptions)
|
|
73
109
|
{
|
|
74
110
|
// Restify has a built-in bodyParser plugin that returns a standard
|
|
75
111
|
// f(Request, Response, Next) => {}; function.
|
|
76
|
-
return libRestify.plugins.bodyParser(
|
|
112
|
+
return libRestify.plugins.bodyParser(Object.assign(
|
|
77
113
|
{
|
|
78
114
|
maxBodySize: 0,
|
|
79
115
|
mapParams: false,
|
|
@@ -97,42 +133,91 @@ class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
|
97
133
|
*/
|
|
98
134
|
multiples: true,
|
|
99
135
|
hash: 'sha1'
|
|
100
|
-
});
|
|
136
|
+
}, pOptions));
|
|
101
137
|
}
|
|
102
138
|
|
|
103
139
|
/*
|
|
104
140
|
* Service Route Functions
|
|
105
141
|
*************************************************************************/
|
|
142
|
+
/**
|
|
143
|
+
* Handles HTTP GET requests -- this is a base function that does nothing; override by the serviceserver is expected.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} pRoute - The route of the request.
|
|
146
|
+
* @param {...Function} fRouteProcessingFunctions - The processing functions for the route.
|
|
147
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
148
|
+
*/
|
|
106
149
|
doGet(pRoute, ...fRouteProcessingFunctions)
|
|
107
150
|
{
|
|
108
151
|
return this.server.get(pRoute, ...fRouteProcessingFunctions);
|
|
109
152
|
}
|
|
110
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Handles HTTP PUT requests -- this is a base function that does nothing; override by the serviceserver is expected.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} pRoute - The route to handle.
|
|
158
|
+
* @param {...Function} fRouteProcessingFunctions - The processing functions to execute for the route.
|
|
159
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
160
|
+
*/
|
|
111
161
|
doPut(pRoute, ...fRouteProcessingFunctions)
|
|
112
162
|
{
|
|
113
163
|
return this.server.put(pRoute, ...fRouteProcessingFunctions);
|
|
114
164
|
}
|
|
115
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Handles the HTTP POST request for a specific route.
|
|
168
|
+
*
|
|
169
|
+
* @param {string} pRoute - The route to handle the POST request for.
|
|
170
|
+
* @param {...Function} fRouteProcessingFunctions - The processing functions to execute for the route.
|
|
171
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
172
|
+
*/
|
|
116
173
|
doPost(pRoute, ...fRouteProcessingFunctions)
|
|
117
174
|
{
|
|
118
175
|
return this.server.post(pRoute, ...fRouteProcessingFunctions);
|
|
119
176
|
}
|
|
120
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Handles HTTP DELETE requests -- this is a base function that does nothing; override by the serviceserver is expected.
|
|
180
|
+
*
|
|
181
|
+
* @param {string} pRoute - The route of the resource to delete.
|
|
182
|
+
* @param {...Function} fRouteProcessingFunctions - The processing functions to be executed to delete the resource.
|
|
183
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
184
|
+
*/
|
|
121
185
|
doDel(pRoute, ...fRouteProcessingFunctions)
|
|
122
186
|
{
|
|
123
187
|
return this.server.del(pRoute, ...fRouteProcessingFunctions);
|
|
124
188
|
}
|
|
125
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Handles HTTP PATCH requests -- this is a base function that does nothing; override by the serviceserver is expected.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} pRoute - The route to send the PATCH request to.
|
|
194
|
+
* @param {...Function} fRouteProcessingFunctions - The processing functions to apply to the route.
|
|
195
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
196
|
+
*/
|
|
126
197
|
doPatch(pRoute, ...fRouteProcessingFunctions)
|
|
127
198
|
{
|
|
128
199
|
return this.server.patch(pRoute, ...fRouteProcessingFunctions);
|
|
129
200
|
}
|
|
130
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Handles HTTP OPT requests -- this is a base function that does nothing; override by the serviceserver is expected.
|
|
204
|
+
*
|
|
205
|
+
* @param {string} pRoute - The route.
|
|
206
|
+
* @param {...Function} fRouteProcessingFunctions - The processing functions to apply to the route.
|
|
207
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
208
|
+
*/
|
|
131
209
|
doOpts(pRoute, ...fRouteProcessingFunctions)
|
|
132
210
|
{
|
|
133
211
|
return this.server.opts(pRoute, ...fRouteProcessingFunctions);
|
|
134
212
|
}
|
|
135
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Handles HTTP HEAD requests -- this is a base function that does nothing; override by the serviceserver is expected.
|
|
216
|
+
*
|
|
217
|
+
* @param {string} pRoute - The route to handle the HEAD request for.
|
|
218
|
+
* @param {...Function} fRouteProcessingFunctions - The processing functions to execute for the route.
|
|
219
|
+
* @returns {any} - The result of adding the route to the concrete service provider (ex. a route object, a boolean).
|
|
220
|
+
*/
|
|
136
221
|
doHead(pRoute, ...fRouteProcessingFunctions)
|
|
137
222
|
{
|
|
138
223
|
return this.server.head(pRoute, ...fRouteProcessingFunctions);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["source"],
|
|
3
|
+
"compilerOptions":
|
|
4
|
+
{
|
|
5
|
+
"lib": ["es2017", "dom"],
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"checkJs": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"emitDeclarationOnly": true,
|
|
11
|
+
"outDir": "types",
|
|
12
|
+
"declarationMap": true,
|
|
13
|
+
"resolveJsonModule": true
|
|
14
|
+
}
|
|
15
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["source", "test"],
|
|
3
|
+
"compilerOptions":
|
|
4
|
+
{
|
|
5
|
+
"lib": ["es2017", "dom"],
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"checkJs": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"emitDeclarationOnly": true,
|
|
11
|
+
"outDir": "types",
|
|
12
|
+
"declarationMap": true,
|
|
13
|
+
"resolveJsonModule": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export = OratorServiceServerRestify;
|
|
2
|
+
declare class OratorServiceServerRestify extends libOratorServiceServerBase {
|
|
3
|
+
/** @type {libRestify} */
|
|
4
|
+
server: libRestify;
|
|
5
|
+
}
|
|
6
|
+
import libOratorServiceServerBase = require("orator-serviceserver-base");
|
|
7
|
+
//# sourceMappingURL=Orator-ServiceServer-Restify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Orator-ServiceServer-Restify.d.ts","sourceRoot":"","sources":["../source/Orator-ServiceServer-Restify.js"],"names":[],"mappings":";AAOA;IAiBE,yBAAyB;IACzB,QADW,UAAU,CAC0F;CA0MhH"}
|