
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Worker
In project root create worker.js
:
const conf = require('nconf')
require('dm-sharedb-server/nconf')
const path = require('path')
// full path to workerActions.js and workerInit.js
process.env['WORKER_ACTIONS_PATH'] = path.join(process.cwd(), './build/workerActions.js')
process.env['WORKER_INIT_PATH'] = path.join(process.cwd(), './build/workerInit.js')
const TaskDispatcher = require('dm-worker')
const dispatcher = new TaskDispatcher()
dispatcher.start().catch((err) => {
console.log('Error starting worker', err)
})
In project root create workerInit.js
. Do any initializations here (plug in hooks, ORM, etc.).
Since this file may be compiled by webpack, use global.DM_WORKER_INIT
instead of module.exports
:
import 'dm-sharedb-server/nconf'
import ShareDB from 'sharedb'
import richText from 'rich-text'
import Racer from 'racer'
import derbyAr from 'derby-ar'
import ormEntities from './model'
import shareDbHooks from 'sharedb-hooks'
import hooks from './server/hooks'
let init = global.DM_WORKER_INIT = function (backend) {
// Register rich-text type in ShareDB
ShareDB.types.register(richText.type)
// Init ORM
Racer.use(derbyAr)
Racer.use(ormEntities)
shareDbHooks(backend)
hooks(backend)
}
In project root create workerActions.js
. Put your tasks here (name of functions are the name of tasks).
Since this file may be compiled by webpack, use global.DM_WORKER_ACTIONS
instead of module.exports
:
let ACTIONS = global.DM_WORKER_ACTIONS = {}
ACTIONS.test = function (model, task, done) {
console.log('>> Start test task', task.id)
setTimeout(() => {
console.log('>> Finish test task', task.id)
done()
}, 5000)
}
Add worker
, workerInit
, workerActions
to webpack.config.js
of dm-react-webpack
:
module.exports = {
// ...
backendApps: {
server: path.join(__dirname, 'server'),
worker: path.join(__dirname, 'worker'),
workerActions: path.join(__dirname, 'workerActions'),
workerInit: path.join(__dirname, 'workerInit')
}
// ...
}
Copyright (c) 2019 Decision Mapper
FAQs
> Worker
The npm package dm-worker receives a total of 8 weekly downloads. As such, dm-worker popularity was classified as not popular.
We found that dm-worker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.