mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-04-25 04:09:12 +00:00
chore: loads of lgtm maintainability fixes
This commit is contained in:
parent
0b918d9ffa
commit
eb6dce5277
13 changed files with 44 additions and 98 deletions
|
@ -39,7 +39,6 @@ module.exports = (R, $) => {
|
|||
})
|
||||
|
||||
R.get('/api/server/:id/slug', async ctx => {
|
||||
const { userId } = ctx.session
|
||||
const { id } = ctx.params
|
||||
|
||||
const srv = $.discord.client.guilds.get(id)
|
||||
|
|
|
@ -53,10 +53,6 @@ async function start() {
|
|||
const pub = path.resolve(path.join(__dirname, 'public'))
|
||||
log.info('public path', pub)
|
||||
|
||||
const staticFiles = require('koa-static')
|
||||
// app.use(staticFiles(pub, { defer: true, gzip: true, br: true }))
|
||||
|
||||
const send = require('koa-send')
|
||||
app.use(async (ctx, next) => {
|
||||
if (ctx.path.startsWith('/api')) {
|
||||
log.info('api breakout')
|
||||
|
@ -85,40 +81,15 @@ async function start() {
|
|||
try {
|
||||
ctx.body = fs.readFileSync(path.join(pub, 'index.html'), { encoding: 'utf-8' })
|
||||
} catch (e) {
|
||||
ctx.body = e.stack || e.trace
|
||||
ctx.body = "A problem occured."
|
||||
ctx.status = 500
|
||||
console.error(e)
|
||||
}
|
||||
log.info('index sent')
|
||||
ctx.status = 200
|
||||
return next()
|
||||
}
|
||||
|
||||
// try {
|
||||
// await next()
|
||||
// } catch (e) {
|
||||
// send(ctx, 'index.html', { root: pub })
|
||||
// }
|
||||
})
|
||||
// const sendOpts = {root: pub, index: 'index.html'}
|
||||
// // const sendOpts = {}
|
||||
// app.use(async (ctx, next) => {
|
||||
// if (ctx.path.startsWith('/api')) {
|
||||
// return await next()
|
||||
// }
|
||||
|
||||
// try {
|
||||
// log.info('pass 1', ctx.path, __dirname+'/public'+ctx.path)
|
||||
// await send(ctx, __dirname+'/public'+ctx.path, sendOpts)
|
||||
// } catch (error) {
|
||||
// try {
|
||||
// log.info('pass 2 /', ctx.path, __dirname+'/public/index.html')
|
||||
// await send(ctx, __dirname+'/public/index.html', sendOpts)
|
||||
// } catch (error) {
|
||||
// log.info('exit to next', ctx.path)
|
||||
// await next()
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
// Request logger
|
||||
|
@ -129,20 +100,21 @@ async function start() {
|
|||
} catch (e) {
|
||||
log.error(e)
|
||||
ctx.status = ctx.status || 500
|
||||
|
||||
if (DEVEL) {
|
||||
ctx.body = ctx.body || e.stack
|
||||
} else {
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
ctx.body = {
|
||||
err: 'something terrible happened.',
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
let timeElapsed = new Date() - timeStart
|
||||
|
||||
log.request(
|
||||
`${ctx.status} ${ctx.method} ${ctx.url} - ${ctx.ip} - took ${timeElapsed}ms`
|
||||
)
|
||||
// return null
|
||||
})
|
||||
|
||||
const session = require('koa-session')
|
||||
|
@ -164,7 +136,6 @@ async function start() {
|
|||
await M.mountRoutes()
|
||||
|
||||
// SPA server
|
||||
|
||||
log.info(`starting HTTP server on ${process.env.APP_PORT || 6769}`)
|
||||
server.listen(process.env.APP_PORT || 6769)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const log = new (require('../logger'))('models/index')
|
||||
const glob = require('glob')
|
||||
const path = require('path')
|
||||
const util = require('../util/model-methods')
|
||||
|
||||
module.exports = sql => {
|
||||
const models = {}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import React, { Component } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import TypingDemo from '../demos/typing'
|
||||
import RoleypolyDemo from '../demos/roleypoly'
|
||||
import * as Actions from '../../actions'
|
||||
import './styles.sass'
|
||||
import discordLogo from '../../pages/images/discord-logo.svg'
|
||||
import RoleypolyDemo from '../demos/roleypoly'
|
||||
import TypingDemo from '../demos/typing'
|
||||
import './styles.sass'
|
||||
|
||||
export default class AddServer extends Component {
|
||||
polling = null
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import React, { Component } from 'react'
|
||||
import { Redirect } from 'react-router-dom'
|
||||
import superagent from 'superagent'
|
||||
import { connect } from 'react-redux'
|
||||
import { push } from 'react-router-redux'
|
||||
import { fetchServers } from '../../actions'
|
||||
import superagent from 'superagent'
|
||||
|
||||
@connect()
|
||||
class OauthCallback extends Component {
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
import React, { Component } from 'react'
|
||||
import { Set } from 'immutable'
|
||||
import { connect } from 'react-redux'
|
||||
import { DropTarget } from 'react-dnd'
|
||||
import { Link, Prompt, Redirect } from 'react-router-dom'
|
||||
import React, { Component } from 'react'
|
||||
import { Scrollbars } from 'react-custom-scrollbars'
|
||||
import * as Actions from './actions'
|
||||
import * as PickerActions from '../role-picker/actions'
|
||||
import { DropTarget } from 'react-dnd'
|
||||
import { connect } from 'react-redux'
|
||||
import { Link, Prompt, Redirect } from 'react-router-dom'
|
||||
import * as UIActions from '../../actions/ui'
|
||||
import './RoleEditor.sass'
|
||||
|
||||
import Category from './Category'
|
||||
import CategoryEditor from './CategoryEditor'
|
||||
import Role from '../role/draggable'
|
||||
import * as Actions from './actions'
|
||||
import Category from './Category'
|
||||
import './RoleEditor.sass'
|
||||
|
||||
const mapState = ({ rolePicker, roleEditor, servers }, ownProps) => ({
|
||||
rp: rolePicker,
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
import React, { Component, Fragment } from 'react'
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { Prompt } from 'react-router-dom'
|
||||
import superagent from 'superagent'
|
||||
import * as Actions from './actions'
|
||||
import { Link, Prompt } from 'react-router-dom'
|
||||
import * as UIActions from '../../actions/ui'
|
||||
import { msgToReal } from '../../utils'
|
||||
import './RolePicker.sass'
|
||||
|
||||
import * as Actions from './actions'
|
||||
import Category from './Category'
|
||||
import { Scrollbars } from 'react-custom-scrollbars'
|
||||
import { Link } from 'react-router-dom'
|
||||
import './RolePicker.sass'
|
||||
|
||||
const mapState = ({ rolePicker, servers }, ownProps) => {
|
||||
return {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes'
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import './ServerCard.sass'
|
||||
import { withRouter } from 'react-router'
|
||||
|
||||
class ServerCard extends Component {
|
||||
static propTypes = {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import React, { Component } from 'react'
|
||||
import { Route, Switch } from 'react-router-dom'
|
||||
import { Scrollbars } from 'react-custom-scrollbars'
|
||||
import { connect } from 'react-redux'
|
||||
import { withRouter, Redirect } from 'react-router'
|
||||
import './index.sass'
|
||||
|
||||
import Navigation from './Navigation'
|
||||
import RolePicker from '../role-picker'
|
||||
import RoleEditor from '../role-editor'
|
||||
import AddServer from '../add-server'
|
||||
import { Redirect } from 'react-router'
|
||||
import { Route, Switch } from 'react-router-dom'
|
||||
import Error404 from '../../pages/Error404'
|
||||
import AddServer from '../add-server'
|
||||
import RoleEditor from '../role-editor'
|
||||
import RolePicker from '../role-picker'
|
||||
import './index.sass'
|
||||
import Navigation from './Navigation'
|
||||
|
||||
// import mockData from './mockData'
|
||||
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
import React, { Component, Fragment } from 'react'
|
||||
import React from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import Scrollbars from 'react-custom-scrollbars'
|
||||
import Typist from 'react-typist'
|
||||
import moment from 'moment'
|
||||
import './landing.sass'
|
||||
import discordLogo from './images/discord-logo.svg'
|
||||
import RoleypolyDemo from '../components/demos/roleypoly'
|
||||
import TypingDemo from '../components/demos/typing'
|
||||
import discordLogo from './images/discord-logo.svg'
|
||||
import './landing.sass'
|
||||
|
||||
const Landing = ({ root = false }) => (
|
||||
<div className="landing uk-width-1-1 uk-text-center">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Map, OrderedMap, fromJS } from 'immutable'
|
||||
import { Map, OrderedMap } from 'immutable'
|
||||
|
||||
const initialState = Map({
|
||||
viewMap: OrderedMap({}),
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
import React, { Component, Fragment } from 'react'
|
||||
import { Route, Switch, Redirect } from 'react-router-dom'
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { withRouter } from 'react-router'
|
||||
|
||||
import Servers from '../components/servers'
|
||||
import { Redirect, Route, Switch } from 'react-router-dom'
|
||||
import OauthBotFlow from '../components/oauth-bot-flow'
|
||||
import OauthCallback from '../components/oauth-callback'
|
||||
import OauthFlow from '../components/oauth-flow'
|
||||
import OauthBotFlow from '../components/oauth-bot-flow'
|
||||
import Pages, { Landing, Error404 } from '../pages'
|
||||
import Servers from '../components/servers'
|
||||
import ServerLanding from '../components/servers/ServerLanding'
|
||||
|
||||
const aaa = props => <div>{JSON.stringify(props)}</div>
|
||||
import Pages, { Error404, Landing } from '../pages'
|
||||
|
||||
export default
|
||||
@withRouter
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import { createStore, applyMiddleware, compose } from 'redux'
|
||||
import thunk from 'redux-thunk'
|
||||
import { createLogger } from 'redux-logger'
|
||||
// import api from '../middleware/api'
|
||||
import rootReducer from '../reducers'
|
||||
import DevTools from '../components/dev-tools'
|
||||
import { routerMiddleware } from 'react-router-redux'
|
||||
import { applyMiddleware, compose, createStore } from 'redux'
|
||||
import { createLogger } from 'redux-logger'
|
||||
import thunk from 'redux-thunk'
|
||||
import rootReducer from '../reducers'
|
||||
|
||||
const configureStore = (preloadedState, history) => {
|
||||
const store = createStore(
|
||||
|
@ -12,7 +10,6 @@ const configureStore = (preloadedState, history) => {
|
|||
preloadedState,
|
||||
compose(
|
||||
applyMiddleware(thunk, routerMiddleware(history), createLogger())
|
||||
// DevTools.instrument()
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue