orator-serviceserver-restify 1.0.4 → 2.0.2
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.
- package/.config/code-server/config.yaml +4 -0
- package/.vscode/launch.json +46 -0
- package/Dockerfile_LUXURYCode +69 -0
- package/README.md +3 -2
- package/debug/Harness.js +55 -0
- package/package.json +51 -46
- package/source/Orator-ServiceServer-Restify.js +6 -4
- package/test/Orator-ServiceServer-Restify_basic_tests.js +20 -11
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Launch Debug Harness",
|
|
9
|
+
"type": "pwa-node",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"outputCapture": "std",
|
|
12
|
+
"skipFiles": [
|
|
13
|
+
"<node_internals>/**"
|
|
14
|
+
],
|
|
15
|
+
"program": "${workspaceFolder}/debug/Harness.js",
|
|
16
|
+
"presentation": {
|
|
17
|
+
"hidden": false,
|
|
18
|
+
"group": "",
|
|
19
|
+
"order": 1
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Mocha Tests",
|
|
24
|
+
"args": [
|
|
25
|
+
"-u",
|
|
26
|
+
"tdd",
|
|
27
|
+
"--timeout",
|
|
28
|
+
"999999",
|
|
29
|
+
"--colors",
|
|
30
|
+
"${workspaceFolder}/test"
|
|
31
|
+
],
|
|
32
|
+
"internalConsoleOptions": "openOnSessionStart",
|
|
33
|
+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
|
34
|
+
"request": "launch",
|
|
35
|
+
"skipFiles": [
|
|
36
|
+
"<node_internals>/**"
|
|
37
|
+
],
|
|
38
|
+
"type": "pwa-node",
|
|
39
|
+
"presentation": {
|
|
40
|
+
"hidden": false,
|
|
41
|
+
"group": "",
|
|
42
|
+
"order": 2
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Use the codercom/code-server image
|
|
2
|
+
FROM codercom/code-server:latest
|
|
3
|
+
LABEL org.opencontainers.image.authors="steven@velozo.com"
|
|
4
|
+
|
|
5
|
+
VOLUME /home/coder/.config
|
|
6
|
+
VOLUME /home/coder/.vscode
|
|
7
|
+
|
|
8
|
+
RUN echo "...installing debian dependencies..."
|
|
9
|
+
RUN sudo apt update
|
|
10
|
+
RUN sudo apt install vim curl tmux -y
|
|
11
|
+
|
|
12
|
+
RUN echo "Building development image..."
|
|
13
|
+
|
|
14
|
+
RUN echo "...installing vscode extensions..."
|
|
15
|
+
|
|
16
|
+
# Mocha unit testing in the sidebar
|
|
17
|
+
RUN code-server --install-extension hbenl.vscode-mocha-test-adapter
|
|
18
|
+
RUN code-server --install-extension hbenl.test-adapter-converter
|
|
19
|
+
RUN code-server --install-extension hbenl.vscode-test-explorer
|
|
20
|
+
|
|
21
|
+
# Magic indentation rainbow
|
|
22
|
+
RUN code-server --install-extension oderwat.indent-rainbow
|
|
23
|
+
RUN code-server --install-extension dbaeumer.vscode-eslint
|
|
24
|
+
|
|
25
|
+
# Contextual git
|
|
26
|
+
RUN code-server --install-extension eamodio.gitlens
|
|
27
|
+
|
|
28
|
+
# Other extensions (uncomment them to have them automagic, or run this from a terminal to install in the container):
|
|
29
|
+
|
|
30
|
+
# Microsoft's AI code completion
|
|
31
|
+
# RUN code-server --install-extension VisualStudioExptTeam.vscodeintellicode
|
|
32
|
+
|
|
33
|
+
# Live server -- make sure to open up the port on the docker image
|
|
34
|
+
# RUN code-server --install-extension ritwickdey.LiveServer
|
|
35
|
+
|
|
36
|
+
# Quick link to required modules' documentation
|
|
37
|
+
# RUN code-server --install-extension bengreenier.vscode-node-readme
|
|
38
|
+
|
|
39
|
+
# Switch up fonts
|
|
40
|
+
# RUN code-server --install-extension evan-buss.font-switcher
|
|
41
|
+
|
|
42
|
+
# Icons
|
|
43
|
+
# RUN code-server --install-extension vscode-icons-team.vscode-icons
|
|
44
|
+
# RUN code-server --install-extension PKief.material-icon-theme
|
|
45
|
+
|
|
46
|
+
# Hover over CSS colors to see them previewed
|
|
47
|
+
# RUN code-server --install-extension bierner.color-info
|
|
48
|
+
|
|
49
|
+
# An easy on the eyes color theme
|
|
50
|
+
# RUN code-server --install-extension daylerees.rainglow
|
|
51
|
+
|
|
52
|
+
RUN echo "...mapping library specific volumes..."
|
|
53
|
+
|
|
54
|
+
# Volume mapping for code
|
|
55
|
+
VOLUME /home/coder/orator-serviceserver-restify
|
|
56
|
+
|
|
57
|
+
SHELL ["/bin/bash", "-c"]
|
|
58
|
+
USER coder
|
|
59
|
+
|
|
60
|
+
RUN echo "...installing node version manager..."
|
|
61
|
+
# Because there is a .bashrc chicken/egg problem, we will create one here to simulate logging in. This is not great.
|
|
62
|
+
RUN touch ~/.bashrc && chmod +x ~/.bashrc
|
|
63
|
+
RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
|
|
64
|
+
|
|
65
|
+
RUN echo "...installing node version 14 as the default..."
|
|
66
|
+
RUN . ~/.nvm/nvm.sh && source ~/.bashrc && nvm install 14
|
|
67
|
+
RUN . ~/.nvm/nvm.sh && source ~/.bashrc && nvm alias default 14
|
|
68
|
+
|
|
69
|
+
WORKDIR /home/coder/orator-serviceserver-restify
|
package/README.md
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Restify Orator Service Server
|
|
2
|
+
|
|
3
|
+
Restify abstraction for Orator. Needs more documentation. Feeling brave? You can `npm i` and `node debug/Harness.js` and it will serve up a silly test endpoint.
|
package/debug/Harness.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const libFable = require('fable');
|
|
2
|
+
const defaultFableSettings = (
|
|
3
|
+
{
|
|
4
|
+
Product:'Orator-ServiceServer-Restify-Harness',
|
|
5
|
+
ProductVersion: '1.0.0',
|
|
6
|
+
APIServerPort: 7766
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// Initialize Fable
|
|
10
|
+
let _Fable = new libFable(defaultFableSettings);
|
|
11
|
+
|
|
12
|
+
// Now initialize the Restify ServiceServer Fable Service
|
|
13
|
+
// If we don't initialize this, orator will initialize IPC by default.
|
|
14
|
+
// TODO: Should that be different in node than browser? Easy to change.
|
|
15
|
+
_Fable.serviceManager.addServiceType('OratorServiceServer', require('../source/Orator-ServiceServer-Restify.js'));
|
|
16
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorServiceServer',
|
|
17
|
+
{
|
|
18
|
+
RestifyConfiguration: { strictNext: true }
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Now add the orator service to Fable
|
|
22
|
+
_Fable.serviceManager.addServiceType('Orator', require('orator'));
|
|
23
|
+
let _Orator = _Fable.serviceManager.instantiateServiceProvider('Orator', {});
|
|
24
|
+
|
|
25
|
+
_Fable.Utility.waterfall(
|
|
26
|
+
[
|
|
27
|
+
_Orator.initialize.bind(_Orator),
|
|
28
|
+
(fStageComplete)=>
|
|
29
|
+
{
|
|
30
|
+
// Create an endpoint. This can also be done after the service is started.
|
|
31
|
+
_Orator.serviceServer.get
|
|
32
|
+
(
|
|
33
|
+
'/test/:hash',
|
|
34
|
+
(pRequest, pResponse, fNext) =>
|
|
35
|
+
{
|
|
36
|
+
// Send back the request parameters
|
|
37
|
+
pResponse.send(pRequest.params);
|
|
38
|
+
_Orator.fable.log.info(`Endpoint sent parameters object:`,pRequest.params);
|
|
39
|
+
// Restify will be unhappy with this due to strictNext
|
|
40
|
+
fNext()
|
|
41
|
+
return fNext();
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
return fStageComplete();
|
|
45
|
+
},
|
|
46
|
+
_Orator.startService.bind(_Orator),
|
|
47
|
+
],
|
|
48
|
+
(pError)=>
|
|
49
|
+
{
|
|
50
|
+
if (pError)
|
|
51
|
+
{
|
|
52
|
+
_Fable.log.error('Error initializing Orator Service Server: '+pError.message, pError);
|
|
53
|
+
}
|
|
54
|
+
_Fable.log.info('Orator Service Server Initialized.');
|
|
55
|
+
});
|
package/package.json
CHANGED
|
@@ -1,48 +1,53 @@
|
|
|
1
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
|
-
|
|
2
|
+
"name": "orator-serviceserver-restify",
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "Restify Service Server for Orator",
|
|
5
|
+
"main": "source/Orator-ServiceServer-Restify.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "./node_modules/mocha/bin/_mocha --exit -u tdd -R spec",
|
|
8
|
+
"coverage": "./node_modules/.bin/nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec",
|
|
9
|
+
"start": "node source/Orator-ServiceServer-Restify.js",
|
|
10
|
+
"tests": "npx mocha -u tdd --exit -R spec --grep",
|
|
11
|
+
"build": "npx quack build",
|
|
12
|
+
"docker-dev-build": "docker build ./ -f Dockerfile_LUXURYCode -t orator-serviceserver-restify-image:local",
|
|
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"
|
|
15
|
+
},
|
|
16
|
+
"mocha": {
|
|
17
|
+
"diff": true,
|
|
18
|
+
"extension": [
|
|
19
|
+
"js"
|
|
20
|
+
],
|
|
21
|
+
"package": "./package.json",
|
|
22
|
+
"reporter": "spec",
|
|
23
|
+
"slow": "75",
|
|
24
|
+
"timeout": "5000",
|
|
25
|
+
"ui": "tdd",
|
|
26
|
+
"watch-files": [
|
|
27
|
+
"source/**/*.js",
|
|
28
|
+
"test/**/*.js"
|
|
29
|
+
],
|
|
30
|
+
"watch-ignore": [
|
|
31
|
+
"lib/vendor"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/stevenvelozo/orator-serviceserver-restify.git"
|
|
37
|
+
},
|
|
38
|
+
"author": "steven velozo <steven@velozo.com>",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/stevenvelozo/orator-serviceserver-restify/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/stevenvelozo/orator-serviceserver-restify#readme",
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"orator-serviceserver-base": "^1.0.0",
|
|
46
|
+
"restify": "^11.1.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"fable": "^3.0.96",
|
|
50
|
+
"orator": "^4.0.2",
|
|
51
|
+
"quackage": "^1.0.24"
|
|
52
|
+
}
|
|
48
53
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
const libOratorServiceServerBase = require('orator')
|
|
1
|
+
const libOratorServiceServerBase = require('orator-serviceserver-base');
|
|
2
2
|
const libRestify = require('restify');
|
|
3
3
|
|
|
4
4
|
class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
5
5
|
{
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
7
7
|
{
|
|
8
|
-
|
|
8
|
+
super(pFable, pOptions, pServiceHash);
|
|
9
9
|
|
|
10
10
|
this.ServiceServerType = 'Restify';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
let tmpRestifyConfiguration = (this.options.hasOwnProperty('RestifyConfiguration')) ? this.options.RestifyConfiguration : {};
|
|
13
|
+
this.server = libRestify.createServer(tmpRestifyConfiguration);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
/*
|
|
@@ -20,6 +21,7 @@ class OratorServiceServerRestify extends libOratorServiceServerBase
|
|
|
20
21
|
this.server.listen(pPort, (pError) =>
|
|
21
22
|
{
|
|
22
23
|
this.Active = true;
|
|
24
|
+
this.Port = pPort;
|
|
23
25
|
this.log.info(`RESTIFY server [${this.server.name}] listening on [${this.server.url}].`);
|
|
24
26
|
return fCallback(pError);
|
|
25
27
|
});
|
|
@@ -9,12 +9,6 @@ const Expect = Chai.expect;
|
|
|
9
9
|
const Assert = Chai.assert;
|
|
10
10
|
|
|
11
11
|
const libFable = require('fable');
|
|
12
|
-
|
|
13
|
-
const _Fable = new libFable({
|
|
14
|
-
"Product": "Orator-ServiceServier-Restify-BasicTests",
|
|
15
|
-
"ProductVersion": "0.0.0"
|
|
16
|
-
})
|
|
17
|
-
|
|
18
12
|
const libOrator = require('orator');
|
|
19
13
|
const libOratorServiceServerRestify = require('../source/Orator-ServiceServer-Restify.js');
|
|
20
14
|
|
|
@@ -22,7 +16,7 @@ const libOratorServiceServerRestify = require('../source/Orator-ServiceServer-Re
|
|
|
22
16
|
|
|
23
17
|
suite
|
|
24
18
|
(
|
|
25
|
-
'
|
|
19
|
+
'Orator Restify Abstraction',
|
|
26
20
|
() =>
|
|
27
21
|
{
|
|
28
22
|
suite
|
|
@@ -35,13 +29,28 @@ suite
|
|
|
35
29
|
'The class should initialize itself into a happy little object.',
|
|
36
30
|
function (fDone)
|
|
37
31
|
{
|
|
38
|
-
|
|
32
|
+
// Initialize fable
|
|
33
|
+
let tmpFable = new libFable();
|
|
34
|
+
|
|
35
|
+
// Add Restify as the default service server type
|
|
36
|
+
tmpFable.addServiceType('OratorServiceServer', libOratorServiceServerRestify);
|
|
37
|
+
|
|
38
|
+
// We can safely create the service now if we want, or after Orator is created. As long as it's before we initialize orator.
|
|
39
|
+
let tmpOratorServiceServerRestify = tmpFable.instantiateServiceProvider('OratorServiceServer', {});
|
|
40
|
+
|
|
41
|
+
// Add Orator as a service
|
|
42
|
+
tmpFable.addServiceType('Orator', libOrator);
|
|
43
|
+
|
|
44
|
+
// Initialize the Orator service
|
|
45
|
+
let tmpOrator = tmpFable.instantiateServiceProvider('Orator', {});
|
|
46
|
+
// Sanity check Orator
|
|
39
47
|
Expect(tmpOrator).to.be.an('object', 'Orator should initialize as an object directly from the require statement.');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
tmpOrator.initializeServiceServer(
|
|
48
|
+
|
|
49
|
+
tmpOrator.initialize(
|
|
43
50
|
(pError)=>
|
|
44
51
|
{
|
|
52
|
+
Expect(tmpOrator.startService).to.be.an('function');
|
|
53
|
+
|
|
45
54
|
Expect(tmpOrator.serviceServer.ServiceServerType).to.equal('Restify', 'The service server provider should be Restify.');
|
|
46
55
|
fDone();
|
|
47
56
|
});
|