Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.use(require('cors')())
app.use(bodyParser.json({ limit: FILEUPLOADSIZELIMIT }))
this.app = app
app.started = false
_.merge(app, opts)
require('./config/config').load(app)
app.version = '0.0.1'
startSecurity(app, opts ? opts.securityConfig : null)
require('./serverroutes')(app, saveSecurityConfig, getSecurityConfig)
require('./put').start(app)
app.signalk = new FullSignalK(app.selfId, app.selfType, app.config.defaults)
const deltachain = new DeltaChain(app.signalk.addDelta.bind(app.signalk))
app.registerDeltaInputHandler = deltachain.register
app.providerStatus = {}
app.setProviderStatus = function(providerId, statusMessage) {
doSetProviderStatus(providerId, statusMessage, 'status')
}
app.setProviderError = function(providerId, errorMessage) {
doSetProviderStatus(providerId, errorMessage, 'error')
}
function doSetProviderStatus(providerId, statusMessage, type) {
if (!statusMessage) {
DeltaCache.prototype.buildFullFromDeltas = function(
user,
deltas,
includeSources
) {
const signalk = new FullSignalK(
this.app.selfId,
this.app.selfType,
JSON.parse(JSON.stringify(this.defaults))
)
const addDelta = signalk.addDelta.bind(signalk)
if (includeSources) {
_.values(this.sourceDeltas).forEach(addDelta)
}
if (deltas && deltas.length) {
const secFilter = this.app.securityStrategy.shouldFilterDeltas()
? delta => this.app.securityStrategy.filterReadDelta(user, delta)
: delta => true
deltas.filter(secFilter).forEach(addDelta)