chore: prettier Server

This commit is contained in:
41666 2020-08-02 16:29:00 -04:00
parent d08c9e4829
commit 5119e1142c
No known key found for this signature in database
GPG key ID: BC51D07640DC10AF
5 changed files with 16 additions and 16 deletions

View file

@ -1,5 +1,5 @@
module.exports = (R, $) => { module.exports = (R, $) => {
R.post('/api/auth/token', async ctx => { R.post('/api/auth/token', async (ctx) => {
const { token } = ctx.request.body const { token } = ctx.request.body
if (token == null || token === '') { if (token == null || token === '') {
@ -27,7 +27,7 @@ module.exports = (R, $) => {
} }
}) })
R.get('/api/auth/user', async ctx => { R.get('/api/auth/user', async (ctx) => {
if (ctx.session.accessToken === undefined) { if (ctx.session.accessToken === undefined) {
ctx.body = { err: 'not_logged_in' } ctx.body = { err: 'not_logged_in' }
ctx.status = 401 ctx.status = 401
@ -46,7 +46,7 @@ module.exports = (R, $) => {
} }
}) })
R.get('/api/auth/redirect', ctx => { R.get('/api/auth/redirect', (ctx) => {
const url = $.discord.getAuthUrl() const url = $.discord.getAuthUrl()
if (ctx.query.url === '✔️') { if (ctx.query.url === '✔️') {
ctx.body = { url } ctx.body = { url }
@ -56,11 +56,11 @@ module.exports = (R, $) => {
ctx.redirect(url) ctx.redirect(url)
}) })
R.post('/api/auth/logout', ctx => { R.post('/api/auth/logout', (ctx) => {
ctx.session = null ctx.session = null
}) })
R.get('/api/oauth/bot', ctx => { R.get('/api/oauth/bot', (ctx) => {
const url = $.discord.getBotJoinUrl() const url = $.discord.getBotJoinUrl()
if (ctx.query.url === '✔️') { if (ctx.query.url === '✔️') {
ctx.body = { url } ctx.body = { url }
@ -70,5 +70,5 @@ module.exports = (R, $) => {
ctx.redirect(url) ctx.redirect(url)
}) })
R.get('/api/oauth/bot/callback', ctx => {}) R.get('/api/oauth/bot/callback', (ctx) => {})
} }

View file

@ -12,7 +12,7 @@ const Roleypoly = require('./Roleypoly')
const ksuid = require('ksuid') const ksuid = require('ksuid')
// monkey patch async-reduce because F U T U R E // monkey patch async-reduce because F U T U R E
Array.prototype.areduce = async function(predicate, acc = []) { Array.prototype.areduce = async function (predicate, acc = []) {
// eslint-disable-line // eslint-disable-line
for (let i of this) { for (let i of this) {
acc = await predicate(acc, i) acc = await predicate(acc, i)
@ -23,8 +23,8 @@ Array.prototype.areduce = async function(predicate, acc = []) {
Array.prototype.filterNot = Array.prototype.filterNot =
Array.prototype.filterNot || Array.prototype.filterNot ||
function(predicate) { function (predicate) {
return this.filter(v => !predicate(v)) return this.filter((v) => !predicate(v))
} }
// Create the server and socket.io server // Create the server and socket.io server
@ -139,6 +139,6 @@ async function start() {
server.listen(process.env.APP_PORT || 6769) server.listen(process.env.APP_PORT || 6769)
} }
start().catch(e => { start().catch((e) => {
log.fatal('app failed to start', e) log.fatal('app failed to start', e)
}) })

View file

@ -2,12 +2,12 @@ const log = new (require('../logger'))('models/index')
const glob = require('glob') const glob = require('glob')
const path = require('path') const path = require('path')
module.exports = sql => { module.exports = (sql) => {
const models = {} const models = {}
const modelFiles = glob.sync('./models/**/!(index).js') const modelFiles = glob.sync('./models/**/!(index).js')
log.debug('found models', modelFiles) log.debug('found models', modelFiles)
modelFiles.forEach(v => { modelFiles.forEach((v) => {
let name = path.basename(v).replace('.js', '') let name = path.basename(v).replace('.js', '')
if (v === './models/index.js') { if (v === './models/index.js') {
log.debug('index.js hit, skipped') log.debug('index.js hit, skipped')
@ -23,7 +23,7 @@ module.exports = sql => {
} }
}) })
Object.keys(models).forEach(v => { Object.keys(models).forEach((v) => {
if (models[v].hasOwnProperty('__associations')) { if (models[v].hasOwnProperty('__associations')) {
models[v].__associations(models) models[v].__associations(models)
} }

View file

@ -43,7 +43,7 @@ class PresentationService extends Service {
const serverData = await this.ctx.server.get(server.id) const serverData = await this.ctx.server.get(server.id)
const serverRoles = await this.discord.getRoles(server.id) const serverRoles = await this.discord.getRoles(server.id)
const memberRoles = member.rolesList const memberRoles = member.rolesList
.map(id => serverRoles.find(role => role.id === id)) .map((id) => serverRoles.find((role) => role.id === id))
.sort((a, b) => (a.position > b.position ? -1 : 1)) .sort((a, b) => (a.position > b.position ? -1 : 1))
const color = memberRoles.length > 0 ? memberRoles[0].color : 0 const color = memberRoles.length > 0 ? memberRoles[0].color : 0
@ -67,7 +67,7 @@ class PresentationService extends Service {
if (process.env.DISABLE_CACHE === 'true') { if (process.env.DISABLE_CACHE === 'true') {
return func() return func()
} }
if (this.cache.has(key)) { if (this.cache.has(key)) {
return this.cache.get(key) return this.cache.get(key)
} }

View file

@ -2,7 +2,7 @@ const ksuid = require('ksuid')
module.exports = { module.exports = {
ksuid(field = 'id') { ksuid(field = 'id') {
return async function() { return async function () {
this.id = await ksuid.random() this.id = await ksuid.random()
return this return this
} }