more DeepSource fixes

pull/20/head
tycrek 4 years ago
parent f3e0f9c70d
commit 8a8b409a75
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -62,7 +62,7 @@ function preStartup() {
// Monitor auth.json for changes (triggered by running 'npm run new-token') // Monitor auth.json for changes (triggered by running 'npm run new-token')
fs.watch(path('auth.json'), { persistent: false }, (eventType) => eventType === 'change' && fs.readJson(path('auth.json')) fs.watch(path('auth.json'), { persistent: false }, (eventType) => eventType === 'change' && fs.readJson(path('auth.json'))
.then((json) => !(arrayEquals(Object.keys(users), Object.keys(json.users))) && (users = json.users) && log(`New token added: ${Object.keys(users)[Object.keys(users).length - 1]}`)) .then((json) => !(arrayEquals(Object.keys(users), Object.keys(json.users))) && (users = json.users) && log(`New token added: ${Object.keys(users)[Object.keys(users).length - 1]}`)) // skipcq: JS-0243
.catch(console.error)); .catch(console.error));
// Create thumbnails directory // Create thumbnails directory
@ -85,7 +85,7 @@ function startup() {
app.use((req, res, next) => req.url.includes('favicon.ico') ? res.sendStatus(204) : next()); app.use((req, res, next) => req.url.includes('favicon.ico') ? res.sendStatus(204) : next());
// Index // Index
app.get('/', (_req, res) => fs.readFile(path('README.md')).then((bytes) => bytes.toString()).then(marked).then((data) => res.render('index', { data }))); app.get('/', (_req, res) => fs.readFile(path('README.md')).then((bytes) => bytes.toString()).then(marked).then((d) => res.render('index', { data: d })));
// Block unauthorized requests and attempt token sanitization // Block unauthorized requests and attempt token sanitization
app.post('/', (req, res, next) => { app.post('/', (req, res, next) => {
@ -94,12 +94,12 @@ function startup() {
}); });
// Generate ID's to use for other functions // Generate ID's to use for other functions
app.post('/', (req, _res, next) => (req.randomId = generateId('random', 32, null, null), next())); // skipcq: JS-0086 app.post('/', (req, _res, next) => (req.randomId = generateId('random', 32, null, null), next())); // skipcq: JS-0086, JS-0090
app.post('/', (req, _res, next) => (req.deleteId = generateId('random', 32, null, null), next())); // skipcq: JS-0086 app.post('/', (req, _res, next) => (req.deleteId = generateId('random', 32, null, null), next())); // skipcq: JS-0086, JS-0090
// Upload file (local & S3) // skipcq: JS-0093 // Upload file (local & S3) // skipcq: JS-0093
s3enabled s3enabled
? app.post('/', (req, res, next) => uploadS3(req, res, (error) => ((error) && console.error(error), next()))) ? app.post('/', (req, res, next) => uploadS3(req, res, (error) => ((error) && console.error(error), next()))) // skipcq: JS-0090
: app.post('/', uploadLocal, ({ next }) => next()); : app.post('/', uploadLocal, ({ next }) => next());
// Pre-response operations // Pre-response operations

@ -78,7 +78,7 @@ if (require.main === module) {
type: 'string', type: 'string',
default: config.resourceIdType, default: config.resourceIdType,
require: false, require: false,
pattern: /(original|zws|random|gfycat)/gi, pattern: /(original|zws|random|gfycat)/gi, // skipcq: JS-0113
message: 'Must be one of: original, zws, random, gfycat' message: 'Must be one of: original, zws, random, gfycat'
}, },
gfyIdSize: { gfyIdSize: {

@ -50,7 +50,7 @@ const bucketSize = () =>
function listAllKeys(resolve, reject, token) { function listAllKeys(resolve, reject, token) {
let allKeys = []; let allKeys = [];
s3.listObjectsV2({ Bucket: s3bucket, ContinuationToken: token }).promise() s3.listObjectsV2({ Bucket: s3bucket, ContinuationToken: token }).promise()
.then((data) => (allKeys = allKeys.concat(data.Contents), data.IsTruncated ? listAllKeys(resolve, reject, data.NextContinuationToken) : resolve(allKeys.length))) // skipcq: JS-0086 .then((data) => (allKeys = allKeys.concat(data.Contents), data.IsTruncated ? listAllKeys(resolve, reject, data.NextContinuationToken) : resolve(allKeys.length))) // skipcq: JS-0086, JS-0090
.catch(reject); .catch(reject);
} }

Loading…
Cancel
Save