Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cloudcmd/node-spero
File copy emitter middleware based on socket.io and copymitter
https://github.com/cloudcmd/node-spero
cloudcmd copy emitter expressjs file folder middleware progress socket-io
Last synced: about 2 months ago
JSON representation
File copy emitter middleware based on socket.io and copymitter
- Host: GitHub
- URL: https://github.com/cloudcmd/node-spero
- Owner: cloudcmd
- License: mit
- Created: 2015-05-26T13:15:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T16:29:46.000Z (over 6 years ago)
- Last Synced: 2024-04-23T16:09:48.949Z (9 months ago)
- Topics: cloudcmd, copy, emitter, expressjs, file, folder, middleware, progress, socket-io
- Language: JavaScript
- Homepage:
- Size: 111 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE
Awesome Lists containing this project
README
# Spero [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL]
File copy emitter middleware based on [socket.io](http://socket.io "Socket.io") and [copymitter](https://github.com/coderaiser/node-copymitter "Copymitter").
## Install
```
npm i spero --save
```## Client
Could be loaded from url `/spero/spero.js`.
```js
const prefix = '/spero';/* could be one argument: callback */
spero(prefix, function(copier) {
const from = '/';
const to = '/tmp';
const names = [
'bin'
];
const progress = (value) => {
console.log('progress:', value);
};
const end = () => {
console.log('end');
copier.removeListener('progress', progress);
copier.removeListener('end', end);
};
const error = (data) => {
const msg = data + '\n Continue?';
const is = confirm(msg);
if (is)
return copier.continue();
copier.abort();
};
copier(from, to, names);
copier.on('progress', progress);
copier.on('end', end);
copier.on('error', error);
});
```## Server
```js
const spero = require('spero');
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(spero({
online: true,
authCheck: function(socket, success) {
}
});spero.listen(socket, {
prefix: '/spero', /* default */
root: '/', /* string or function */
});
```## Environments
In old `node.js` environments that supports `es5` only, `dword` could be used with:
```js
var spero = require('spero/legacy');
```## License
MIT
[NPMIMGURL]: https://img.shields.io/npm/v/spero.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/node-spero/master.svg?style=flat
[NPMURL]: https://npmjs.org/package/spero "npm"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[BuildStatusURL]: https://travis-ci.org/coderaiser/node-spero "Build Status"