Emitting middleware for file removing based on socket.io and remy.
npm i remedy --save
Could be loaded from url /remedy/remedy.js
.
/* could be one argument: callback */
remedy('/remedy', function(remover) {
const from = '/';
const to = '/tmp';
const names = [
'bin'
];
const progress = (value) => {
console.log('progress:', value);
};
const end = () => {
console.log('end');
remover.removeListener('progress', progress);
remover.removeListener('end', end);
};
const error = (data) => {
const msg = data + '\n Continue?';
const is = confirm(msg);
if (is)
return remover.continue();
remover.abort();
};
remover(from, names);
remover.on('progress', progress);
remover.on('end', end);
remover.on('error', error);
});
const remedy = require('remedy');
const http = require('http');
const express = require('express');
const io = require('socket.io');
const app = express();
const port = 1337;
const server = http.createServer(app);
const socket = io.listen(server);
server.listen(port);
app.use(remedy({
online: true,
authCheck: function(socket, success) {
}
});
remedy.listen(socket, {
prefix: '/remedy', /* default */
root: '/', /* string or function */
});
MIT