@blaasvaer/frmwrk 0.3.1 → 0.3.3

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/controllers.js CHANGED
@@ -23,6 +23,7 @@ function installControllers ( config ) {
23
23
  if ( controller ) {
24
24
  if ( typeof controller.install === 'function' ) {
25
25
  // Add controller if it exports install
26
+ this.controllers = {};
26
27
  this.controllers[ file.split('.')[0] ] = controller;
27
28
 
28
29
  // Trigger install script for controller
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,13 +48,10 @@ if ( process.env.NODE_ENV !== 'production') {
46
48
  * @return {Node} Node
47
49
  */
48
50
  FW = function ( config ) {
49
- let _this = this;
51
+ _config = config || {};
50
52
 
51
53
  hostname = config.hostname ? config.hostname : '0.0.0.0';
52
54
 
53
- controllers = {};
54
- models = {};
55
-
56
55
  /**
57
56
  * Set the Controller
58
57
  * @param {string} name The name of 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
  */
@@ -130,10 +133,16 @@ console.log("Authorize - check credentials:", credentials);
130
133
  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 = function Install ( config ) {
146
- // global.publicPath = config.root + '/themes/' + config.theme + '/' + 'public/';
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')( config ),
155
- require('./models')( config ),
156
- require('./views')( config ),
157
- require('./connections')( config ),
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/models.js CHANGED
@@ -24,6 +24,7 @@ function installModels ( config ) {
24
24
  /**
25
25
  * Add model if it exports install
26
26
  */
27
+ this.models = {};
27
28
  this.models[ file.split('.')[0] ] = model;
28
29
 
29
30
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaasvaer/frmwrk",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "My personal Node framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "homepage": "https://bitbucket.org/blaasvaer/frmwrk#readme",
27
27
  "dependencies": {
28
- "serve-handler": "^6.1.3"
28
+ "serve-handler": "^6.1.3",
29
+ "socket.io": "^4.8.1"
29
30
  }
30
31
  }