fix: Switch converted to Object Literal (#940)
* updating a switch into object literal and fixed a couple linter errors * added a comment about weird formatting * style: use lodash get * fix: pass eslint + puglint + jest
This commit is contained in:
committed by
Nicolas Giard
parent
2142b5f674
commit
0f9ddf1e5d
@@ -12,8 +12,8 @@ const bruteforce = new ExpressBrute(new BruteKnex({
|
||||
knex: WIKI.models.knex
|
||||
}), {
|
||||
freeRetries: 5,
|
||||
minWait: 5*60*1000, // 5 minutes
|
||||
maxWait: 60*60*1000, // 1 hour
|
||||
minWait: 5 * 60 * 1000, // 5 minutes
|
||||
maxWait: 60 * 60 * 1000, // 1 hour
|
||||
failCallback: (req, res, next) => {
|
||||
res.status(401).send('Too many failed attempts. Try again later.')
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* global WIKI */
|
||||
|
||||
exports.up = knex => {
|
||||
const dbCompat = {
|
||||
blobLength: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* global WIKI */
|
||||
|
||||
exports.up = knex => {
|
||||
const dbCompat = {
|
||||
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* global WIKI */
|
||||
|
||||
exports.up = knex => {
|
||||
const dbCompat = {
|
||||
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
||||
|
||||
@@ -20,10 +20,10 @@ module.exports = {
|
||||
},
|
||||
|
||||
getMigrationName(migration) {
|
||||
return migration.file;
|
||||
return migration.file
|
||||
},
|
||||
|
||||
getMigration(migration) {
|
||||
return require(path.join(baseMigrationPath, migration.file));
|
||||
return require(path.join(baseMigrationPath, migration.file))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
// Query: {
|
||||
// comments(obj, args, context, info) {
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
// Query: {
|
||||
// folders(obj, args, context, info) {
|
||||
|
||||
@@ -74,7 +74,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
async update(obj, args) {
|
||||
if(_.some(args.pageRules, pr => {
|
||||
if (_.some(args.pageRules, pr => {
|
||||
return pr.match === 'REGEX' && !safeRegex(pr.path)
|
||||
})) {
|
||||
throw new gql.GraphQLError('Some Page Rules contains unsafe or exponential time regex.')
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = {
|
||||
return {
|
||||
responseResult: graphHelper.generateSuccess('Telemetry state updated successfully')
|
||||
}
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
return graphHelper.generateError(err)
|
||||
}
|
||||
},
|
||||
@@ -63,7 +63,7 @@ module.exports = {
|
||||
return {
|
||||
responseResult: graphHelper.generateSuccess('Telemetry Client ID has been reset successfully')
|
||||
}
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
return graphHelper.generateError(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
const gql = require('graphql')
|
||||
|
||||
module.exports = {
|
||||
// Query: {
|
||||
// tags(obj, args, context, info) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const crypto = require('crypto')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Generate unique hash from page
|
||||
|
||||
@@ -66,14 +66,11 @@ module.exports = {
|
||||
['date', page.updatedAt],
|
||||
['tags', '']
|
||||
]
|
||||
switch (page.contentType) {
|
||||
case 'markdown':
|
||||
return '---\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n---\n\n' + page.content
|
||||
case 'html':
|
||||
return '<!--\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n-->\n\n' + page.content
|
||||
default:
|
||||
return page.content
|
||||
const inject = {
|
||||
'markdown': '---\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n---\n\n' + page.content,
|
||||
'html': '<!--\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n-->\n\n' + page.content
|
||||
}
|
||||
return _.get(inject, page.contentType, page.content)
|
||||
},
|
||||
/**
|
||||
* Check if path is a reserved path
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const { graphqlUploadExpress } = require('graphql-upload')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
/**
|
||||
* GraphQL File Upload Middleware
|
||||
*/
|
||||
|
||||
@@ -138,6 +138,5 @@ module.exports = class Analytics extends Model {
|
||||
bodyEnd: ''
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// ------------------------------------
|
||||
|
||||
const DiscordStrategy = require('passport-discord').Strategy
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = {
|
||||
init (passport, conf) {
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = {
|
||||
githubConfig.authorizationURL = `https://${conf.enterpriseDomain}/login/oauth/authorize`
|
||||
githubConfig.tokenURL = `https://${conf.enterpriseDomain}/login/oauth/access_token`
|
||||
githubConfig.userProfileURL = conf.enterpriseUserEndpoint
|
||||
githubConfig.userEmailURL = `${conf.enterpriseUserEndpoint}/emails`
|
||||
githubConfig.userEmailURL = `${conf.enterpriseUserEndpoint}/emails`
|
||||
}
|
||||
|
||||
passport.use('github',
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const fs = require('fs-extra')
|
||||
const _ = require('lodash')
|
||||
const path = require('path')
|
||||
const tar = require('tar-fs')
|
||||
const zlib = require('zlib')
|
||||
|
||||
43
server/test/helpers/page.test.js
Normal file
43
server/test/helpers/page.test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const { injectPageMetadata } = require('../../helpers/page')
|
||||
|
||||
describe('injectPageMetadata tests', () => {
|
||||
let page = {
|
||||
title: 'PAGE TITLE',
|
||||
description: 'A PAGE',
|
||||
isPublished: true,
|
||||
updatedAt: new Date(),
|
||||
content: 'TEST CONTENT'
|
||||
}
|
||||
test('injectPageMetadata: default', () => {
|
||||
const expected = 'TEST CONTENT'
|
||||
const result = injectPageMetadata(page)
|
||||
expect(result).toEqual(expected)
|
||||
})
|
||||
test('injectPageMetadata: markdown', () => {
|
||||
page.contentType = 'markdown'
|
||||
const expected = `---
|
||||
title: ${page.title}
|
||||
description: ${page.description}
|
||||
published: ${page.isPublished.toString()}
|
||||
date: ${page.updatedAt}
|
||||
tags: \n---
|
||||
|
||||
TEST CONTENT`
|
||||
const result = injectPageMetadata(page)
|
||||
expect(result).toEqual(expected)
|
||||
})
|
||||
|
||||
test('injectPageMetadata: hmtl', () => {
|
||||
page.contentType = 'html'
|
||||
const expected = `<!--
|
||||
title: ${page.title}
|
||||
description: ${page.description}
|
||||
published: ${page.isPublished.toString()}
|
||||
date: ${page.updatedAt}
|
||||
tags: \n-->
|
||||
|
||||
TEST CONTENT`
|
||||
const result = injectPageMetadata(page)
|
||||
expect(result).toEqual(expected)
|
||||
})
|
||||
})
|
||||
@@ -9,7 +9,7 @@ block body
|
||||
v-layout(row)
|
||||
v-flex(xs10)
|
||||
a(href='/'): img(src='/svg/logo-wikijs.svg')
|
||||
v-flex(xs2).text-xs-right
|
||||
v-flex.text-right(xs2)
|
||||
v-btn(href='/', depressed, color='red darken-3')
|
||||
v-icon(left) home
|
||||
span Home
|
||||
|
||||
Reference in New Issue
Block a user