refactored upload away from multipart forms to binary data

This commit is contained in:
Danny Coates 2018-05-31 14:06:25 -07:00
parent 196d4211b6
commit af7a262ef0
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
9 changed files with 56 additions and 93 deletions

20
server/limiter.js Normal file
View file

@ -0,0 +1,20 @@
const { Transform } = require('stream');
class Limiter extends Transform {
constructor(limit) {
super();
this.limit = limit;
this.length = 0;
}
_transform(chunk, encoding, callback) {
this.length += chunk.length;
this.push(chunk);
if (this.length > this.limit) {
return callback(new Error('limit'));
}
callback();
}
}
module.exports = Limiter;