orator-static-server 1.0.1 → 1.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/LICENSE +1 -1
- package/README.md +102 -3
- package/docs/.nojekyll +0 -0
- package/docs/README.md +49 -0
- package/docs/_sidebar.md +9 -0
- package/docs/api-reference.md +68 -0
- package/docs/cover.md +11 -0
- package/docs/getting-started.md +84 -0
- package/docs/index.html +39 -0
- package/docs/subdomain-routing.md +63 -0
- package/package.json +10 -7
- package/source/Orator-Static-Server.js +125 -90
- package/test/Orator-Static-Server_tests.js +1413 -0
- package/test/static_content/about.html +1 -0
- package/test/static_content/app.js +1 -0
- package/test/static_content/data.json +1 -0
- package/test/static_content/index.html +1 -0
- package/test/static_content/style.css +1 -0
- package/test/static_content/subsite/index.html +1 -0
- package/.vscode/launch.json +0 -46
- package/debug/Harness.js +0 -75
- package/debug/serve/index.html +0 -9
- package/test/Orator-Static-Server-basic_tests.js +0 -62
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<html><head><title>About</title></head><body>About page content</body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('Hello from the test app');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"TestKey":"TestValue","Numbers":[1,2,3]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<html><head><title>Test Index</title></head><body>Welcome to the test server</body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
body { font-family: sans-serif; color: #333; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<html><head><title>Subsite</title></head><body>Subsite index page</body></html>
|
package/.vscode/launch.json
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|
package/debug/Harness.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const libFable = require('fable');
|
|
2
|
-
|
|
3
|
-
const defaultFableSettings = (
|
|
4
|
-
{
|
|
5
|
-
Product:'Orator-Static',
|
|
6
|
-
ProductVersion: '1.0.0',
|
|
7
|
-
APIServerPort: 8766,
|
|
8
|
-
|
|
9
|
-
OratorStaticServerDefaultFolder: `${__dirname}/serve/`,
|
|
10
|
-
OratorStaticServerAutoMap: true
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// Initialize Fable
|
|
14
|
-
let _Fable = new libFable(defaultFableSettings);
|
|
15
|
-
|
|
16
|
-
// Now initialize the Restify ServiceServer Fable Service
|
|
17
|
-
_Fable.serviceManager.addServiceType('OratorServiceServer', require('orator-serviceserver-restify'));
|
|
18
|
-
_Fable.serviceManager.instantiateServiceProvider('OratorServiceServer',
|
|
19
|
-
{
|
|
20
|
-
RestifyConfiguration: { strictNext: true }
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Now add the orator service to Fable
|
|
24
|
-
_Fable.serviceManager.addServiceType('Orator', require('orator'));
|
|
25
|
-
let _Orator = _Fable.serviceManager.instantiateServiceProvider('Orator', {});
|
|
26
|
-
|
|
27
|
-
let tmpAnticipate = _Fable.newAnticipate();
|
|
28
|
-
|
|
29
|
-
// Initialize the Orator server
|
|
30
|
-
tmpAnticipate.anticipate(_Orator.initialize.bind(_Orator));
|
|
31
|
-
|
|
32
|
-
// Create a simple custom endpoint on the server.
|
|
33
|
-
tmpAnticipate.anticipate(
|
|
34
|
-
(fNext)=>
|
|
35
|
-
{
|
|
36
|
-
// Create an endpoint. This can also be done after the service is started.
|
|
37
|
-
_Orator.serviceServer.get
|
|
38
|
-
(
|
|
39
|
-
'/test/:hash',
|
|
40
|
-
(pRequest, pResponse, fNext) =>
|
|
41
|
-
{
|
|
42
|
-
// Send back the request parameters
|
|
43
|
-
pResponse.send(pRequest.params);
|
|
44
|
-
_Orator.fable.log.info(`Endpoint sent parameters object:`, pRequest.params);
|
|
45
|
-
return fNext();
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
return fNext();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Add the orator static server service
|
|
52
|
-
const libOratorServeStatic = require(`../source/Orator-Static-Server.js`);
|
|
53
|
-
_Fable.serviceManager.addServiceType('OratorServeStatic', libOratorServeStatic);
|
|
54
|
-
_Fable.serviceManager.instantiateServiceProvider('OratorServeStatic', {LogLevel: 2});
|
|
55
|
-
|
|
56
|
-
// Manually map the ./serve/ folder to the root of the server.
|
|
57
|
-
// tmpAnticipate.anticipate(
|
|
58
|
-
// (fNext)=>
|
|
59
|
-
// {
|
|
60
|
-
// _Fable.OratorServeStatic.addStaticRoute(`${__dirname}/serve/`, 'index.html');
|
|
61
|
-
// return fNext();
|
|
62
|
-
// });
|
|
63
|
-
|
|
64
|
-
// Now start the service server.
|
|
65
|
-
tmpAnticipate.anticipate(_Orator.startService.bind(_Orator));
|
|
66
|
-
|
|
67
|
-
tmpAnticipate.wait(
|
|
68
|
-
(pError)=>
|
|
69
|
-
{
|
|
70
|
-
if (pError)
|
|
71
|
-
{
|
|
72
|
-
_Fable.log.error('Error initializing Orator Service Server: '+pError.message, pError);
|
|
73
|
-
}
|
|
74
|
-
_Fable.log.info('Orator Service Server Initialized.');
|
|
75
|
-
});
|
package/debug/serve/index.html
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>Debug</title>
|
|
4
|
-
</head>
|
|
5
|
-
<body>
|
|
6
|
-
<h1>Debug</h1>
|
|
7
|
-
<p>Debugging is the process of finding and resolving defects or problems within a computer program that prevent correct operation of computer software or a system.</p>
|
|
8
|
-
</body>
|
|
9
|
-
</html>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for Orator
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Steven Velozo <steven@velozo.com>
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const Chai = require("chai");
|
|
8
|
-
const Expect = Chai.expect;
|
|
9
|
-
const Assert = Chai.assert;
|
|
10
|
-
|
|
11
|
-
const libFable = require('fable');
|
|
12
|
-
const libOrator = require('orator');
|
|
13
|
-
const libOratorStaticServer = require('../source/Orator-Static-Server.js');
|
|
14
|
-
|
|
15
|
-
//const libSuperTest = require('supertest');
|
|
16
|
-
|
|
17
|
-
suite
|
|
18
|
-
(
|
|
19
|
-
'Orator Restify Abstraction',
|
|
20
|
-
() =>
|
|
21
|
-
{
|
|
22
|
-
suite
|
|
23
|
-
(
|
|
24
|
-
'Object Sanity',
|
|
25
|
-
() =>
|
|
26
|
-
{
|
|
27
|
-
test
|
|
28
|
-
(
|
|
29
|
-
'The class should initialize itself into a happy little object.',
|
|
30
|
-
function (fDone)
|
|
31
|
-
{
|
|
32
|
-
// Initialize fable
|
|
33
|
-
let tmpFable = new libFable();
|
|
34
|
-
|
|
35
|
-
// Add Restify as the default service server type
|
|
36
|
-
tmpFable.addServiceType('OratorStaticServer', libOratorStaticServer);
|
|
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('OratorStaticServer', {});
|
|
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
|
|
47
|
-
Expect(tmpOrator).to.be.an('object', 'Orator should initialize as an object directly from the require statement.');
|
|
48
|
-
|
|
49
|
-
tmpOrator.initialize(
|
|
50
|
-
(pError)=>
|
|
51
|
-
{
|
|
52
|
-
Expect(tmpOrator.startService).to.be.an('function');
|
|
53
|
-
|
|
54
|
-
Expect(tmpOrator.serviceServer.ServiceServerType).to.equal('IPC', 'The service server provider should be Restify.');
|
|
55
|
-
fDone();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
);
|