Socket
Socket
Sign inDemoInstall

remotedev-server

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remotedev-server - npm Package Compare versions

Comparing version 0.3.0-beta-9 to 0.3.0

3

bin/injectServer.js

@@ -13,3 +13,4 @@ var fs = require('fs');

'0.44.0-rc.0': ' runServer(args, config, startedCallback, readyCallback);',
'0.46.0-rc.0': ' runServer(runServerArgs, configT, startedCallback, readyCallback);'
'0.46.0-rc.0': ' runServer(runServerArgs, configT, startedCallback, readyCallback);',
'0.57.0': ' runServer(args, configT);'
},

@@ -16,0 +17,0 @@ 'react-native-desktop': {

{
"client": "sqlite3",
"connection": { "filename": ":memory:" },
"pool": {
"min": 1,
"max": 1,
"idleTimeoutMillis": 360000000,
"disposeTimeout": 360000000
},
"useNullAsDefault": true,
"debug": false,
"migrate": true
}
var getPort = require('getport');
var SocketCluster = require('socketcluster');
var getOptions = require('./lib/options');

@@ -10,3 +11,2 @@

module.exports = function(argv) {
var SocketCluster = require('socketcluster').SocketCluster;
var options = Object.assign(getOptions(argv), {

@@ -13,0 +13,0 @@ workerController: __dirname + '/lib/worker.js',

@@ -9,5 +9,5 @@ exports.up = function(knex, Promise) {

table.string('action');
table.text('payload');
table.text('preloadedState');
table.text('screenshot');
table.text('payload', 'longtext');
table.text('preloadedState', 'longtext');
table.text('screenshot', 'longtext');
table.string('userAgent');

@@ -14,0 +14,0 @@ table.string('version');

@@ -20,7 +20,9 @@ var path = require('path');

},
adapter: argv.adapter || process.env.npm_package_remotedev_adapter,
dbOptions: dbOptions,
maxRequestBody: argv.passphrase || '16mb',
logHTTPRequests: argv.logHTTPRequests,
logLevel: argv.logLevel || 3
logLevel: argv.logLevel || 3,
wsEngine: argv.wsEngine || process.env.npm_package_remotedev_wsengine || 'ws'
};
}

@@ -1,2 +0,2 @@

var uuid = require('uuid');
var uuidV4 = require('uuid/v4');
var pick = require('lodash/pick');

@@ -43,3 +43,3 @@ var connector = require('./db/connector');

var reportId = uuid.v4();
var reportId = uuidV4();
var report = {

@@ -60,4 +60,4 @@ id: reportId,

meta: data.meta,
exception: data.exception,
added: Date.now()
exception: composeException(data.exception),
added: new Date().toISOString(),
};

@@ -92,2 +92,15 @@ if (data.appId) report.appId = data.appId; // TODO check if the id exists and we have access to link it

function composeException(exception) {
var message = '';
if (exception) {
message = 'Exception thrown: ';
if (exception.message)
message += exception.message;
if (exception.stack)
message += '\n' + exception.stack;
}
return message;
}
module.exports = createStore;

@@ -0,1 +1,2 @@

var SCWorker = require("socketcluster/scworker");
var path = require('path');

@@ -10,114 +11,122 @@ var app = require('express')();

module.exports.run = function(worker) {
var httpServer = worker.httpServer;
var scServer = worker.scServer;
var store = createStore(worker.options);
var limit = worker.options.maxRequestBody;
var logHTTPRequests = worker.options.logHTTPRequests;
class Worker extends SCWorker {
run() {
var httpServer = this.httpServer;
var scServer = this.scServer;
var options = this.options;
var store = createStore(options);
var limit = options.maxRequestBody;
var logHTTPRequests = options.logHTTPRequests;
httpServer.on('request', app);
httpServer.on('request', app);
app.set('view engine', 'ejs');
app.set('views', path.resolve(__dirname, '..', 'views'));
if (logHTTPRequests) {
if (typeof logHTTPRequests === 'object') app.use(morgan('combined', logHTTPRequests));
else app.use(morgan('combined'));
}
app.set('view engine', 'ejs');
app.set('views', path.resolve(__dirname, '..', 'views'));
app.use('/graphiql', graphiqlMiddleware);
if (logHTTPRequests) {
if (typeof logHTTPRequests === 'object') app.use(morgan('combined', logHTTPRequests));
else app.use(morgan('combined'));
}
app.get('*', function(req, res) {
res.render('index', { port: worker.options.port });
});
app.use('/graphiql', graphiqlMiddleware);
app.use(cors({ methods: 'POST' }));
app.use(bodyParser.json({ limit: limit }));
app.use(bodyParser.urlencoded({ limit: limit, extended: false }));
app.get('*', function (req, res) {
res.render('index', {port: options.port});
});
app.use('/graphql', graphqlMiddleware(store));
app.use(cors({methods: 'POST'}));
app.use(bodyParser.json({limit: limit}));
app.use(bodyParser.urlencoded({limit: limit, extended: false}));
app.post('/', function(req, res) {
if (!req.body) return res.status(404).end();
switch(req.body.op) {
case 'get':
store.get(req.body.id).then(function(r) {
res.send(r || {});
}).catch(function(error) {
app.use('/graphql', graphqlMiddleware(store));
app.post('/', function (req, res) {
if (!req.body) return res.status(404).end();
switch (req.body.op) {
case 'get':
store.get(req.body.id).then(function (r) {
res.send(r || {});
}).catch(function (error) {
console.error(error);
res.sendStatus(500)
});
break;
case 'list':
store.list(req.body.query, req.body.fields).then(function (r) {
res.send(r);
}).catch(function (error) {
console.error(error);
res.sendStatus(500)
});
break;
default:
store.add(req.body).then(function (r) {
res.send({id: r.id, error: r.error});
scServer.exchange.publish('report', {
type: 'add', data: r
});
}).catch(function (error) {
console.error(error);
res.status(500).send({})
});
}
});
scServer.addMiddleware(scServer.MIDDLEWARE_EMIT, function (req, next) {
var channel = req.event;
var data = req.data;
if (channel.substr(0, 3) === 'sc-' || channel === 'respond' || channel === 'log') {
scServer.exchange.publish(channel, data);
} else if (channel === 'log-noid') {
scServer.exchange.publish('log', {id: req.socket.id, data: data});
}
next();
});
scServer.addMiddleware(scServer.MIDDLEWARE_SUBSCRIBE, function (req, next) {
next();
if (req.channel === 'report') {
store.list().then(function (data) {
req.socket.emit(req.channel, {type: 'list', data: data});
}).catch(function (error) {
console.error(error);
res.sendStatus(500)
});
break;
case 'list':
store.list(req.body.query, req.body.fields).then(function(r) {
res.send(r);
}).catch(function(error) {
console.error(error);
res.sendStatus(500)
}
});
scServer.on('connection', function (socket) {
var channelToWatch, channelToEmit;
socket.on('login', function (credentials, respond) {
if (credentials === 'master') {
channelToWatch = 'respond';
channelToEmit = 'log';
} else {
channelToWatch = 'log';
channelToEmit = 'respond';
}
this.exchange.subscribe('sc-' + socket.id).watch(function (msg) {
socket.emit(channelToWatch, msg);
});
break;
default:
store.add(req.body).then(function(r) {
res.send({ id: r.id, error: r.error });
scServer.exchange.publish('report', {
type: 'add', data: r
});
}).catch(function(error) {
respond(null, channelToWatch);
});
socket.on('getReport', function (id, respond) {
store.get(id).then(function (data) {
respond(null, data);
}).catch(function (error) {
console.error(error);
res.status(500).send({})
});
}
});
scServer.addMiddleware(scServer.MIDDLEWARE_EMIT, function (req, next) {
var channel = req.event;
var data = req.data;
if (channel.substr(0, 3) === 'sc-' || channel === 'respond' || channel === 'log') {
scServer.exchange.publish(channel, data);
} else if (channel === 'log-noid') {
scServer.exchange.publish('log', { id: req.socket.id, data: data });
}
next();
});
scServer.addMiddleware(scServer.MIDDLEWARE_SUBSCRIBE, function (req, next) {
next();
if (req.channel === 'report') {
store.list().then(function(data) {
req.socket.emit(req.channel, { type: 'list', data: data });
}).catch(function(error) {
console.error(error);
});
}
});
scServer.on('connection', function(socket) {
var channelToWatch, channelToEmit;
socket.on('login', function (credentials, respond) {
if (credentials === 'master') {
channelToWatch = 'respond'; channelToEmit = 'log';
} else {
channelToWatch = 'log'; channelToEmit = 'respond';
}
worker.exchange.subscribe('sc-' + socket.id).watch(function(msg) {
socket.emit(channelToWatch, msg);
socket.on('disconnect', function () {
var channel = this.exchange.channel('sc-' + socket.id);
channel.unsubscribe();
channel.destroy();
scServer.exchange.publish(
channelToEmit,
{id: socket.id, type: 'DISCONNECTED'}
);
});
respond(null, channelToWatch);
});
socket.on('getReport', function (id, respond) {
store.get(id).then(function(data) {
respond(null, data);
}).catch(function(error) {
console.error(error);
});
});
socket.on('disconnect', function() {
var channel = worker.exchange.channel('sc-' + socket.id);
channel.unsubscribe(); channel.destroy();
scServer.exchange.publish(
channelToEmit,
{ id: socket.id, type: 'DISCONNECTED' }
);
});
});
};
};
}
new Worker();
{
"name": "remotedev-server",
"version": "0.3.0-beta-9",
"version": "0.3.0",
"description": "Run the RemoteDev monitor on your local server.",

@@ -30,3 +30,3 @@ "main": "index.js",

"engines": {
"node": ">=4.0.0"
"node": ">=6.0.0"
},

@@ -46,7 +46,6 @@ "author": "Mihail Diordiev <zalmoxisus@gmail.com> (https://github.com/zalmoxisus)",

"getport": "^0.1.0",
"graphql": "^0.10.3",
"graphql-server-express": "^1.0.0",
"graphql-tools": "^1.1.0",
"js-data": "^2.9.0",
"knex": "0.11.10",
"graphql": "^0.13.0",
"graphql-server-express": "^1.4.0",
"graphql-tools": "^4.0.3",
"knex": "^0.15.2",
"lodash": "^4.15.0",

@@ -56,4 +55,4 @@ "minimist": "^1.2.0",

"semver": "^5.3.0",
"socketcluster": "^6.7.1",
"sqlite3": "^3.1.8",
"socketcluster": "^14.3.3",
"sqlite3": "^4.0.4",
"uuid": "^3.0.1"

@@ -64,5 +63,5 @@ },

"mocha": "^3.2.0",
"socketcluster-client": "^5.1.1",
"socketcluster-client": "^14.0.0",
"supertest": "^3.0.0"
}
}

@@ -47,2 +47,18 @@ RemoteDev Server

#### Available options
| Console argument | description | default value |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| `--hostname` | hostname | localhost |
| `--port` | port | 8000 |
| `--protocol` | protocol | http |
| `--key` | the key file for [running an https server](https://github.com/SocketCluster/socketcluster#using-over-https) (`--protocol` must be set to 'https') | - |
| `--cert` | the cert file for [running an https server](https://github.com/SocketCluster/socketcluster#using-over-https) (`--protocol` must be set to 'https') | - |
| `--passphrase` | the key passphrase for [running an https server](https://github.com/SocketCluster/socketcluster#using-over-https) (`--protocol` must be set to 'https') | - |
| `--adapter` | the [database adapter](https://github.com/zalmoxisus/remotedev-server#save-reports-and-logs) name | - |
| `--dbOptions` | the [database adapter](https://github.com/zalmoxisus/remotedev-server#save-reports-and-logs) options string to pass | - |
| `--logLevel` | the socket server log level - 0=none, 1=error, 2=warn, 3=info | 3 |
| `--wsEngine` | the socket server web socket engine - ws or uws | uws |
### Inject to React Native local server

@@ -93,3 +109,3 @@

| Storage | `adapter` | `dbOptions` argument example (optional) | install |
|-----------|-----------|------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| --------- | --------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| Firebase | firebase | `{ basePath: 'https://my-app.firebase.io' }` | `npm install --save js-data-firebase` |

@@ -96,0 +112,0 @@ | HTTP | http | `{ basePath: 'https://my-rest-server/api' }` | `npm install --save js-data-http` |

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc