@blaasvaer/frmwrk 0.2.7 → 0.3.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.
- package/index.js +24 -16
- package/package.json +1 -1
- package/package 2.json +0 -30
package/index.js
CHANGED
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
* Native modules
|
|
11
11
|
*/
|
|
12
12
|
const http = require('http');
|
|
13
|
+
const { Server } = require('socket.io');
|
|
13
14
|
|
|
14
15
|
let port;
|
|
16
|
+
let _config;
|
|
17
|
+
let _io;
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* Custom modules
|
|
@@ -22,8 +25,7 @@ const Utils = require('./utils');
|
|
|
22
25
|
/**
|
|
23
26
|
* Define variables
|
|
24
27
|
*/
|
|
25
|
-
let hostname
|
|
26
|
-
server;
|
|
28
|
+
let hostname;
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* If port number is passed in as first (custom) parameter, set port
|
|
@@ -46,12 +48,9 @@ if ( process.env.NODE_ENV !== 'production') {
|
|
|
46
48
|
* @return {Node} Node
|
|
47
49
|
*/
|
|
48
50
|
FW = function ( config ) {
|
|
49
|
-
|
|
51
|
+
_config = config || {};
|
|
50
52
|
|
|
51
|
-
hostname =
|
|
52
|
-
|
|
53
|
-
controllers = {};
|
|
54
|
-
models = {};
|
|
53
|
+
hostname = _config.hostname ? _config.hostname : '0.0.0.0';
|
|
55
54
|
|
|
56
55
|
/**
|
|
57
56
|
* Set the Controller
|
|
@@ -114,6 +113,10 @@ console.log("Authorize - check credentials:", credentials);
|
|
|
114
113
|
// return true;
|
|
115
114
|
}
|
|
116
115
|
|
|
116
|
+
getSocketIO = () => {
|
|
117
|
+
return _io;
|
|
118
|
+
}
|
|
119
|
+
|
|
117
120
|
/**
|
|
118
121
|
* Install framework components and start the server
|
|
119
122
|
*/
|
|
@@ -127,13 +130,19 @@ console.log("Authorize - check credentials:", credentials);
|
|
|
127
130
|
* Create and start the server
|
|
128
131
|
* @return {function} Server instance
|
|
129
132
|
*/
|
|
130
|
-
http.createServer( handleRequest ).listen(port, hostname, () => {
|
|
133
|
+
const server = http.createServer( handleRequest ).listen(port, hostname, () => {
|
|
131
134
|
console.log(`Server running at http://${hostname}:${port}`);
|
|
132
135
|
});
|
|
136
|
+
|
|
137
|
+
if ( config.enable_socket_io ) {
|
|
138
|
+
_io = new Server( server );
|
|
139
|
+
}
|
|
133
140
|
})
|
|
134
141
|
.catch(function( err ) {
|
|
135
142
|
console.log("Install Error:", err);
|
|
136
|
-
})
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return this;
|
|
137
146
|
};
|
|
138
147
|
|
|
139
148
|
/**
|
|
@@ -142,19 +151,18 @@ console.log("Install Error:", err);
|
|
|
142
151
|
* Installs the components of the framework like; controllers, models, views, users etc.
|
|
143
152
|
* @param {Object} config Config object
|
|
144
153
|
*/
|
|
145
|
-
global.Install =
|
|
146
|
-
|
|
147
|
-
global.publicPath = config.root + '/themes/' + config.theme;
|
|
154
|
+
global.Install = () => {
|
|
155
|
+
global.publicPath = _config.root + '/themes/' + _config.theme;
|
|
148
156
|
|
|
149
157
|
/**
|
|
150
158
|
* Installation processes to run
|
|
151
159
|
* @type {Array}
|
|
152
160
|
*/
|
|
153
161
|
let install_processes = [
|
|
154
|
-
require('./controllers')(
|
|
155
|
-
require('./models')(
|
|
156
|
-
require('./views')(
|
|
157
|
-
require('./connections')(
|
|
162
|
+
require('./controllers')( _config ),
|
|
163
|
+
require('./models')( _config ),
|
|
164
|
+
require('./views')( _config ),
|
|
165
|
+
require('./connections')( _config ),
|
|
158
166
|
// require('./users')( config )
|
|
159
167
|
];
|
|
160
168
|
|
package/package.json
CHANGED
package/package 2.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@blaasvaer/frmwrk",
|
|
3
|
-
"version": "0.1.14",
|
|
4
|
-
"description": "My personal Node framework",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"patch": "npm version patch --force && npm publish",
|
|
9
|
-
"major": "npm version major --force && npm publish",
|
|
10
|
-
"minor": "npm version minor --force && npm publish"
|
|
11
|
-
},
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+ssh://git@bitbucket.org/blaasvaer/frmwrk.git"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"Node",
|
|
18
|
-
"Framework",
|
|
19
|
-
"Homebrew"
|
|
20
|
-
],
|
|
21
|
-
"author": "Sam Blåsvær",
|
|
22
|
-
"license": "ISC",
|
|
23
|
-
"bugs": {
|
|
24
|
-
"url": "https://bitbucket.org/blaasvaer/frmwrk/issues"
|
|
25
|
-
},
|
|
26
|
-
"homepage": "https://bitbucket.org/blaasvaer/frmwrk#readme",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"serve-handler": "^6.1.3"
|
|
29
|
-
}
|
|
30
|
-
}
|