some weird old code cleanup that was left hanging, /shrug

This commit is contained in:
Evert Prants 2021-02-09 18:46:04 +02:00
parent 08c196684b
commit c7ce387685
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
14 changed files with 1582 additions and 1467 deletions

36
.eslintrc.js Normal file
View File

@ -0,0 +1,36 @@
module.exports = {
'env': {
'browser': true,
'es2021': true,
'node': true
},
'extends': [
'eslint:recommended',
'plugin:vue/essential'
],
'parserOptions': {
'ecmaVersion': 12,
'sourceType': 'module'
},
'plugins': [
'vue'
],
'rules': {
'indent': [
'error',
2
],
'linebreak-style': [
'error',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'never'
]
}
}

2842
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -30,27 +30,28 @@
},
"homepage": "https://icynet.eu",
"dependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
"@babel/register": "^7.12.10",
"@babel/plugin-transform-modules-commonjs": "^7.12.13",
"@babel/register": "^7.12.13",
"bcryptjs": "^2.4.3",
"bluebird": "^3.7.2",
"body-parser": "^1.19.0",
"connect-redis": "^5.0.0",
"connect-redis": "^5.1.0",
"connect-session-knex": "^2.0.0",
"email-templates": "^8.0.2",
"email-templates": "^8.0.3",
"express": "^4.17.1",
"express-rate-limit": "^5.2.3",
"express-rate-limit": "^5.2.5",
"express-session": "^1.17.1",
"feed": "^4.2.1",
"fs-extra": "^9.0.1",
"feed": "^4.2.2",
"fs-extra": "^9.1.0",
"gm": "^1.23.1",
"knex": "^0.21.13",
"json-web-token": "^3.2.0",
"knex": "^0.21.17",
"multiparty": "^4.2.2",
"mysql": "^2.18.1",
"nodemailer": "^6.4.17",
"notp": "^2.0.3",
"oauth-libre": "^0.9.17",
"objection": "^2.2.3",
"objection": "^2.2.14",
"querystring-es3": "^0.2.1",
"redis": "^3.0.2",
"serve-favicon": "^2.5.0",
@ -61,12 +62,14 @@
"vue": "^2.6.12"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.10",
"@babel/core": "^7.12.13",
"@babel/preset-env": "^7.12.13",
"babel-loader": "^8.2.2",
"bootstrap": "^4.5.3",
"bootstrap": "^4.6.0",
"concurrently": "^5.3.0",
"eslint": "^7.19.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-vue": "^7.5.0",
"jquery": "^3.5.1",
"morgan": "^1.10.0",
"mustache": "^4.1.0",
@ -74,16 +77,16 @@
"pug": "^3.0.0",
"pug-plain-loader": "^1.1.0",
"standard": "^16.0.3",
"terser-webpack-plugin": "^5.0.3",
"terser-webpack-plugin": "^5.1.1",
"vue-clickaway": "^2.2.2",
"vue-loader": "^15.9.5",
"vue-loader": "^15.9.6",
"vue-resource": "^1.5.1",
"vue-router": "^3.4.9",
"vue-router": "^3.5.1",
"vue-template-compiler": "^2.6.12",
"watch": "^1.0.2",
"webpack": "^5.10.1",
"webpack-cli": "^4.2.0",
"webpack-merge": "^5.7.0"
"webpack": "^5.21.2",
"webpack-cli": "^4.5.0",
"webpack-merge": "^5.7.3"
},
"standard": {
"env": {

View File

@ -96,7 +96,7 @@ export function Hash (len) {
return crypto.randomBytes(len).toString('hex')
}
/* ppp - Posts Per Page; dcount - Post Count; page - number of current page */
/* ppp - Posts Per Page; dcount - Post Count; page - number of current page */
export function Pagination (ppp, dcount, page) {
if (!ppp) ppp = 5
if (!dcount) return null
@ -545,7 +545,7 @@ export class User {
}
}
export class Paymen {
export class Payment {
static async handleIPN (body) {
const sandboxed = body.test_ipn === '1'
const url = 'https://ipnpb.' + (sandboxed ? 'sandbox.' : '') + 'paypal.com/cgi-bin/webscr'

View File

@ -12,7 +12,7 @@ function slugify (title) {
return title.toLowerCase().replace(/\W/g, '-').substring(0, 32)
}
async function cleanArticle (entry, shortenContent = false) {
async function cleanArticle (entry) {
const poster = await User.get(entry.user_id)
const article = {
id: entry.id,

View File

@ -4,13 +4,14 @@ import {
InvalidClient,
UnauthorizedClient,
InvalidScope,
AccessDenied
AccessDenied,
Forbidden
} from '../error'
import { data as dataResponse } from '../response'
import * as model from '../model'
import wrap from '../wrap'
export const authorization = wrap(async (req, res, next) => {
export const authorization = wrap(async (req, res) => {
let clientId = null
let redirectUri = null
let responseType = null

View File

@ -1,3 +1,3 @@
export function decision (req, res, client, scope, user) {
export function decision (req, res, client, scope) {
res.render('authorization', { client: client, scope: scope })
}

View File

@ -1,3 +1,3 @@
export * from './authorization';
export * from './introspection';
export * from './token';
export * from './authorization'
export * from './introspection'
export * from './token'

View File

@ -1,5 +1,10 @@
import * as tokens from './tokens'
import { InvalidRequest, InvalidClient, UnauthorizedClient } from '../error'
import {
InvalidRequest,
InvalidClient,
UnauthorizedClient,
UnsupportedGrantType
} from '../error'
import { data as dataResponse, error as errorResponse } from '../response'
import wrap from '../wrap'
@ -76,7 +81,7 @@ export const token = wrap(async (req, res) => {
evt = await tokens.refreshToken(req.oauth2, client, req.body.refresh_token, req.body.scope)
break
default:
throw new error.UnsupportedGrantType('Grant type does not match any supported type')
throw new UnsupportedGrantType('Grant type does not match any supported type')
}
if (evt) {

View File

@ -1,6 +1,6 @@
import { InvalidRequest, ServerError, InvalidGrant } from '../../error'
export async function authorizationCode (oauth2, client, providedCode, redirectUri) {
export async function authorizationCode (oauth2, client, providedCode) {
const respObj = {
token_type: 'bearer'
}

View File

@ -1,6 +1,6 @@
import { InvalidRequest, ServerError, InvalidGrant, InvalidClient } from '../../error'
export async function refreshToken (oauth2, client, pRefreshToken, scope) {
export async function refreshToken (oauth2, client, pRefreshToken) {
let user = null
let ttl = null
let refreshToken = null

View File

@ -130,7 +130,7 @@ export const client = {
export const code = {
ttl: config.oauth2.code_life,
create: async (userId, clientId, scope, ttl, special = false) => {
create: async (userId, clientId, scope, ttl) => {
const newCode = crypto.randomBytes(config.oauth2.token_length).toString('hex')
const expr = new Date(Date.now() + ttl * 1000)

View File

@ -304,7 +304,7 @@ apiRouter.post('/email', csrfVerify, wrap(async (req, res) => {
res.jsonp(result)
}))
apiRouter.use((err, req, res, next) => {
apiRouter.use((err, req, res) => {
console.error(err)
return res.status(400).jsonp({ error: err.message })
})

View File

@ -438,7 +438,7 @@ router.post('/avatar/gravatar', wrap(async (req, res, next) => {
req.flash('message', { error: false, text: 'Success!' })
} catch (e) {
console.error(e);
console.error(e)
req.flash('message', { error: true, text: 'Failed to use gravatar avatar.' })
}
@ -500,7 +500,7 @@ router.get('/donations/user', wrap(async (req, res, next) => {
res.jsonp(contribs)
}))
router.get('/donations', wrap(async (req, res, next) => {
router.get('/donations', wrap(async (req, res) => {
let count = parseInt(req.query.count)
if (isNaN(count)) {
count = 10
@ -523,7 +523,7 @@ router.use((req, res) => {
res.status(404).jsonp({ error: 'Not found' })
})
router.use((err, req, res, next) => {
router.use((err, req, res) => {
console.error(err)
res.jsonp({ error: 'Internal server error.' })
})