Get linting passing again
This commit is contained in:
parent
4f95f27400
commit
494f66d388
21 changed files with 367 additions and 212 deletions
|
@ -9,15 +9,15 @@ export function formatDate(timestamp) {
|
|||
|
||||
export function formatSize(size) {
|
||||
if (size >= 1073741824) {
|
||||
return Math.round((size / 1073741824) * 10) / 10 + 'GB';
|
||||
return `${Math.round((size / 1073741824) * 10) / 10}GB`;
|
||||
}
|
||||
if (size >= 1048576) {
|
||||
return Math.round((size / 1048576) * 10) / 10 + 'MB';
|
||||
return `${Math.round((size / 1048576) * 10) / 10}MB`;
|
||||
}
|
||||
if (size >= 1024) {
|
||||
return Math.round((size / 1024) * 10) / 10 + 'KB';
|
||||
return `${Math.round((size / 1024) * 10) / 10}KB`;
|
||||
}
|
||||
return Math.round(size) + 'B';
|
||||
return `${Math.round(size)}B`;
|
||||
}
|
||||
|
||||
export function formatFile(file) {
|
||||
|
@ -25,8 +25,8 @@ export function formatFile(file) {
|
|||
added: moment.unix(file.time_added).format(),
|
||||
readableAdded: formatDate(file.time_added),
|
||||
downloads: file.downloads !== undefined ? file.downloads : 0,
|
||||
href: baseURL + '/' + file._id, // eslint-disable-line no-underscore-dangle
|
||||
id: file._id, // eslint-disable-line no-underscore-dangle
|
||||
href: `${baseURL}/${file._id}`,
|
||||
id: file._id,
|
||||
name: file.file_name,
|
||||
size: file.file_size,
|
||||
readableSize: formatSize(file.file_size),
|
||||
|
@ -40,8 +40,8 @@ export function formatFile(file) {
|
|||
formattedFile.width = file.width;
|
||||
const ext = (file.file_name.split('.').pop().toLowerCase() === 'psd' ? '.png' : '');
|
||||
formattedFile.direct = {
|
||||
'150x': baseURL + '/file/150/' + file._id + '/' + file.file_name + ext, // eslint-disable-line no-underscore-dangle
|
||||
'970x': baseURL + '/file/970/' + file._id + '/' + file.file_name + ext, // eslint-disable-line no-underscore-dangle
|
||||
'150x': `${baseURL}/file/150/${file._id}/${file.file_name}${ext}`,
|
||||
'970x': `${baseURL}/file/970/${file._id}/${file.file_name}${ext}`,
|
||||
};
|
||||
}
|
||||
return formattedFile;
|
||||
|
|
|
@ -1,10 +1,63 @@
|
|||
import virustotal from './virustotal';
|
||||
|
||||
const extensions = ['EXE', 'PIF', 'APPLICATION', 'GADGET', 'MSI', 'MSP', 'COM', 'SCR', 'HTA', 'CPL', 'MSC',
|
||||
'JAR', 'BAT', 'CMD', 'VB', 'VBS', 'VBE', 'JS', 'JSE', 'WS', 'WSF', 'WSC', 'WSH', 'PS1', 'PS1XML', 'PS2',
|
||||
'PS2XML', 'PSC1', 'PSC2', 'MSH', 'MSH1', 'MSH2', 'MSHXML', 'MSH1XML', 'MSH2XML', 'SCF', 'LNK', 'INF', 'REG',
|
||||
'PDF', 'DOC', 'XLS', 'PPT', 'DOCM', 'DOTM', 'XLSM', 'XLTM', 'XLAM', 'PPTM', 'POTM', 'PPAM', 'PPSM', 'SLDM',
|
||||
'RAR', 'TAR', 'ZIP', 'GZ',
|
||||
const extensions = [
|
||||
'EXE',
|
||||
'PIF',
|
||||
'APPLICATION',
|
||||
'GADGET',
|
||||
'MSI',
|
||||
'MSP',
|
||||
'COM',
|
||||
'SCR',
|
||||
'HTA',
|
||||
'CPL',
|
||||
'MSC',
|
||||
'JAR',
|
||||
'BAT',
|
||||
'CMD',
|
||||
'VB',
|
||||
'VBS',
|
||||
'VBE',
|
||||
'JS',
|
||||
'JSE',
|
||||
'WS',
|
||||
'WSF',
|
||||
'WSC',
|
||||
'WSH',
|
||||
'PS1',
|
||||
'PS1XML',
|
||||
'PS2',
|
||||
'PS2XML',
|
||||
'PSC1',
|
||||
'PSC2',
|
||||
'MSH',
|
||||
'MSH1',
|
||||
'MSH2',
|
||||
'MSHXML',
|
||||
'MSH1XML',
|
||||
'MSH2XML',
|
||||
'SCF',
|
||||
'LNK',
|
||||
'INF',
|
||||
'REG',
|
||||
'PDF',
|
||||
'DOC',
|
||||
'XLS',
|
||||
'PPT',
|
||||
'DOCM',
|
||||
'DOTM',
|
||||
'XLSM',
|
||||
'XLTM',
|
||||
'XLAM',
|
||||
'PPTM',
|
||||
'POTM',
|
||||
'PPAM',
|
||||
'PPSM',
|
||||
'SLDM',
|
||||
'RAR',
|
||||
'TAR',
|
||||
'ZIP',
|
||||
'GZ',
|
||||
];
|
||||
|
||||
function getExtension(filename) {
|
||||
|
@ -19,6 +72,6 @@ export default function* (file) {
|
|||
const result = yield virustotal.getFileReport(file.md5);
|
||||
return {
|
||||
positive: result.positives >= 5,
|
||||
result: result,
|
||||
result,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ const MongoClient = mongodb().MongoClient;
|
|||
import debugname from 'debug';
|
||||
const debug = debugname('hostr:mongo');
|
||||
|
||||
/* eslint no-param-reassign: ["error", { "props": false }] */
|
||||
const configuredClient = new Promise((resolve, reject) => {
|
||||
debug('Connecting to Mongodb');
|
||||
return MongoClient.connect(process.env.MONGO_URL).then((client) => {
|
||||
|
@ -13,8 +14,8 @@ const configuredClient = new Promise((resolve, reject) => {
|
|||
client.Logins = client.collection('logins');
|
||||
client.Remember = client.collection('remember');
|
||||
client.Reset = client.collection('reset');
|
||||
client.Remember.ensureIndex({'created': 1}, {expireAfterSeconds: 2592000});
|
||||
client.Files.ensureIndex({'owner': 1, 'status': 1, 'time_added': -1});
|
||||
client.Remember.ensureIndex({ created: 1 }, { expireAfterSeconds: 2592000 });
|
||||
client.Files.ensureIndex({ owner: 1, status: 1, time_added: -1 });
|
||||
client.ObjectId = client.objectId = mongodb().ObjectId;
|
||||
return resolve(client);
|
||||
}).catch((e) => {
|
||||
|
@ -24,7 +25,7 @@ const configuredClient = new Promise((resolve, reject) => {
|
|||
debug(e);
|
||||
});
|
||||
|
||||
export default function() {
|
||||
export default function mongo() {
|
||||
return function* dbMiddleware(next) {
|
||||
try {
|
||||
this.db = yield configuredClient;
|
||||
|
|
24
lib/redis.js
24
lib/redis.js
|
@ -11,25 +11,25 @@ const connection = new Promise((resolve, reject) => {
|
|||
client.on('error', reject);
|
||||
resolve(client);
|
||||
}).catch((err) => {
|
||||
debug('Connection error: ' + err);
|
||||
debug('Connection error: ', err);
|
||||
throw err;
|
||||
});
|
||||
|
||||
const redisSession = new Promise((resolve, reject) => {
|
||||
return connection.then((client) => {
|
||||
const sessionClient = koaRedis({client: client});
|
||||
const redisSession = new Promise((resolve, reject) =>
|
||||
connection.then((client) => {
|
||||
const sessionClient = koaRedis({ client });
|
||||
resolve(session({
|
||||
key: 'hid',
|
||||
store: sessionClient,
|
||||
}));
|
||||
}).catch((err) => {
|
||||
debug('koa-redis error: ' + err);
|
||||
debug('koa-redis error: ', err);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
const wrapped = new Promise((resolve, reject) => {
|
||||
return connection.then((client) => {
|
||||
const wrapped = new Promise((resolve, reject) =>
|
||||
connection.then((client) => {
|
||||
const asyncClient = coRedis(client);
|
||||
asyncClient.on('error', reject);
|
||||
asyncClient.on('ready', () => {
|
||||
|
@ -37,11 +37,11 @@ const wrapped = new Promise((resolve, reject) => {
|
|||
resolve(asyncClient);
|
||||
});
|
||||
}).catch((err) => {
|
||||
debug('co-redis error: ' + err);
|
||||
debug('co-redis error: ', err);
|
||||
reject(err);
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
export function sessionStore() {
|
||||
return function* sessionStoreMiddleware(next) {
|
||||
|
|
|
@ -63,7 +63,7 @@ export default function resize(path, type, currentSize, newSize) {
|
|||
return cover(path, type, newSize);
|
||||
} else if (newSize.width > 970 && ratio > 1) {
|
||||
debug('Scale');
|
||||
newSize.height = currentSize.height * ratio;
|
||||
newSize.height = currentSize.height * ratio; // eslint-disable-line no-param-reassign
|
||||
return scale(path, type, newSize);
|
||||
}
|
||||
debug('Copy');
|
||||
|
|
50
lib/type.js
50
lib/type.js
|
@ -1,29 +1,29 @@
|
|||
const extensions = {
|
||||
'jpg': 'image',
|
||||
'jpeg': 'image',
|
||||
'png': 'image',
|
||||
'gif': 'image',
|
||||
'bmp': 'image',
|
||||
'tiff': 'image',
|
||||
'psd': 'image',
|
||||
'mp3': 'audio',
|
||||
'm4a': 'audio',
|
||||
'ogg': 'audio',
|
||||
'flac': 'audio',
|
||||
'aac': 'audio',
|
||||
'mpg': 'video',
|
||||
'mkv': 'video',
|
||||
'avi': 'video',
|
||||
'divx': 'video',
|
||||
'mpeg': 'video',
|
||||
'flv': 'video',
|
||||
'mp4': 'video',
|
||||
'mov': 'video',
|
||||
'zip': 'archive',
|
||||
'gz': 'archive',
|
||||
'tgz': 'archive',
|
||||
'bz2': 'archive',
|
||||
'rar': 'archive',
|
||||
jpg: 'image',
|
||||
jpeg: 'image',
|
||||
png: 'image',
|
||||
gif: 'image',
|
||||
bmp: 'image',
|
||||
tiff: 'image',
|
||||
psd: 'image',
|
||||
mp3: 'audio',
|
||||
m4a: 'audio',
|
||||
ogg: 'audio',
|
||||
flac: 'audio',
|
||||
aac: 'audio',
|
||||
mpg: 'video',
|
||||
mkv: 'video',
|
||||
avi: 'video',
|
||||
divx: 'video',
|
||||
mpeg: 'video',
|
||||
flv: 'video',
|
||||
mp4: 'video',
|
||||
mov: 'video',
|
||||
zip: 'archive',
|
||||
gz: 'archive',
|
||||
tgz: 'archive',
|
||||
bz2: 'archive',
|
||||
rar: 'archive',
|
||||
};
|
||||
|
||||
export function sniff(filename) {
|
||||
|
|
|
@ -35,7 +35,6 @@ export default class Uploader {
|
|||
}
|
||||
|
||||
*accept() {
|
||||
yield this.checkLimit();
|
||||
this.upload = yield parse(this.context, {
|
||||
autoFields: true,
|
||||
headers: this.context.request.headers,
|
||||
|
|
|
@ -7,5 +7,5 @@ export function* getFileReport(resource, apiKey = process.env.VIRUSTOTAL_KEY) {
|
|||
const form = new FormData();
|
||||
form.append('apikey', apiKey);
|
||||
form.append('resource', resource);
|
||||
return yield fetch(`${apiRoot}/file/report`, { method: 'POST'});
|
||||
return yield fetch(`${apiRoot}/file/report`, { method: 'POST' });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue