mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Register the express app to allow registration of urls.
This commit is contained in:
27
modules/node_modules/node_helper/index.js
generated
vendored
27
modules/node_modules/node_helper/index.js
generated
vendored
@@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
var Class = require('../../../js/class.js');
|
||||
var express = require('express');
|
||||
var path = require('path');
|
||||
|
||||
NodeHelper = Class.extend({
|
||||
init: function() {
|
||||
@@ -26,7 +28,7 @@ NodeHelper = Class.extend({
|
||||
console.log(this.name + ' received a socket notification: ' + notification + ' - Payload: ' + payload);
|
||||
},
|
||||
|
||||
/* setName(data)
|
||||
/* setName(name)
|
||||
* Set the module name.
|
||||
*
|
||||
* argument name string - Module name.
|
||||
@@ -35,6 +37,15 @@ NodeHelper = Class.extend({
|
||||
this.name = name;
|
||||
},
|
||||
|
||||
/* setPath(path)
|
||||
* Set the module path.
|
||||
*
|
||||
* argument name string - Module name.
|
||||
*/
|
||||
setPath: function(path) {
|
||||
this.path = path;
|
||||
},
|
||||
|
||||
/* sendSocketNotification(notification, payload)
|
||||
* Send a socket notification to the node helper.
|
||||
*
|
||||
@@ -45,6 +56,20 @@ NodeHelper = Class.extend({
|
||||
this.io.of(this.name).emit(notification, payload);
|
||||
},
|
||||
|
||||
|
||||
/* setExpressApp(app)
|
||||
* Sets the express app object for this module.
|
||||
* This allows you to host files from the created webserver.
|
||||
*
|
||||
* argument app Express app - The Express app object.
|
||||
*/
|
||||
setExpressApp: function(app) {
|
||||
this.expressApp = app;
|
||||
|
||||
var publicPath = this.path + '/public';
|
||||
app.use('/' + this.name, express.static(publicPath));
|
||||
},
|
||||
|
||||
/* setSocketIO(io)
|
||||
* Sets the socket io object for this module.
|
||||
* Binds message receiver.
|
||||
|
Reference in New Issue
Block a user